ietf-tools / xml2rfc

Generate RFCs and IETF drafts from document source in XML according to the IETF xml2rfc v2 and v3 vocabularies
https://ietf-tools.github.io/xml2rfc/
BSD 3-Clause "New" or "Revised" License
69 stars 38 forks source link

The formatting of artwork used in a definition list #1024

Open ajeanmahoney opened 1 year ago

ajeanmahoney commented 1 year ago

Describe the issue

Somewhat of a corner case, but in the following definition list, artwork is used as the definition:

        <dl spacing="normal" newline="false">
          <dt>Metric (4 octets):</dt>
          <dd>Metric information as defined in ...</dd>
          <dt>Flags (1 octet):</dt>
          <dd>
            <artwork><![CDATA[
 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|D|  Reserved   |
+-+-+-+-+-+-+-+-+
]]></artwork>
              <dl newline="false" spacing="normal">
                <dt>D-flag:</dt>
                <dd>When the Prefix ...</dd>
              </dl>
          </dd>
          <dt>...

As coded above (see [1] and look for [JM] in the comments), the HTML output shows the artwork appearing on a new line. The question is, should it? The newline attribute was set to false. There is also a lack of whitespace between the artwork at the "Flags (1 octet):" line.

Adding an empty <t/> in front of the artwork (see [2]) causes the artwork to be placed inline, which is unexpected behavior. The expectation is that the empty <t/> would start the artwork on a newline and perhaps fix the whitespace issue.

Adding text in front of the artwork (e.g., <t>The following flags are defined:</t>; see Section 6.3) causes the output to be formatted correctly (this is the workaround).

[1] https://www.rfc-editor.org/v3test/draft-ietf-lsr-ip-flexalgo-16.xml [2] https://www.rfc-editor.org/v3test/draft-ietf-lsr-ip-flexalgo-16-alt.xml

Code of Conduct

kesara commented 1 year ago

CSS was designed this way [1] to match text output.

/* Elements that should not be rendered on the same line as a <dt> */
/* This should match the element list in writer.text.TextWriter.render_dl() */
dd > div.artwork:first-child,
dd > aside:first-child,
dd > figure:first-child,
dd > ol:first-child,
dd > div.sourcecode:first-child,
dd > table:first-child,
dd > ul:first-child {
  clear: left;
}

[1] https://github.com/ietf-tools/xml2rfc/blob/main/xml2rfc/data/xml2rfc.css#L1140-L1142

kesara commented 1 year ago

Note that the alternative version with <t/> will not give you the desired results in text output.

   Flags (1 octet):  0 1 2 3 4 5 6 7
      +-+-+-+-+-+-+-+-+
      |D|  Reserved   |
      +-+-+-+-+-+-+-+-+

      D-flag:  When the Prefix is leaked from level-2 to level-1, the D
         bit MUST be set.  Otherwise, this bit MUST be clear.  Prefixes
         with the D bit set MUST NOT be leaked from level-1 to level-2.
         This is to prevent looping.
cabo commented 1 year ago

RFC 7991 assumes that you know which of the elements it defines are block-level elements (as opposed to span-level elements, which generally can occur in mixed content with "text" interspersed). This is never said anywhere, but <artwork is a block-level element.

(Block-level elements arrange vertically down the page; span-level elements arrange horizontally on the line.)