Skip to content

Commit

Permalink
fix(text): Update non-ASCII art text (#1140)
Browse files Browse the repository at this point in the history
* fix(text): Update non-ASCII art text

Fixes #617

This change introduces two new command line options for text:
   --rfc-html-archive-url
      Default value: https://www.rfc-editor.org/rfc/
      URL for HTML file archive of RFCs.

   --id-html-archive-url
      Default value: https://www.ietf.org/archive/id/
      URL for HTML file archive Internet-Drafts.

* chore: Run yestests pre-changes

* chore: Run yestests post-changes
  • Loading branch information
kesara committed Sep 16, 2024
1 parent 3dfb04c commit e2b8734
Show file tree
Hide file tree
Showing 22 changed files with 166 additions and 95 deletions.
29 changes: 29 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,35 @@ def test_render_reference(self):
self.assertEqual(len(lines), 2)
self.assertIn(url, lines[1].text)

def test_render_artwork_svg_only(self):
artwork_str = '''
<artwork type="svg">
<svg xmlns="http://www.w3.org/2000/svg">
<text x="10" y="15">foobar</text>
</svg>
</artwork>'''
artwork = lxml.etree.fromstring(artwork_str)

# for RFC
self.writer.root = lxml.etree.fromstring(f'<rfc number="1234"></rfc>')
self.writer.options.rfc = True
self.writer.rfcnumber = 1234
lines = self.writer.render_artwork(artwork, width=60)
text = ''.join(line.text for line in lines)
self.assertIn("Artwork only available as svg", text)
self.assertIn(default_options.rfc_html_archive_url, text)
self.assertIn('rfc1234.html', text)

# for Draft
self.writer.options.rfc = None
lines = self.writer.render_artwork(artwork, width=60)
text = ' '.join(line.text for line in lines)
self.assertIn("Artwork only available as svg", text)
self.assertIn(default_options.id_html_archive_url, text)
self.assertIn(".html", text)



class BaseV3WriterTest(unittest.TestCase):
'''BaseV3Writer tests'''

Expand Down
36 changes: 28 additions & 8 deletions tests/valid/docfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<meta charset="utf-8">
<meta content="Cherokee,Common,Greek,Latin" name="scripts">
<meta content="initial-scale=1.0" name="viewport">
<title>Xml2rfc Vocabulary Version 3 Schema xml2rfc release 3.22.0</title>
<title>Xml2rfc Vocabulary Version 3 Schema xml2rfc release 3.23.0</title>
<meta content="xml2rfc(1)" name="author">
<meta content="
This document provides information about the XML schema implemented in this release of xml2rfc, and the individual elements of that schema. The document is generated from the RNG schema file that is part of the xml2rfc distribution, so schema information in this document should always be in sync with the schema in actual use. The textual descriptions depend on manual updates in order to reflect the implementation.
" name="description">
<meta content="xml2rfc 3.22.0" name="generator">
<meta content="xml2rfc-docs-3.22.0" name="ietf.draft">
<meta content="xml2rfc 3.23.0" name="generator">
<meta content="xml2rfc-docs-3.23.0" name="ietf.draft">
<link href="tests/out/docfile.xml" rel="alternate" type="application/rfc+xml">
<link href="#copyright" rel="license">
<link href="xml2rfc.css" rel="stylesheet">
Expand All @@ -24,7 +24,7 @@
<thead><tr>
<td class="left"></td>
<td class="center">Xml2rfc Vocabulary V3 Schema</td>
<td class="right">August 2024</td>
<td class="right">September 2024</td>
</tr></thead>
<tfoot><tr>
<td class="left">xml2rfc(1)</td>
Expand All @@ -39,7 +39,7 @@
<dd class="workgroup">xml2rfc(1)</dd>
<dt class="label-published">Published:</dt>
<dd class="published">
<time datetime="2024-08-19" class="published">19 August 2024</time>
<time datetime="2024-09-16" class="published">16 September 2024</time>
</dd>
<dt class="label-authors">Author:</dt>
<dd class="authors">
Expand All @@ -49,7 +49,7 @@
</dd>
</dl>
</div>
<h1 id="title">Xml2rfc Vocabulary Version 3 Schema<br>xml2rfc release 3.22.0</h1>
<h1 id="title">Xml2rfc Vocabulary Version 3 Schema<br>xml2rfc release 3.23.0</h1>
<section id="section-abstract">
<h2 id="abstract"><a href="#abstract" class="selfRef">Abstract</a></h2>
<p id="section-abstract-1">
Expand Down Expand Up @@ -371,7 +371,7 @@ <h2 id="name-introduction">
<p id="section-1-5">
The latest version of this documentation is available in HTML form at <span><a href="https://ietf-tools.github.io/xml2rfc/">https://ietf-tools.github.io/xml2rfc/</a></span>.<a href="#section-1-5" class="pilcrow"></a></p>
<p id="section-1-6">
This documentation applies to xml2rfc version 3.22.0.<a href="#section-1-6" class="pilcrow"></a></p>
This documentation applies to xml2rfc version 3.23.0.<a href="#section-1-6" class="pilcrow"></a></p>
</section>
<section id="section-2">
<h2 id="name-schema-version-3-elements">
Expand Down Expand Up @@ -6188,6 +6188,26 @@ <h3 id="name-text-format-options">
</dd>
<dd class="break"></dd>
</dl>
</dd>
<dd class="break"></dd>
<dt id="appendix-B.7-1.17">
<div id="option--rfc-html-archive-url">
<code>--rfc-html-archive-url</code> </div>
</dt>
<dd style="margin-left: 1.5em" id="appendix-B.7-1.18">
<p id="appendix-B.7-1.18.1"><br>Default value: https://www.rfc-editor.org/rfc/<a href="#appendix-B.7-1.18.1" class="pilcrow"></a></p>
<p id="appendix-B.7-1.18.2">
URL for HTML file archive of RFCs.<a href="#appendix-B.7-1.18.2" class="pilcrow"></a></p>
</dd>
<dd class="break"></dd>
<dt id="appendix-B.7-1.19">
<div id="option--id-html-archive-url">
<code>--id-html-archive-url</code> </div>
</dt>
<dd style="margin-left: 1.5em" id="appendix-B.7-1.20">
<p id="appendix-B.7-1.20.1"><br>Default value: https://www.ietf.org/archive/id/<a href="#appendix-B.7-1.20.1" class="pilcrow"></a></p>
<p id="appendix-B.7-1.20.2">
URL for HTML file archive Internet-Drafts.<a href="#appendix-B.7-1.20.2" class="pilcrow"></a></p>
</dd>
<dd class="break"></dd>
</dl>
Expand Down Expand Up @@ -6367,7 +6387,7 @@ <h2 id="name-xml2rfc-documentation-templ">
<p id="appendix-D-1">

The following variables are available for use in an xml2rfc
manpage Jinja2 template, as of xml2rfc version 3.22.0:<a href="#appendix-D-1" class="pilcrow"></a></p>
manpage Jinja2 template, as of xml2rfc version 3.23.0:<a href="#appendix-D-1" class="pilcrow"></a></p>
<span class="break"></span><dl class="dlNewline" id="appendix-D-2">
<dt id="appendix-D-2.1">{{ bare_latin_tags }}:</dt>
<dd style="margin-left: 1.5em" id="appendix-D-2.2"></dd>
Expand Down
6 changes: 3 additions & 3 deletions tests/valid/draft-miek-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
This version is adapted to work with "xml2rfc" version 2.x.
' name="description">
<meta content="xml2rfc 3.22.0" name="generator">
<meta content="xml2rfc 3.23.0" name="generator">
<meta content="RFC" name="keyword">
<meta content="Request for Comments" name="keyword">
<meta content="I-D" name="keyword">
Expand All @@ -26,7 +26,7 @@
<meta content="Extensible Markup Language" name="keyword">
<meta content="draft-gieben-writing-rfcs-pandoc-02" name="ietf.draft">
<!-- Generator version information:
xml2rfc 3.22.0
xml2rfc 3.23.0
Python 3.12.4
ConfigArgParse 1.7
google-i18n-address 3.1.0
Expand Down Expand Up @@ -1173,7 +1173,7 @@
tt, code {
background-color: transparent;
}
p tt, p code, li tt, li code {
p tt, p code, li tt, li code, dt tt, dt code {
background-color: #f8f8f8;
}
/* Tweak the pre margin -- 0px doesn't come out well */
Expand Down
6 changes: 3 additions & 3 deletions tests/valid/draft-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
Insert an abstract: MANDATORY. This template is for creating an
Internet Draft.
" name="description">
<meta content="xml2rfc 3.22.0" name="generator">
<meta content="xml2rfc 3.23.0" name="generator">
<meta content="template" name="keyword">
<meta content="draft-ietf-xml2rfc-template-05" name="ietf.draft">
<!-- Generator version information:
xml2rfc 3.22.0
xml2rfc 3.23.0
Python 3.12.4
ConfigArgParse 1.7
google-i18n-address 3.1.0
Expand Down Expand Up @@ -1162,7 +1162,7 @@
tt, code {
background-color: transparent;
}
p tt, p code, li tt, li code {
p tt, p code, li tt, li code, dt tt, dt code {
background-color: #f8f8f8;
}
/* Tweak the pre margin -- 0px doesn't come out well */
Expand Down
19 changes: 10 additions & 9 deletions tests/valid/draft-v3-features.text
Original file line number Diff line number Diff line change
Expand Up @@ -519,41 +519,42 @@ Table of Contents

Text before...

(Artwork only available as svg: No external link available, see
draft-v3-features.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/draft-v3-features.html)

Text after...

8.2. inline (left)

Text before...

(Artwork only available as svg: No external link available, see
draft-v3-features.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/draft-v3-features.html)

Text after...

8.3. inline (centered)

Text before...

(Artwork only available as svg: No external link available, see
draft-v3-features.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/draft-v3-features.html)

Text after...

8.4. inline (right)

Text before...

(Artwork only available as svg: No external link available, see
draft-v3-features.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/draft-v3-features.html)

Text after...

8.5. included (type svg)

(Artwork only available as svg: rfc7991.references.svg)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/draft-v3-features.html)
+--------------------+
| Included from file |
+--------------------+
Expand Down
8 changes: 4 additions & 4 deletions tests/valid/elements.bom.text
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018

* Artset include with <xi:include>

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

* Unicode SVG rendering test

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

4. Ordered list with sub-elements

Expand Down
8 changes: 4 additions & 4 deletions tests/valid/elements.pages.text
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018

* Artset include with <xi:include>

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

* Unicode SVG rendering test

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

4. Ordered list with sub-elements

Expand Down
8 changes: 4 additions & 4 deletions tests/valid/elements.text
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ Table of Contents

* Artset include with <xi:include>

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

* Unicode SVG rendering test

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

4. Ordered list with sub-elements

Expand Down
8 changes: 4 additions & 4 deletions tests/valid/elements.wip.text
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018

* Artset include with <xi:include>

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

* Unicode SVG rendering test

(Artwork only available as svg: No external link available, see
elements-00.html for artwork.)
(Artwork only available as svg: see
https://www.ietf.org/archive/id/elements-00.html)

4. Ordered list with sub-elements

Expand Down
16 changes: 8 additions & 8 deletions tests/valid/indexes.pages.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group H. Person, Ed.
Internet-Draft August 19, 2024
Internet-Draft September 16, 2024
Intended status: Experimental
Expires: February 20, 2025
Expires: March 20, 2025


xml2rfc index tests
Expand All @@ -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 20, 2025.
This Internet-Draft will expire on March 20, 2025.

Copyright Notice

Expand All @@ -53,9 +53,9 @@ Table of Contents



Person Expires February 20, 2025 [Page 1]
Person Expires March 20, 2025 [Page 1]

Internet-Draft xml2rfc index tests August 2024
Internet-Draft xml2rfc index tests September 2024


This is another section!
Expand Down Expand Up @@ -109,9 +109,9 @@ Index



Person Expires February 20, 2025 [Page 2]
Person Expires March 20, 2025 [Page 2]

Internet-Draft xml2rfc index tests August 2024
Internet-Draft xml2rfc index tests September 2024


E
Expand Down Expand Up @@ -165,4 +165,4 @@ Author's Address



Person Expires February 20, 2025 [Page 3]
Person Expires March 20, 2025 [Page 3]
8 changes: 4 additions & 4 deletions tests/valid/indexes.prepped.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" sortRefs="true" category="exp" submissionType="independent" ipr="trust200902" docName="indexes-00" indexInclude="true" prepTime="2024-08-19T02:51:35" scripts="Common,Latin" symRefs="true" tocDepth="3" tocInclude="true">
<!-- xml2rfc v2v3 conversion 3.22.0 -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" sortRefs="true" category="exp" submissionType="independent" ipr="trust200902" docName="indexes-00" indexInclude="true" prepTime="2024-09-16T20:21:25" scripts="Common,Latin" symRefs="true" tocDepth="3" tocInclude="true">
<!-- xml2rfc v2v3 conversion 3.23.0 -->



Expand All @@ -20,7 +20,7 @@
</postal>
</address>
</author>
<date day="19" month="08" year="2024"/>
<date day="16" month="09" year="2024"/>
<boilerplate>
<section anchor="status-of-memo" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.1">
<name slugifiedName="name-status-of-this-memo">Status of This Memo</name>
Expand All @@ -41,7 +41,7 @@
material or to cite them other than as "work in progress."
</t>
<t indent="0" pn="section-boilerplate.1-4">
This Internet-Draft will expire on 20 February 2025.
This Internet-Draft will expire on 20 March 2025.
</t>
</section>
<section anchor="copyright" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.2">
Expand Down
6 changes: 3 additions & 3 deletions tests/valid/indexes.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group H. Person, Ed.
Internet-Draft August 19, 2024
Internet-Draft September 16, 2024
Intended status: Experimental
Expires: February 20, 2025
Expires: March 20, 2025


xml2rfc index tests
Expand All @@ -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 20, 2025.
This Internet-Draft will expire on March 20, 2025.

Copyright Notice

Expand Down
Loading

0 comments on commit e2b8734

Please sign in to comment.