From d1ba2ea82282f838c09de813292db384cc3d089f Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Tue, 9 Jul 2024 20:17:10 +1200 Subject: [PATCH 1/5] fix: Render ol items correctly Fixes #1135 --- xml2rfc/writers/text.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xml2rfc/writers/text.py b/xml2rfc/writers/text.py index 94a3b7fb..9e9aeb64 100644 --- a/xml2rfc/writers/text.py +++ b/xml2rfc/writers/text.py @@ -2152,7 +2152,11 @@ def render_li(self, e, width, **kwargs): tt, __ = self.text_or_block_renderer(e, width, **kwargs) if isinstance(tt, list): lines = stripl(tt) - if lines and lines[0].elem.tag not in ['artwork', 'figure', 'sourcecode', 'li', ]: + if ( + lines + and lines[0].elem.tag not in ["artwork", "figure", "sourcecode"] + and not (p.tag == "ul" and lines[0].elem.tag == "li") + ): lines[0].text = text + lines[0].text.lstrip(stripspace) else: text += tt.lstrip(stripspace) From efb4df68db3383b571593fe97ef2f573538a44ea Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Wed, 10 Jul 2024 12:11:50 +1200 Subject: [PATCH 2/5] fix: Insert a new line to li rather than skipping --- xml2rfc/writers/text.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/xml2rfc/writers/text.py b/xml2rfc/writers/text.py index 9e9aeb64..fc0c5a10 100644 --- a/xml2rfc/writers/text.py +++ b/xml2rfc/writers/text.py @@ -2152,12 +2152,21 @@ def render_li(self, e, width, **kwargs): tt, __ = self.text_or_block_renderer(e, width, **kwargs) if isinstance(tt, list): lines = stripl(tt) + children = e.getchildren() if ( - lines - and lines[0].elem.tag not in ["artwork", "figure", "sourcecode"] - and not (p.tag == "ul" and lines[0].elem.tag == "li") + children + and children[0].tag in ["artwork", "figure", "sourcecode", "ol", "ul"] + and not (p.tag == "ul" and p.get("empty", "false").lower() == "true") ): - lines[0].text = text + lines[0].text.lstrip(stripspace) + lines.insert(0, Line(text.rstrip(stripspace), e)) + else: + if lines and lines[0].elem.tag not in [ + "artwork", + "figure", + "sourcecode", + "li", + ]: + lines[0].text = text + lines[0].text.lstrip(stripspace) else: text += tt.lstrip(stripspace) lines = mklines(text, e) From d9db9aaeb81ddadc487a0170a803c1afcd8acb1f Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Mon, 9 Dec 2024 11:32:46 +1300 Subject: [PATCH 3/5] test: Add test for ul with empty bullets --- tests/input/elements.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/input/elements.xml b/tests/input/elements.xml index 67eecd9f..f4b78d89 100644 --- a/tests/input/elements.xml +++ b/tests/input/elements.xml @@ -1362,6 +1362,26 @@ for opt, value in opts: +
  • + ul with no bullets +
      +
    • +
        +
      • Must not have an empty line with bullet above this line.
      • +
      +
    • +
    +
  • +
  • + ul with bullets +
      +
    • +
        +
      • Must have an empty line with bullet above this line.
      • +
      +
    • +
    +
  • From cf194c7be6aafa62acb9ce00419a0b4020d72ef2 Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Mon, 9 Dec 2024 12:56:52 +1300 Subject: [PATCH 4/5] chore: Run yestests pre-changes --- tests/valid/indexes.pages.text | 12 ++++++------ tests/valid/indexes.prepped.xml | 6 +++--- tests/valid/indexes.text | 6 +++--- tests/valid/indexes.v3.html | 8 ++++---- tests/valid/manpage.txt | 2 +- tests/valid/sourcecode.pages.text | 14 +++++++------- tests/valid/sourcecode.prepped.xml | 6 +++--- tests/valid/sourcecode.text | 6 +++--- tests/valid/sourcecode.v3.html | 8 ++++---- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/valid/indexes.pages.text b/tests/valid/indexes.pages.text index 4d8635d1..75e37e92 100644 --- a/tests/valid/indexes.pages.text +++ b/tests/valid/indexes.pages.text @@ -3,9 +3,9 @@ Network Working Group H. Person, Ed. -Internet-Draft December 4, 2024 +Internet-Draft December 8, 2024 Intended status: Experimental -Expires: June 7, 2025 +Expires: June 11, 2025 xml2rfc index tests @@ -26,7 +26,7 @@ Status of This Memo time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on June 7, 2025. + This Internet-Draft will expire on June 11, 2025. Copyright Notice @@ -53,7 +53,7 @@ Table of Contents -Person Expires June 7, 2025 [Page 1] +Person Expires June 11, 2025 [Page 1] Internet-Draft xml2rfc index tests December 2024 @@ -109,7 +109,7 @@ Index -Person Expires June 7, 2025 [Page 2] +Person Expires June 11, 2025 [Page 2] Internet-Draft xml2rfc index tests December 2024 @@ -165,4 +165,4 @@ Author's Address -Person Expires June 7, 2025 [Page 3] +Person Expires June 11, 2025 [Page 3] diff --git a/tests/valid/indexes.prepped.xml b/tests/valid/indexes.prepped.xml index 86f9aec1..6b5ee504 100644 --- a/tests/valid/indexes.prepped.xml +++ b/tests/valid/indexes.prepped.xml @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@ - +
    Status of This Memo @@ -41,7 +41,7 @@ material or to cite them other than as "work in progress." - This Internet-Draft will expire on 7 June 2025. + This Internet-Draft will expire on 11 June 2025.
    diff --git a/tests/valid/indexes.text b/tests/valid/indexes.text index 36f16d62..4d814a40 100644 --- a/tests/valid/indexes.text +++ b/tests/valid/indexes.text @@ -3,9 +3,9 @@ Network Working Group H. Person, Ed. -Internet-Draft December 4, 2024 +Internet-Draft December 8, 2024 Intended status: Experimental -Expires: June 7, 2025 +Expires: June 11, 2025 xml2rfc index tests @@ -26,7 +26,7 @@ Status of This Memo time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on June 7, 2025. + This Internet-Draft will expire on June 11, 2025. Copyright Notice diff --git a/tests/valid/indexes.v3.html b/tests/valid/indexes.v3.html index 43f59f89..51189155 100644 --- a/tests/valid/indexes.v3.html +++ b/tests/valid/indexes.v3.html @@ -23,7 +23,7 @@ Person -Expires June 7, 2025 +Expires June 11, 2025 [Page] @@ -36,12 +36,12 @@
    indexes-00
    Published:
    - +
    Intended Status:
    Experimental
    Expires:
    -
    +
    Author:
    @@ -71,7 +71,7 @@

    time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    - This Internet-Draft will expire on June 7, 2025.

    + This Internet-Draft will expire on June 11, 2025.

    Dreiunddreißig Gedichte

    + +
  • +

    ul with no bullets

    +
      +
    • +
        +
      • Must not have an empty line with bullet above this line. +
      • +
      +
    • +
    +
  • +
  • +

    ul with bullets

    +
      +
    • +
        +
      • Must have an empty line with bullet above this line. +
      • +
      +
    • +
  • diff --git a/tests/valid/elements.wip.text b/tests/valid/elements.wip.text index 2ec054b0..f5fca1ae 100644 --- a/tests/valid/elements.wip.text +++ b/tests/valid/elements.wip.text @@ -93,9 +93,9 @@ Table of Contents CMS References . . . . . . . . . . . . . . . . . . . . . . . 25 ESS References . . . . . . . . . . . . . . . . . . . . . . . 26 MIME-SPEC References . . . . . . . . . . . . . . . . . . . . 26 - Other References . . . . . . . . . . . . . . . . . . . . . . 26 + Other References . . . . . . . . . . . . . . . . . . . . . . 27 Appendix A. Some Back Matter . . . . . . . . . . . . . . . . . . 27 - A.1. Contributors . . . . . . . . . . . . . . . . . . . . . . 27 + A.1. Contributors . . . . . . . . . . . . . . . . . . . . . . 28 A.2. Arbitrary^superscript in section _title_ . . . . . . . . 28 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 28 @@ -450,6 +450,7 @@ Author, et al. Expires 13 January 2019 [Page 8] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + 4. 4.1 Sublist with '%p' parent counter element in the list counter, item one @@ -500,7 +501,6 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - Author, et al. Expires 13 January 2019 [Page 9] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 @@ -1351,6 +1351,7 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 * Indent="5". “The heaviest penalty for declining to rule is to be ruled by someone inferior to yourself.” Πολιτεία + * Ich weiß nicht, was soll es bedeuten, Daß ich so traurig bin; Ein Mährchen aus alten Zeiten, @@ -1358,6 +1359,15 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 Dreiunddreißig Gedichte + * ul with no bullets + + o Must not have an empty line with bullet above this line. + + * ul with bullets + + - + o Must have an empty line with bullet above this line. + References Normative References @@ -1379,6 +1389,19 @@ Informative References CMS References + + + + + + + + +Author, et al. Expires 13 January 2019 [Page 25] + +Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + [I-D.levkowetz-xml2rfc-v3-implementation-notes] Levkowetz, H., "Implementation notes for RFC7991,", Work in Progress, Internet-Draft, draft-levkowetz-xml2rfc-v3- @@ -1395,13 +1418,6 @@ CMS References RFC 5652, DOI 10.17487/RFC5652, September 2009, . - - -Author, et al. Expires 13 January 2019 [Page 25] - -Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - - ESS References [RFC2634] Hoffman, P., Ed., "Enhanced Security Services for S/MIME", @@ -1435,6 +1451,13 @@ MIME-SPEC References Examples", RFC 2049, DOI 10.17487/RFC2049, November 1996, . + + +Author, et al. Expires 13 January 2019 [Page 26] + +Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + [RFC4289] Freed, N. and J. Klensin, "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures", BCP 13, RFC 4289, DOI 10.17487/RFC4289, December 2005, @@ -1447,17 +1470,6 @@ MIME-SPEC References Other References - - - - - - -Author, et al. Expires 13 January 2019 [Page 26] - -Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - - [AUTHORS] Πυθαγόρας ὁ Σάμιος (Samos, P. O.), Doe, J., Bergström, A., and J. Doe, "Lots of authors", RFC 7539, DOI 10.17487/RFC7539, May 2015, @@ -1493,6 +1505,15 @@ Appendix A. Some Back Matter // This is a long comment line which extends well beyond the // 72-character page width. + + + + +Author, et al. Expires 13 January 2019 [Page 27] + +Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + A.1. Contributors We'd like to thank these contributors: @@ -1505,15 +1526,6 @@ A.1. Contributors Additional contact information: - - - - -Author, et al. Expires 13 January 2019 [Page 27] - -Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - - רוני אבן וואווי דוד המלך 14 @@ -1547,6 +1559,17 @@ Authors' Addresses Additional contact information: + + + + + + +Author, et al. Expires 13 January 2019 [Page 28] + +Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + רוני אבן וואווי דוד המלך 14 @@ -1563,13 +1586,6 @@ Authors' Addresses Additional contact information: - - -Author, et al. Expires 13 January 2019 [Page 28] - -Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - - 田中花子 様 日本 〒112-0001 @@ -1604,21 +1620,5 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - - - - - - - - - - - - - - - - Author, et al. Expires 13 January 2019 [Page 29] diff --git a/tests/valid/indexes.pages.text b/tests/valid/indexes.pages.text index 75e37e92..8198e1f4 100644 --- a/tests/valid/indexes.pages.text +++ b/tests/valid/indexes.pages.text @@ -3,9 +3,9 @@ Network Working Group H. Person, Ed. -Internet-Draft December 8, 2024 +Internet-Draft December 9, 2024 Intended status: Experimental -Expires: June 11, 2025 +Expires: June 12, 2025 xml2rfc index tests @@ -26,7 +26,7 @@ Status of This Memo time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on June 11, 2025. + This Internet-Draft will expire on June 12, 2025. Copyright Notice @@ -53,7 +53,7 @@ Table of Contents -Person Expires June 11, 2025 [Page 1] +Person Expires June 12, 2025 [Page 1] Internet-Draft xml2rfc index tests December 2024 @@ -109,7 +109,7 @@ Index -Person Expires June 11, 2025 [Page 2] +Person Expires June 12, 2025 [Page 2] Internet-Draft xml2rfc index tests December 2024 @@ -165,4 +165,4 @@ Author's Address -Person Expires June 11, 2025 [Page 3] +Person Expires June 12, 2025 [Page 3] diff --git a/tests/valid/indexes.prepped.xml b/tests/valid/indexes.prepped.xml index 6b5ee504..49008ea1 100644 --- a/tests/valid/indexes.prepped.xml +++ b/tests/valid/indexes.prepped.xml @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@ - +
    Status of This Memo @@ -41,7 +41,7 @@ material or to cite them other than as "work in progress." - This Internet-Draft will expire on 11 June 2025. + This Internet-Draft will expire on 12 June 2025.
    diff --git a/tests/valid/indexes.text b/tests/valid/indexes.text index 4d814a40..3f851621 100644 --- a/tests/valid/indexes.text +++ b/tests/valid/indexes.text @@ -3,9 +3,9 @@ Network Working Group H. Person, Ed. -Internet-Draft December 8, 2024 +Internet-Draft December 9, 2024 Intended status: Experimental -Expires: June 11, 2025 +Expires: June 12, 2025 xml2rfc index tests @@ -26,7 +26,7 @@ Status of This Memo time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on June 11, 2025. + This Internet-Draft will expire on June 12, 2025. Copyright Notice diff --git a/tests/valid/indexes.v3.html b/tests/valid/indexes.v3.html index 51189155..8c9eaac1 100644 --- a/tests/valid/indexes.v3.html +++ b/tests/valid/indexes.v3.html @@ -23,7 +23,7 @@ Person -Expires June 11, 2025 +Expires June 12, 2025 [Page] @@ -36,12 +36,12 @@
    indexes-00
    Published:
    - +
    Intended Status:
    Experimental
    Expires:
    -
    +
    Author:
    @@ -71,7 +71,7 @@

    time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    - This Internet-Draft will expire on June 11, 2025.

    + This Internet-Draft will expire on June 12, 2025.