From 474592969345c99ac9befe3cbbea6d6005ba5306 Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Wed, 17 Aug 2022 11:53:13 +1000 Subject: [PATCH 1/3] chore: yestests --- tests/valid/docfile.html | 12 ++++++------ tests/valid/draft-miek-test.html | 8 ++++---- tests/valid/draft-template.html | 8 ++++---- tests/valid/indexes.pages.text | 12 ++++++------ tests/valid/indexes.prepped.xml | 8 ++++---- tests/valid/indexes.text | 6 +++--- tests/valid/indexes.v3.html | 10 +++++----- tests/valid/manpage.txt | 10 +++++----- tests/valid/rfc7911.html | 8 ++++---- tests/valid/sourcecode.pages.text | 14 +++++++------- tests/valid/sourcecode.prepped.xml | 8 ++++---- tests/valid/sourcecode.text | 6 +++--- tests/valid/sourcecode.v3.html | 10 +++++----- 13 files changed, 60 insertions(+), 60 deletions(-) diff --git a/tests/valid/docfile.html b/tests/valid/docfile.html index a0c1481b4..d19f6125b 100644 --- a/tests/valid/docfile.html +++ b/tests/valid/docfile.html @@ -4,15 +4,15 @@ -Xml2rfc Vocabulary Version 3 Schema xml2rfc release 3.13.1 +Xml2rfc Vocabulary Version 3 Schema xml2rfc release 3.14.0 - - + + @@ -45,7 +45,7 @@ -

Xml2rfc Vocabulary Version 3 Schema
xml2rfc release 3.13.1

+

Xml2rfc Vocabulary Version 3 Schema
xml2rfc release 3.14.0

Abstract

@@ -367,7 +367,7 @@

The latest version of this documentation is available in HTML form at https://ietf-tools.github.io/xml2rfc/.

- This documentation applies to xml2rfc version 3.13.1.

+ This documentation applies to xml2rfc version 3.14.0.

@@ -6351,7 +6351,7 @@

The following variables are available for use in an xml2rfc - manpage Jinja2 template, as of xml2rfc version 3.13.1:

+ manpage Jinja2 template, as of xml2rfc version 3.14.0:

{{ bare_latin_tags }}:
diff --git a/tests/valid/draft-miek-test.html b/tests/valid/draft-miek-test.html index 1e05ee171..49492bc36 100644 --- a/tests/valid/draft-miek-test.html +++ b/tests/valid/draft-miek-test.html @@ -16,7 +16,7 @@ This version is adapted to work with "xml2rfc" version 2.x. ' name="description"> - + @@ -26,8 +26,8 @@ diff --git a/tests/valid/draft-template.html b/tests/valid/draft-template.html index 98ab0f509..9fe80af7d 100644 --- a/tests/valid/draft-template.html +++ b/tests/valid/draft-template.html @@ -11,12 +11,12 @@ Insert an abstract: MANDATORY. This template is for creating an Internet Draft. " name="description"> - + diff --git a/tests/valid/indexes.pages.text b/tests/valid/indexes.pages.text index a6e6aa32f..c1db2ca02 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 August 9, 2022 +Internet-Draft August 17, 2022 Intended status: Experimental -Expires: February 10, 2023 +Expires: February 18, 2023 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 February 10, 2023. + This Internet-Draft will expire on February 18, 2023. Copyright Notice @@ -53,7 +53,7 @@ Table of Contents -Person Expires February 10, 2023 [Page 1] +Person Expires February 18, 2023 [Page 1] Internet-Draft xml2rfc index tests August 2022 @@ -109,7 +109,7 @@ Index -Person Expires February 10, 2023 [Page 2] +Person Expires February 18, 2023 [Page 2] Internet-Draft xml2rfc index tests August 2022 @@ -165,4 +165,4 @@ Author's Address -Person Expires February 10, 2023 [Page 3] +Person Expires February 18, 2023 [Page 3] diff --git a/tests/valid/indexes.prepped.xml b/tests/valid/indexes.prepped.xml index 1bb3839a9..75cc9383d 100644 --- a/tests/valid/indexes.prepped.xml +++ b/tests/valid/indexes.prepped.xml @@ -1,6 +1,6 @@ - - + + @@ -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 10 February 2023. + This Internet-Draft will expire on 18 February 2023.
diff --git a/tests/valid/indexes.text b/tests/valid/indexes.text index 75e4440ec..e562eb62f 100644 --- a/tests/valid/indexes.text +++ b/tests/valid/indexes.text @@ -3,9 +3,9 @@ Network Working Group H. Person, Ed. -Internet-Draft August 9, 2022 +Internet-Draft August 17, 2022 Intended status: Experimental -Expires: February 10, 2023 +Expires: February 18, 2023 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 February 10, 2023. + This Internet-Draft will expire on February 18, 2023. Copyright Notice diff --git a/tests/valid/indexes.v3.html b/tests/valid/indexes.v3.html index 927e2e045..fe30da994 100644 --- a/tests/valid/indexes.v3.html +++ b/tests/valid/indexes.v3.html @@ -6,7 +6,7 @@ xml2rfc index tests - + @@ -23,7 +23,7 @@ Person -Expires February 10, 2023 +Expires February 18, 2023 [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 February 10, 2023.

+ This Internet-Draft will expire on February 18, 2023.

diff --git a/tests/valid/manpage.txt b/tests/valid/manpage.txt index 9bf962523..beb4894e1 100644 --- a/tests/valid/manpage.txt +++ b/tests/valid/manpage.txt @@ -4008,6 +4008,9 @@ B.4. Generic Switch Options --clear-cache, -C Purge the cache and exit. + --compact-index + Generate a compact index. + --debug Show debugging output. diff --git a/xml2rfc/run.py b/xml2rfc/run.py index 1a76d97a5..d388db348 100755 --- a/xml2rfc/run.py +++ b/xml2rfc/run.py @@ -266,6 +266,8 @@ def main(): help='with --text and --html: use the legacy output formatters, rather than the v3 ones') formatoptions.add_argument('--id-is-work-in-progress', default=True, action='store_true', help='in references, refer to Internet-Drafts as "Work in Progress"') + formatoptions.add_argument('--compact-index', action='store_true', + help='Generate a compact index') textoptions = optionparser.add_argument_group('Text Format Options') textoptions.add_argument('--no-headers', dest='omit_headers', action='store_true', diff --git a/xml2rfc/writers/base.py b/xml2rfc/writers/base.py index 22e092bde..76a0ce88b 100644 --- a/xml2rfc/writers/base.py +++ b/xml2rfc/writers/base.py @@ -53,6 +53,7 @@ 'cache': None, 'clear_cache': False, 'css': None, + 'compact_index': False, 'config_file': None, 'country_help': False, 'date': None, diff --git a/xml2rfc/writers/preptool.py b/xml2rfc/writers/preptool.py index 89da1685f..845542e1e 100644 --- a/xml2rfc/writers/preptool.py +++ b/xml2rfc/writers/preptool.py @@ -1608,6 +1608,38 @@ def get_name(t): else: label = '"%s"' % (get_name(t) or target) content = "%s %s" % (type, label) + elif format == 'compact': + if t.tag in [ 'reference', 'referencegroup' ]: + anchor = t.get('anchor') + content = '%s' % self.refname_mapping[anchor] if anchor in self.refname_mapping else anchor + elif t.tag in [ 't', 'ul', 'ol', 'dl', ]: + _, num, para = self.split_pn(pn) + content = "\u00a7%s \u204b%s" % (num.title(), para) + elif t.tag in [ 'li', ]: + _, num, para = self.split_pn(pn) + para, item = para.split('.', 1) + bullet = "#" if t.getparent().tag == "ol" else "\u2022"; + content = "\u00a7%s \u204b%s %s%s" % (num.title(), para, bullet, item) + elif t.tag == 'u': + try: + content = expand_unicode_element(t, bare=True) + except (RuntimeError, ValueError) as exc: + self.err(t, '%s' % exc) + elif t.tag in ['author', 'contact']: + content = full_author_name_expansion(t) + elif t.tag in ['abstract']: + content = t.tag.capitalize() + elif t.tag in ['cref']: + content = "\"%s" % target + else: + # If section is numbered, refer by number, otherwise use section name if available + numbered = t.get('numbered') != 'false' + if numbered: + _, num, _ = self.split_pn(pn) + label = num.title() + else: + label = '"%s"' % (get_name(t) or target) + content = "\u00a7%s" % (label) elif format == 'title': if t.tag in ['u', 'author', 'contact', ]: self.die(e, "Using format='%s' with a <%s> target is not supported" % (format, t.tag, )) @@ -2195,6 +2227,7 @@ def entry_dt_dd(label, entries, indent): self, text='Reference' if ent.anchor_tag in ['reference', 'referencegroup'] else None, target=ent.anchor, + format="compact" if self.options.compact_index else "default", ) if ent.iref.get('primary') == 'true': xr_em = self.element('em') @@ -2203,7 +2236,7 @@ def entry_dt_dd(label, entries, indent): xr.append(xr_em) t.append(xr) if index < len(anchored_entries) - 1: - xr.tail = '; ' + xr.tail = ', ' if self.options.compact_index else '; ' xr.tail = (xr.tail or '') + '\n' return dt, dd From 7e0b75da922a3e4a7b8aad4ad03193cdfba834fc Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Wed, 17 Aug 2022 14:36:20 +1000 Subject: [PATCH 3/3] test: Add a test for a compact index --- Makefile | 21 ++-- tests/valid/indexes.compact_index.text | 139 +++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 8 deletions(-) create mode 100644 tests/valid/indexes.compact_index.text diff --git a/Makefile b/Makefile index 1dabbd52b..bc7000108 100644 --- a/Makefile +++ b/Makefile @@ -116,6 +116,11 @@ tests/out/%.txt tests/out/%.raw.txt tests/out/%.nroff tests/out/%.html tests/out @echo -e "\n Processing $<" @PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tests/out/ --text --html --strict $<" +tests/out/%.compact_index.text tests/out/%.compact_index.html : tests/input/%.xml install + @echo -e "\n Generating with a compact index $<" + @PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tests/out/ --$(subst .,,$(suffix $@)) --strict --compact-index --no-pagination $< --out $@" + + tests/out/%.v2v3.xml: tests/input/%.xml install @PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --v2v3 --strict --legacy-date-format $< --out $@" @doc=$(basename $@); printf ' '; xmllint --noout --xinclude --relaxng xml2rfc/data/v3.rng $$doc.xml @@ -227,12 +232,12 @@ rfcregressiontest: cleantmp install drafttest: cleantmp env/bin/python install $(drafttests) dateshifttest # rfctest: cleantmp env/bin/python install $(rfctests) -# @PS4=" " /bin/bash -cx "xml2rfc --skip-config --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --utf8tests/input/rfc6787.xml --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 --prep" -# doc=rfc6787 ; postnrofffix="cat" ; type=ascii; $(CHECKOUTPUT) -# @PS4=" " /bin/bash -cx "xml2rfc --skip-config --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --utf8tests/input/rfc7754.edited.xml --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 --prep" -# doc=rfc7754.edited ; postnrofffix="cat" ; type=ascii; $(CHECKOUTPUT) -# @PS4=" " /bin/bash -cx "xml2rfc --skip-config --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --utf8tests/input/rfc7911.xml --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 --prep" -# doc=rfc7911 ; postnrofffix="cat" ; type=ascii; $(CHECKOUTPUT) +# @PS4=" " /bin/bash -cx "xml2rfc --skip-config --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --utf8tests/input/rfc6787.xml --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 --prep" +# doc=rfc6787 ; postnrofffix="cat" ; type=ascii; $(CHECKOUTPUT) +# @PS4=" " /bin/bash -cx "xml2rfc --skip-config --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --utf8tests/input/rfc7754.edited.xml --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 --prep" +# doc=rfc7754.edited ; postnrofffix="cat" ; type=ascii; $(CHECKOUTPUT) +# @PS4=" " /bin/bash -cx "xml2rfc --skip-config --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --utf8tests/input/rfc7911.xml --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 --prep" +# doc=rfc7911 ; postnrofffix="cat" ; type=ascii; $(CHECKOUTPUT) unicodetest: cleantmp env/bin/python install @PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tmp/ --raw --legacy --text --nroff --html --no-inline-version --exp --v2v3 --prep tests/input/unicode.xml " @@ -246,11 +251,11 @@ v3featuretest: tests/out/draft-v3-features.prepped.xml.test tests/out/draft-v3-f dateshifttest: cleantmp install @PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --date 2013-02-01 --legacy --out tmp/draft-miek-test.dateshift.txt --text tests/input/draft-miek-test.xml" - @diff -u -I '$(datetime_regex)' -I '$(version_regex)' -I '$(date_regex)' tests/valid/draft-miek-test.dateshift.txt tmp/draft-miek-test.dateshift.txt || { echo "Diff failed for draft-miek-test.dateshift.txt output"; exit 1; } + @diff -u -I '$(datetime_regex)' -I '$(version_regex)' -I '$(date_regex)' tests/valid/draft-miek-test.dateshift.txt tmp/draft-miek-test.dateshift.txt || { echo "Diff failed for draft-miek-test.dateshift.txt output"; exit 1; } elementstest: install tests/out/elements.prepped.xml.test tests/out/elements.text.test tests/out/elements.pages.text.test tests/out/elements.v3.html.test -indextest: install tests/out/indexes.prepped.xml.test tests/out/indexes.text.test tests/out/indexes.pages.text.test tests/out/indexes.v3.html.test +indextest: install tests/out/indexes.prepped.xml.test tests/out/indexes.text.test tests/out/indexes.pages.text.test tests/out/indexes.v3.html.test tests/out/indexes.compact_index.text.test sourcecodetest: install tests/out/sourcecode.prepped.xml.test tests/out/sourcecode.text.test tests/out/sourcecode.pages.text.test tests/out/sourcecode.v3.html.test diff --git a/tests/valid/indexes.compact_index.text b/tests/valid/indexes.compact_index.text new file mode 100644 index 000000000..e6296350b --- /dev/null +++ b/tests/valid/indexes.compact_index.text @@ -0,0 +1,139 @@ + + + + +Network Working Group H. Person, Ed. +Internet-Draft 17 August 2022 +Intended status: Experimental +Expires: 18 February 2023 + + + xml2rfc index tests + indexes-00 + +Status of This Memo + + This Internet-Draft is submitted in full conformance with the + provisions of BCP 78 and BCP 79. + + Internet-Drafts are working documents of the Internet Engineering + Task Force (IETF). Note that other groups may also distribute + working documents as Internet-Drafts. The list of current Internet- + Drafts is at https://datatracker.ietf.org/drafts/current/. + + Internet-Drafts are draft documents valid for a maximum of six months + and may be updated, replaced, or obsoleted by other documents at any + 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 18 February 2023. + +Copyright Notice + + Copyright (c) 2022 IETF Trust and the persons identified as the + document authors. All rights reserved. + + This document is subject to BCP 78 and the IETF Trust's Legal + Provisions Relating to IETF Documents (https://trustee.ietf.org/ + license-info) in effect on the date of publication of this document. + Please review these documents carefully, as they describe your rights + and restrictions with respect to this document. + +Table of Contents + + 1. First Section + 2. References + Index + Author's Address + +1. First Section + + This is a section! _Emphatically._ *Loudly.* _(Subscripted.) + ^(Superscripted.) Typewritten. + + This is another section! + + TASK + + dt dd + + * unnumbered item + + 1. numbered item + + | This is an aside. + + | This is a blockquote. + + +===============+ + |Table heading | + +===============+ + | printf("Hello world!\n");| + +---------------+ + + Table 1 + +2. References + + [ref0] Author, R. Q., "Reference". This is a reference not in a + reference group. + + [refgroup0] + Author, R. Q., "Reference Group". This is a reference in + a reference group. + +Index + + A B D E F L S T + + A + + annotation Reference [ref0] + in reference group Reference [refgroup0] + + B + + blockquote §1 + + D + + dd §1 + dt §1 + + E + + em §1 ⁋1 + + F + + figure §1 ⁋9.1.2.1.1 + + L + + li + ol *_§1 ⁋6 #1_* + ul §1 ⁋5 •1 + + S + + section §1 + strong *_§1 ⁋1_* + sub §1 ⁋1 + sup §1 ⁋1 + + T + + t §1 ⁋1, §1 ⁋2 + in an aside tag §1 ⁋7.1 + table §1 + TASK §1 ⁋3 + td §1 ⁋9.1.2.1.1 + th §1 + tt §1 ⁋1 + +Author's Address + + Human Person (editor) + line 1 + line 2 + line 3