Subject: [xml2rfc] xml2rfc --v3 --text fails to wrap table of contents for sections with long-enough titles

From: Daniel Kahn Gillmor <[email-masked]>
Date: Fri, 16 Apr 2021 12:46:53 -0400

This is a bug report for xml2rfc's text output.  I ran into it with a
real draft (which had a legitimately long section title) but i've
narrowed it down to a simple reproducer here.

Attached is a sample foo.xml draft.

When i ask xml2rfc to generate a text version, it builds a corrupted
table of contents:

$ xml2rfc --v3 --text foo.xml --out foo.txt
(No source line available): Warning: Too long line found (L64), 80 characters longer than 72 characters: 
           Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lo  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
 Created file foo.txt
$ cat foo.txt
[…]
Table of Contents

   1.  Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Lorem
           Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lo  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .   2

1.  Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Lorem Ipsum
    Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lo

   Nothing to see here.
$

it looks like it's some sort of line-wrapping miscalculation in
generating the text output for section title that are particularly
long (if i add or remove a few extra characters to the section title it
wraps correctly).

   --dkg

<?xml version='1.0' encoding='utf-8'?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc2629 version  -->
<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent">
<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc comments="yes"?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-dkg-example-draft-00" category="info" obsoletes="" updates="" submissionType="IETF" xml:lang="en" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.7.0 -->
  <front>
    <title abbrev="Example Draft">Sample Internet Draft</title>
    <seriesInfo name="Internet-Draft" value="draft-dkg-example-draft-00"/>
    <author initials="D.K." surname="Gillmor" fullname="Daniel Kahn Gillmor">
      <organization/>
      <address>
      </address>
    </author>
    <date year="2021" month="April" day="16"/>
    <workgroup>Example Working Group</workgroup>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>This is a sample draft.</t>
    </abstract>
  </front>
  <middle>
    <section anchor="lorem-ipsum-lorem-ipsum-lorem-ipsum-lorem-ipsum-lorem-lorem-ipsum-lorem-ipsum-lorem-ipsum-lorem-ipsum-lorem-ipsum-lo" numbered="true" toc="default">
      <name>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lo</name>
      <t>Nothing to see here.</t>
    </section>
  </middle>
  <back>

  </back>
  <!-- ##markdown-source:
H4sIADu+eWAAA52QTU/DMAyG7/4V1riSqtoJch6apiEuIHFACGWt20Zt4spx
Gfv3ZIsYZ5AS6c3rr8cxxkDDrY+9xUU7cwegXieyuHp2YZ4Id1FJIiluxHW6
Anc4CH1afPgq8YsNLTfRhVzWnp+mHXtDJcEUp66hcUo9y8mijx0D+FksqixJ
13V9X6/h2P+2fWUZMxVuhZcZxqO9gpgyEZK62H64iWMee6IEs7f4ptzcYmJR
oS5ldQpFNBwCRU3vAG7RgcUCoskXM02yuKlwX+HWT1Ngudhln42LnibcuyFe
o2CMQXdIKq7JIC+DT5iPw1TYLxtXJS34tp0I4AYfWSjgbk5L+IP+X9WPBnhi
Hc7/qIyJCAcSquAbIgA6JfYBAAA=

-->

</rfc>

---

From: Daniel Kahn Gillmor <[email-masked]>
Date: Sun, 18 Apr 2021 18:44:10 -0400

> When i ask xml2rfc to generate a text version, it builds a corrupted

Julian pointed me to the trac instance, so i reported this issue there
too:

https://trac.tools.ietf.org/tools/xml2rfc/trac/ticket/624

I note that there was a Version dropdown box but it didn't have any
option for 3.7.0.  Maybe someone with admin privs on that trac instance
needs to update the metadata for that trac instance.

Thanks for the ongoing work on xml2rfc!

      --dkg