You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
(106) |
May
(215) |
Jun
(104) |
Jul
(290) |
Aug
(351) |
Sep
(245) |
Oct
(289) |
Nov
(184) |
Dec
(113) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(179) |
Feb
(88) |
Mar
(77) |
Apr
(70) |
May
(107) |
Jun
(288) |
Jul
(115) |
Aug
(67) |
Sep
(91) |
Oct
(34) |
Nov
(31) |
Dec
(61) |
2004 |
Jan
(54) |
Feb
(17) |
Mar
(102) |
Apr
(152) |
May
(178) |
Jun
(377) |
Jul
(136) |
Aug
(37) |
Sep
(196) |
Oct
(142) |
Nov
(119) |
Dec
(58) |
2005 |
Jan
(51) |
Feb
(76) |
Mar
(220) |
Apr
(132) |
May
(134) |
Jun
(230) |
Jul
(142) |
Aug
(58) |
Sep
(71) |
Oct
(76) |
Nov
(129) |
Dec
(117) |
2006 |
Jan
(94) |
Feb
(30) |
Mar
(97) |
Apr
(63) |
May
(63) |
Jun
(62) |
Jul
(23) |
Aug
(40) |
Sep
(47) |
Oct
(40) |
Nov
(23) |
Dec
(21) |
2007 |
Jan
(57) |
Feb
(65) |
Mar
(77) |
Apr
(23) |
May
(118) |
Jun
(127) |
Jul
(87) |
Aug
(33) |
Sep
(26) |
Oct
(8) |
Nov
(4) |
Dec
(25) |
2008 |
Jan
(16) |
Feb
(18) |
Mar
(16) |
Apr
(4) |
May
(22) |
Jun
(20) |
Jul
(38) |
Aug
(14) |
Sep
(18) |
Oct
(68) |
Nov
(16) |
Dec
(95) |
2009 |
Jan
(28) |
Feb
(16) |
Mar
(8) |
Apr
(44) |
May
(35) |
Jun
(41) |
Jul
(63) |
Aug
(40) |
Sep
(38) |
Oct
(41) |
Nov
(17) |
Dec
(9) |
2010 |
Jan
(9) |
Feb
(3) |
Mar
(71) |
Apr
(20) |
May
(15) |
Jun
(16) |
Jul
(33) |
Aug
(13) |
Sep
(39) |
Oct
(30) |
Nov
(25) |
Dec
(20) |
2011 |
Jan
(213) |
Feb
(252) |
Mar
(24) |
Apr
(24) |
May
(20) |
Jun
(21) |
Jul
(37) |
Aug
(18) |
Sep
(28) |
Oct
(65) |
Nov
(22) |
Dec
(48) |
2012 |
Jan
(35) |
Feb
(39) |
Mar
(17) |
Apr
(9) |
May
(37) |
Jun
(31) |
Jul
(23) |
Aug
(14) |
Sep
(16) |
Oct
(15) |
Nov
(5) |
Dec
(43) |
2013 |
Jan
(15) |
Feb
(19) |
Mar
(26) |
Apr
(13) |
May
(9) |
Jun
(11) |
Jul
(32) |
Aug
(9) |
Sep
(6) |
Oct
|
Nov
(13) |
Dec
(5) |
2014 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
|
May
(2) |
Jun
(4) |
Jul
(18) |
Aug
|
Sep
|
Oct
(3) |
Nov
(4) |
Dec
(2) |
2015 |
Jan
(3) |
Feb
(25) |
Mar
(49) |
Apr
(28) |
May
(13) |
Jun
(2) |
Jul
(2) |
Aug
(14) |
Sep
(9) |
Oct
(6) |
Nov
|
Dec
(2) |
2016 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
(12) |
Jun
|
Jul
(17) |
Aug
(7) |
Sep
(3) |
Oct
(2) |
Nov
(5) |
Dec
(28) |
2017 |
Jan
(11) |
Feb
(6) |
Mar
(10) |
Apr
(10) |
May
(34) |
Jun
(32) |
Jul
(15) |
Aug
(28) |
Sep
(8) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2018 |
Jan
(8) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(7) |
Aug
|
Sep
(1) |
Oct
|
Nov
(15) |
Dec
|
2019 |
Jan
|
Feb
(7) |
Mar
(2) |
Apr
(2) |
May
(2) |
Jun
(2) |
Jul
(48) |
Aug
(73) |
Sep
(22) |
Oct
(8) |
Nov
(16) |
Dec
(26) |
2020 |
Jan
(30) |
Feb
(13) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(12) |
Aug
(18) |
Sep
(18) |
Oct
(5) |
Nov
(9) |
Dec
(16) |
2021 |
Jan
(13) |
Feb
(17) |
Mar
(19) |
Apr
(70) |
May
(43) |
Jun
(27) |
Jul
(18) |
Aug
(15) |
Sep
(16) |
Oct
(37) |
Nov
(38) |
Dec
(11) |
2022 |
Jan
(73) |
Feb
(18) |
Mar
(36) |
Apr
(6) |
May
(8) |
Jun
(33) |
Jul
(22) |
Aug
|
Sep
(6) |
Oct
(71) |
Nov
(91) |
Dec
(26) |
2023 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(34) |
May
(29) |
Jun
(27) |
Jul
(3) |
Aug
(17) |
Sep
(11) |
Oct
(4) |
Nov
(34) |
Dec
(7) |
2024 |
Jan
(16) |
Feb
(27) |
Mar
(60) |
Apr
(57) |
May
(55) |
Jun
(50) |
Jul
(36) |
Aug
(108) |
Sep
(15) |
Oct
|
Nov
|
Dec
|
From: <mi...@us...> - 2024-09-15 11:13:45
|
Revision: 9931 http://sourceforge.net/p/docutils/code/9931 Author: milde Date: 2024-09-15 11:13:43 +0000 (Sun, 15 Sep 2024) Log Message: ----------- HTML writers: Add "px" to unitless table "width" values. The table "width" attribute is of type "length", with optional unit. The writers must ensure there is a unit when converting a length to a HTML "style" attribute rule. For HTML writers, the default length unit is "px". Modified Paths: -------------- trunk/docutils/HISTORY.rst trunk/docutils/docutils/writers/_html_base.py trunk/docutils/docutils/writers/html4css1/__init__.py trunk/docutils/docutils/writers/html5_polyglot/__init__.py trunk/docutils/test/test_writers/test_html4css1.py trunk/docutils/test/test_writers/test_html5_polyglot.py Modified: trunk/docutils/HISTORY.rst =================================================================== --- trunk/docutils/HISTORY.rst 2024-09-13 08:13:03 UTC (rev 9930) +++ trunk/docutils/HISTORY.rst 2024-09-15 11:13:43 UTC (rev 9931) @@ -147,10 +147,12 @@ - Make MathML the default math_output_. - Revise image size handling methods, use "width" and "height" attributes for unitless values. + - Add "px" to unitless table "width" values. * docutils/writers/html4css1/__init__.py - Keep default math_output_ value "HTML math.css". + - Add "px" to unitless table "width" values. * docutils/writers/latex2e/__init__.py Modified: trunk/docutils/docutils/writers/_html_base.py =================================================================== --- trunk/docutils/docutils/writers/_html_base.py 2024-09-13 08:13:03 UTC (rev 9930) +++ trunk/docutils/docutils/writers/_html_base.py 2024-09-15 11:13:43 UTC (rev 9931) @@ -1693,7 +1693,10 @@ if 'align' in node: atts['classes'].append('align-%s' % node['align']) if 'width' in node: - atts['style'] = 'width: %s;' % node['width'] + width = node['width'] + if width[-1:] in '0123456789.': # unitless value + width += 'px' # add default length unit + atts['style'] = f'width: {width};' tag = self.starttag(node, 'table', **atts) self.body.append(tag) Modified: trunk/docutils/docutils/writers/html4css1/__init__.py =================================================================== --- trunk/docutils/docutils/writers/html4css1/__init__.py 2024-09-13 08:13:03 UTC (rev 9930) +++ trunk/docutils/docutils/writers/html4css1/__init__.py 2024-09-15 11:13:43 UTC (rev 9931) @@ -866,7 +866,10 @@ if 'align' in node: classes.append('align-%s' % node['align']) if 'width' in node: - atts['style'] = 'width: %s' % node['width'] + width = node['width'] + if width[-1:] in '0123456789.': # unitless value + width += 'px' # add default length unit + atts['style'] = f'width: {width}' self.body.append( self.starttag(node, 'table', CLASS=' '.join(classes), **atts)) Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py =================================================================== --- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2024-09-13 08:13:03 UTC (rev 9930) +++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2024-09-15 11:13:43 UTC (rev 9931) @@ -200,7 +200,7 @@ # use new HTML5 <figure> and <figcaption> elements def visit_figure(self, node) -> None: atts = {} - if node.get('width'): + if 'width' in node: atts['style'] = f"width: {node['width']}" if node.get('align'): atts['class'] = f"align-{node['align']}" Modified: trunk/docutils/test/test_writers/test_html4css1.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1.py 2024-09-13 08:13:03 UTC (rev 9930) +++ trunk/docutils/test/test_writers/test_html4css1.py 2024-09-15 11:13:43 UTC (rev 9931) @@ -183,6 +183,7 @@ ["""\ .. table:: :align: right + :width: 320 +-----+-----+ | 1 | 2 | @@ -191,7 +192,7 @@ +-----+-----+ """, """\ -<table border="1" class="docutils align-right"> +<table border="1" class="docutils align-right" style="width: 320px"> <colgroup> <col width="50%" /> <col width="50%" /> Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-13 08:13:03 UTC (rev 9930) +++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-15 11:13:43 UTC (rev 9931) @@ -218,6 +218,7 @@ ["""\ .. table:: :align: right + :width: 320 +-----+-----+ | 1 | 2 | @@ -226,7 +227,7 @@ +-----+-----+ """, """\ -<table class="align-right"> +<table class="align-right" style="width: 320px;"> <tbody> <tr><td><p>1</p></td> <td><p>2</p></td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-13 08:13:06
|
Revision: 9930 http://sourceforge.net/p/docutils/code/9930 Author: milde Date: 2024-09-13 08:13:03 +0000 (Fri, 13 Sep 2024) Log Message: ----------- Use "unknown_reference_resolver" for LaTeX writer option "use-bibtex". The "latex" writer provides the (provisional) setting "use_bibtex" to defer the resolution of citation references to the backend (LaTeX/BibTeX/LaTeX). Use the `unknown_reference_resolvers` hook of the `TransformSpec` to mark citation references as resolved if BibTeX is used. Advantages: * replaces hard-coded special-case in `transforms.references.DanglingReferencesVisitor` introduced in [r9312], * provides a usage example, * tests the hook with the Docutils test suite without additional overhead. Update docstrings and comments. Modified Paths: -------------- trunk/docutils/HISTORY.rst trunk/docutils/docutils/__init__.py trunk/docutils/docutils/transforms/__init__.py trunk/docutils/docutils/transforms/references.py trunk/docutils/docutils/writers/latex2e/__init__.py Modified: trunk/docutils/HISTORY.rst =================================================================== --- trunk/docutils/HISTORY.rst 2024-09-12 12:57:48 UTC (rev 9929) +++ trunk/docutils/HISTORY.rst 2024-09-13 08:13:03 UTC (rev 9930) @@ -158,6 +158,8 @@ (ignored since at least 2012). - Don't wrap references with custom reference-label_ in a ``\hyperref`` command. + - Provide an "unknown_references_resolver" (cf. `docutils/TransformSpec`) + for citation references resolved with BibTeX (cf. `use_bibtex`_ setting). .. _reference-label: docs/user/config.html#reference-label @@ -3856,9 +3858,9 @@ * docutils/transforms/__init__.py: - Added ``Transformer`` class and completed transform reform. - - Added unknown_reference_resolvers list for each transformer. This list holds - the list of functions provided by each component of the transformer that - help resolve references. + - Added unknown_reference_resolvers list for each transformer. + This list holds the list of functions provided by each component + of the transformer that help resolve references. * docutils/transforms/frontmatter.py: Modified: trunk/docutils/docutils/__init__.py =================================================================== --- trunk/docutils/docutils/__init__.py 2024-09-12 12:57:48 UTC (rev 9929) +++ trunk/docutils/docutils/__init__.py 2024-09-13 08:13:03 UTC (rev 9930) @@ -282,8 +282,11 @@ default_transforms: ClassVar[tuple[()]] = () unknown_reference_resolvers: Sequence[_UnknownReferenceResolver] = () - """List of functions to try to resolve unknown references. + """List of hook functions which assist in resolving references. + Override in subclasses to implement component-specific resolving of + unknown references. + Unknown references have a 'refname' attribute which doesn't correspond to any target in the document. Called when the transforms in `docutils.transforms.references` are unable to find a correct target. @@ -291,7 +294,7 @@ The list should contain functions which will try to resolve unknown references, with the following signature:: - def reference_resolver(node): + def reference_resolver(node: nodes.Element) -> bool: '''Returns boolean: true if resolved, false if not.''' If the function is able to resolve the reference, it should also remove @@ -301,13 +304,20 @@ node.resolved = True Each function must have a "priority" attribute which will affect the order - the unknown_reference_resolvers are run:: + the unknown_reference_resolvers are run + cf. ../docs/api/transforms.html#transform-priority-range-categories :: - reference_resolver.priority = 100 + reference_resolver.priority = 500 - This hook is provided for 3rd party extensions. - Example use case: the `MoinMoin - ReStructured Text Parser` - https://github.com/moinwiki/moin + Examples: + `writers.latex2e.Writer` defines a resolver to mark citation references + as resolved by BibTeX if the "use_bibtex" configuration setting is set. + + The `MoinMoin ReStructured Text Parser`__ provides a resolver for + "WikiWiki links" (currently only in the outdated 1.9 version). + + __ https://github.com/moinwiki/moin-1.9/blob/1.9.11/MoinMoin/parser/ + text_rst.py """ Modified: trunk/docutils/docutils/transforms/__init__.py =================================================================== --- trunk/docutils/docutils/transforms/__init__.py 2024-09-12 12:57:48 UTC (rev 9929) +++ trunk/docutils/docutils/transforms/__init__.py 2024-09-13 08:13:03 UTC (rev 9930) @@ -144,7 +144,7 @@ def populate_from_components(self, components) -> None: """ - Store each component's default transforms and reference resolvers + Store each component's default transforms and reference resolvers. Transforms are stored with default priorities for later sorting. "Unknown reference resolvers" are sorted and stored. @@ -161,7 +161,7 @@ resolvers.extend(component.unknown_reference_resolvers) self.sorted = False # sort transform list in self.apply_transforms() - # Sort and add helper functions to help resolve unknown references. + # Sort and add hook functions helping to resolve unknown references. def keyfun(f): return f.priority resolvers.sort(key=keyfun) Modified: trunk/docutils/docutils/transforms/references.py =================================================================== --- trunk/docutils/docutils/transforms/references.py 2024-09-12 12:57:48 UTC (rev 9929) +++ trunk/docutils/docutils/transforms/references.py 2024-09-13 08:13:03 UTC (rev 9930) @@ -888,37 +888,33 @@ return refname = node['refname'] id = self.document.nameids.get(refname) - if id is None: - for resolver_function in self.unknown_reference_resolvers: - if resolver_function(node): - break - else: - if (getattr(self.document.settings, 'use_bibtex', False) - and isinstance(node, nodes.citation_reference)): - # targets added from BibTeX database by LaTeX - node.resolved = True - return - if refname in self.document.nameids: - msg = self.document.reporter.error( - 'Duplicate target name, cannot be used as a unique ' - 'reference: "%s".' % (node['refname']), base_node=node) - else: - msg = self.document.reporter.error( - f'Unknown target name: "{node["refname"]}".', - base_node=node) - msgid = self.document.set_id(msg) - prb = nodes.problematic( - node.rawsource, node.rawsource, refid=msgid) - try: - prbid = node['ids'][0] - except IndexError: - prbid = self.document.set_id(prb) - msg.add_backref(prbid) - node.replace_self(prb) - else: + if id is not None: + # target found, set refid del node['refname'] node['refid'] = id self.document.ids[id].note_referenced_by(id=id) node.resolved = True + return + # Apply component-specific resolving functions (cf. TransformSpec): + for resolver_function in self.unknown_reference_resolvers: + if resolver_function(node): + return + # Report unresolved references: + if refname in self.document.nameids: + msg = self.document.reporter.error( + 'Duplicate target name, cannot be used as a unique ' + 'reference: "%s".' % (node['refname']), base_node=node) + else: + msg = self.document.reporter.error( + f'Unknown target name: "{node["refname"]}".', + base_node=node) + msgid = self.document.set_id(msg) + prb = nodes.problematic(node.rawsource, node.rawsource, refid=msgid) + try: + prbid = node['ids'][0] + except IndexError: + prbid = self.document.set_id(prb) + msg.add_backref(prbid) + node.replace_self(prb) visit_footnote_reference = visit_citation_reference = visit_reference Modified: trunk/docutils/docutils/writers/latex2e/__init__.py =================================================================== --- trunk/docutils/docutils/writers/latex2e/__init__.py 2024-09-12 12:57:48 UTC (rev 9929) +++ trunk/docutils/docutils/writers/latex2e/__init__.py 2024-09-13 08:13:03 UTC (rev 9930) @@ -253,7 +253,23 @@ def __init__(self) -> None: writers.Writer.__init__(self) self.translator_class = LaTeXTranslator + self.unknown_reference_resolvers = [self.bibtex_reference_resolver] + self.bibtex_reference_resolver.priority = 400 + @staticmethod + def bibtex_reference_resolver(node: nodes.Element) -> bool: + """Mark citation references as resolved if BibTeX is used. + + Cf. `TransformSpec.unknown_reference_resolvers`. + """ + if (isinstance(node, nodes.citation_reference) + and node.document.settings.use_bibtex): + del node['refname'] + node.resolved = True + return True + else: + return False + def get_transforms(self): # Override parent method to add latex-specific transforms return super().get_transforms() + [ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-12 12:57:50
|
Revision: 9929 http://sourceforge.net/p/docutils/code/9929 Author: milde Date: 2024-09-12 12:57:48 +0000 (Thu, 12 Sep 2024) Log Message: ----------- Fix test_writers html4css when PIL is installed. Fixup for [r9924]. Modified Paths: -------------- trunk/docutils/test/test_writers/test_html4css1.py Modified: trunk/docutils/test/test_writers/test_html4css1.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1.py 2024-09-11 07:20:07 UTC (rev 9928) +++ trunk/docutils/test/test_writers/test_html4css1.py 2024-09-12 12:57:48 UTC (rev 9929) @@ -39,10 +39,11 @@ # Pillow/PIL is optional: if PIL: - SCALING_OUTPUT = 'style="width: 32px; height: 32px;" ' + SCALING_OUTPUT = 'style="width: 32.0px; height: 32.0px;" ' else: SCALING_OUTPUT = '' + class Html5WriterPublishPartsTestCase(unittest.TestCase): """Test case for HTML5 writer via the publish_parts() interface.""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-11 07:20:10
|
Revision: 9928 http://sourceforge.net/p/docutils/code/9928 Author: milde Date: 2024-09-11 07:20:07 +0000 (Wed, 11 Sep 2024) Log Message: ----------- HTML5: use "width" and "height" for unitless image size values. Fixes [feature-requests:#102] The HTML `<img>` element supports "width" and "height" attributes to specify the size or ratio of an image. Values are restricted to integers (size in pixels). In Docutils, "width" and "hight" attributes also support a set of CSS compatible units. Therefore, all size values were passed to HTML via the common attribute "style". Using HTML "width" and "hight" attributes for values without unit provides a means to specify an image's *aspect ratio* without overriding a size declaration in a CSS style sheet. This change is not backported to the "html4css1" writer to keep the output backwards compatible. The provisional method `HTMLTranslator.image_size()` now returns a dictionary of attribute values. Modified Paths: -------------- trunk/docutils/HISTORY.rst trunk/docutils/RELEASE-NOTES.rst trunk/docutils/docs/user/html.rst trunk/docutils/docutils/writers/_html_base.py trunk/docutils/test/functional/expected/rst_html5_tuftig.html trunk/docutils/test/functional/expected/standalone_rst_html5.html trunk/docutils/test/test_writers/test_html5_polyglot.py trunk/docutils/test/test_writers/test_html5_polyglot_misc.py Modified: trunk/docutils/HISTORY.rst =================================================================== --- trunk/docutils/HISTORY.rst 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/HISTORY.rst 2024-09-11 07:20:07 UTC (rev 9928) @@ -145,6 +145,8 @@ * docutils/writers/_html_base.py - Make MathML the default math_output_. + - Revise image size handling methods, + use "width" and "height" attributes for unitless values. * docutils/writers/html4css1/__init__.py Modified: trunk/docutils/RELEASE-NOTES.rst =================================================================== --- trunk/docutils/RELEASE-NOTES.rst 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/RELEASE-NOTES.rst 2024-09-11 07:20:07 UTC (rev 9928) @@ -85,20 +85,6 @@ __ https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html #the-blockquote-element - - Unitless image_ :width: and :hight: values and dimensions - read from the image due to a :scale: option will be written as - "width" and "hight" attributes instead of "style" rules to allow - specification of the aspect ratio to `prevent jank when loading - images`__ without overwriting an image size set in a CSS stylesheet - in Docutils 0.22 (cf. `feature-requests:102`__). - The current behaviour is kept for dimensions with units, so - users may specify, e.g. ``:width: 50px`` instead of ``:width: 50`` - to override CSS stylesheet rules. - - __ https://developer.mozilla.org/en-US/docs/Learn/Performance/Multimedia - #rendering_strategy_preventing_jank_when_loading_images - __ https://sourceforge.net/p/docutils/feature-requests/102/ - - Change the default value of the initial_header_level_ setting to None (<h2> if there is a document title, else <h1>) in Docutils 1.0. @@ -202,22 +188,30 @@ (See `command line interface`_ for the rationale.) Output changes - "manpage" writer: + LaTeX: + Don't wrap references with custom reference-label_ in a ``\hyperref`` + command. The "hyperref" package generates hyperlinks for labels by + default, so there is no change in the PDF (except for "ref*"). + + .. _reference-label: docs/user/config.html#reference-label + + HTML5: + Unitless image_ size measures__ are written as <img> "width" and + "hight" values instead of "style" rules. The current behaviour + is kept for values with units, so users may specify, e.g. ``:width: + 50px`` instead of ``:width: 50`` to override CSS stylesheet rules. + + __ docs/ref/doctree.html#measure + + manpage: Don't UPPERCASE section headings. - "null" writer: - output changed from None to the empty string. + null: + The "null" writer output changed from None to the empty string. `publish_string()` now returns a `bytes` or `str` instance for all writers (as documented). - "latex" writer: - Don't wrap references with custom reference-label_ in a ``\hyperref`` - command. The "hyperref" package generates hyperlinks for labels by - default, so there is no change in the PDF (except for "ref*"). - - .. _reference-label: docs/user/config.html#reference-label - New objects `parsers.docutils_xml` parser for `Docutils XML`_ (e.g., the output of the "xml" writer). Modified: trunk/docutils/docs/user/html.rst =================================================================== --- trunk/docutils/docs/user/html.rst 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/docs/user/html.rst 2024-09-11 07:20:07 UTC (rev 9928) @@ -52,6 +52,13 @@ better legibility. Adaption of the layout is possible with `custom style sheets`_. [#safetext]_ +Image_ size values with unit are converted to "style" rules, +values without unit are rounded to the nearest integer and +written as "width" and "height" attributes instead. +This allows the specification of the image's aspect ratio +(to `prevent jank when loading images`__) without overwriting +size declarations in a CSS stylesheet. + .. [#safetext] The validity of raw HTML and custom stylesheets must be ensured by the author. @@ -69,6 +76,9 @@ .. _custom style sheets: ../howto/html-stylesheets.html .. _viewable with any browser: http://www.anybrowser.org/campaign .. _Benefits of polyglot XHTML5: http://xmlplease.com/xhtml/xhtml5polyglot/ +.. _image: ../ref/rst/directives.html#image +__ https://developer.mozilla.org/en-US/docs/Learn/Performance/Multimedia + #rendering_strategy_preventing_jank_when_loading_images html4css1 Modified: trunk/docutils/docutils/writers/_html_base.py =================================================================== --- trunk/docutils/docutils/writers/_html_base.py 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/docutils/writers/_html_base.py 2024-09-11 07:20:07 UTC (rev 9928) @@ -413,7 +413,7 @@ text = str(text) return text.translate(self.special_characters) - def image_size(self, node: nodes.image) -> str: + def image_size(self, node: nodes.image) -> dict[str, str]: """Determine the image size from node arguments or the image file. Auxiliary method called from `self.visit_image()`. @@ -420,9 +420,6 @@ Provisional. """ - # TODO: Use "width" and "hight" for unitless integers? - # [feature-requests:#102] - # List with optional width and height measures ((value, unit)-tuples) measures: list[tuple[Real, str] | None] = [None, None] dimensions = ('width', 'height') @@ -440,10 +437,22 @@ if factor != 1: measures = [(measure[0] * factor, measure[1]) for measure in measures if measure] - # format as CSS declarations and return - return ' '.join(f'{dimension}: {measure[0]:g}{measure[1] or "px"};' - for dimension, measure in zip(dimensions, measures) - if measure) + # format as <img> attributes, + # use "width" and "hight" for unitless values and "style" else, + # e.g., height': '32' 'style': 'width: 4 em;'}``: + size_atts = {} # attributes "width", "height", or "style" + declarations = [] # declarations for the "style" attribute + for dimension, measure in zip(dimensions, measures): + if measure is None: + continue + value, unit = measure + if unit: + declarations.append(f'{dimension}: {value:g}{unit};') + else: + size_atts[dimension] = f'{round(value)}' + if declarations: + size_atts['style'] = ' '.join(declarations) + return size_atts def read_size_with_PIL(self, node) -> tuple[int, int] | None: # Try reading size from image file. @@ -501,6 +510,9 @@ style_att = dict((k.strip(), v.strip()) for k, p, v in style_att) style_att = ' '.join(f'{k}: {v};' for k, v in style_att.items()) svg.set('style', style_att) + for dimension in ('width', 'height'): + if dimension in atts: + svg.set(dimension, atts[dimension]) if 'classes' in atts or node['classes']: classes = svg.get('class', '').split() classes += node['classes'] + atts.get('classes', []) @@ -1169,10 +1181,9 @@ alt = node.get('alt', uri) mimetype = mimetypes.guess_type(uri)[0] element = '' # the HTML element (including potential children) - atts = {} # attributes for the HTML tag - size_declaration = self.image_size(node) - if size_declaration: - atts['style'] = size_declaration + # attributes for the HTML tag: + atts = self.image_size(node) + # alignment is handled by CSS rules if 'align' in node: atts['classes'] = [f"align-{node['align']}"] # ``:loading:`` option (embed, link, lazy), default from setting, Modified: trunk/docutils/test/functional/expected/rst_html5_tuftig.html =================================================================== --- trunk/docutils/test/functional/expected/rst_html5_tuftig.html 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/test/functional/expected/rst_html5_tuftig.html 2024-09-11 07:20:07 UTC (rev 9928) @@ -137,7 +137,7 @@ </section> </main> <footer> -<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p> +<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" height="31" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" width="88" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" height="31" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" width="88" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" height="31" src="http://jigsaw.w3.org/css-validator/images/vcss" width="88" /></a></p> </footer> </body> </html> Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2024-09-11 07:20:07 UTC (rev 9928) @@ -614,7 +614,7 @@ media, figures might float to a different position if this helps the page layout.</p> <figure class="figclass1 figclass2"> -<img alt="reStructuredText, the markup syntax" class="class1 class2" src="../../../docs/user/rst/images/title.png" style="width: 258px;" /> +<img alt="reStructuredText, the markup syntax" class="class1 class2" src="../../../docs/user/rst/images/title.png" width="258" /> <figcaption> <p>Plaintext markup syntax and parser system.</p> <div class="legend"> @@ -1302,7 +1302,7 @@ <li><img alt="blue square" class="align-right" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAALElEQVR4nO3NMQEAMAjAsDFjvIhHFCbgSwU0kdXvsn96BwAAAAAAAAAAAIsNnEwBk52VRuMAAAAASUVORK5CYII=" /> <p>Embed images or defer fetching images with the <a class="reference external" href="https://docutils.sourceforge.io/docs/user/config.html#image-loading">image-loading</a> <a class="brackets" href="#footnote-9" id="footnote-reference-22" role="doc-noteref"><span class="fn-bracket">[</span>9<span class="fn-bracket">]</span></a> configuration setting or the "loading" option of the "image" directive.</p> -<img alt="../../../docs/user/rst/images/biohazard.png" class="align-right" loading="lazy" src="../../../docs/user/rst/images/biohazard.png" style="width: 16px; height: 16px;" /> +<img alt="../../../docs/user/rst/images/biohazard.png" class="align-right" height="16" loading="lazy" src="../../../docs/user/rst/images/biohazard.png" width="16" /> <p>Especially with "lazy" loading, it is strongly recommended to specify both width and height of the image to prevent content layout shifts or use the "scale" option to let the writer insert the size @@ -1930,7 +1930,7 @@ </main> <footer> <p>Document footer</p> -<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p> +<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" height="31" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" width="88" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" height="31" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" width="88" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" height="31" src="http://jigsaw.w3.org/css-validator/images/vcss" width="88" /></a></p> </footer> </body> </html> Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-11 07:20:07 UTC (rev 9928) @@ -47,13 +47,15 @@ if (tuple(int(i) for i in PIL.__version__.split('.')) >= (10, 3)): DUMMY_PNG_NOT_FOUND = ("[Errno 2] No such file or directory: '%s'" % Path('dummy.png').resolve()) - SCALING_OUTPUT = 'style="width: 32px; height: 32px;" ' + HEIGHT_ATTR = 'height="32" ' + WIDTH_ATTR = 'width="32" ' NO_PIL_SYSTEM_MESSAGE = '' else: REQUIRES_PIL = '\n Requires Python Imaging Library.' ONLY_LOCAL = 'Requires Python Imaging Library.' DUMMY_PNG_NOT_FOUND = 'Requires Python Imaging Library.' - SCALING_OUTPUT = '' + HEIGHT_ATTR = '' + WIDTH_ATTR = '' NO_PIL_SYSTEM_MESSAGE = ( '<aside class="system-message">\n' '<p class="system-message-title">System Message:' @@ -156,7 +158,7 @@ :align: left """, """\ -<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" style="width: 50%; height: 30px;" class="align-left"> +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" style="width: 50%;" height="30" class="align-left"> <circle cx="5" cy="5" r="4" fill="lightblue" /> </svg> """], @@ -451,11 +453,11 @@ :scale: 100% .. figure:: /data/blue%20square.png """, -'<img alt="/data/blue%20square.png" src="data:image/png;base64,' +f'<img alt="/data/blue%20square.png" {HEIGHT_ATTR}src="data:image/png;base64,' 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAALElEQVR4nO3NMQ' 'EAMAjAsDFjvIhHFCbgSwU0kdXvsn96BwAAAAAAAAAAAIsNnEwBk52VRuMAAAAA' 'SUVORK5CYII="' -f' {SCALING_OUTPUT}/>\n{NO_PIL_SYSTEM_MESSAGE}' +f' {WIDTH_ATTR}/>\n{NO_PIL_SYSTEM_MESSAGE}' '<figure>\n' '<img alt="/data/blue%20square.png" src="data:image/png;base64,' 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAALElEQVR4nO3NMQ' Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-09-11 07:19:52 UTC (rev 9927) +++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-09-11 07:20:07 UTC (rev 9928) @@ -243,7 +243,7 @@ class ImagesTestCase(unittest.TestCase): """Test image handling routines.""" - + maxDiff = None settings = frontend.get_default_settings(_html_base.Writer) document = utils.new_document('test data', settings) translator = _html_base.HTMLTranslator(document) @@ -250,24 +250,28 @@ svg_sample = """\ <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" - style="background: blue; width: 5ex" viewBox="0 0 10 10"> + style="background: blue; width: 5ex; height: 3ex" viewBox="0 0 10 10"> <circle cx="5" cy="5" r="4" fill="lightblue" /> <!-- comments are ignored --> </svg> """ expected = """\ -<svg xmlns="http://www.w3.org/2000/svg" style="background: blue; width: 4em; height: 32px;" viewBox="0 0 10 10" class="test me"> +<svg xmlns="http://www.w3.org/2000/svg" style="background: blue; width: 4em; height: 3ex;" viewBox="0 0 10 10" height="32" class="test me"> <title>blue circle</title><circle cx="5" cy="5" r="4" fill="lightblue" /> \n\ </svg>""" def test_image_size(self): - image = nodes.image(height='3', width='4em') + # HTML attributes "width" and "height" take only integer values: + # -> height value is passed as "height" attribute, + # value with unit is passed via "style". + image = nodes.image(width='4em', height='3', scale=200) self.assertEqual(self.translator.image_size(image), - 'width: 4em; height: 3px;') - image = nodes.image(height='3', width='4em', scale=50) + {'height': '6', 'style': 'width: 8em;'}) + # "style" declaration also used for unitless non-interger value + image = nodes.image(width='4em', height='3', scale=50) self.assertEqual(self.translator.image_size(image), - 'width: 2em; height: 1.5px;') + {'style': 'width: 2em;', 'height': '2'}) def test_prepare_svg(self): # Internal method: the test is no guaranty for stability, @@ -274,7 +278,7 @@ # interface and behaviour may change without notice. image = nodes.image(height='32', width='4em', alt='blue circle', align='left', classes=['test', 'me']) - atts = {'style': self.translator.image_size(image)} + atts = self.translator.image_size(image) rv = self.translator.prepare_svg(self.svg_sample, image, atts) self.assertEqual(rv, self.expected) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-11 07:19:56
|
Revision: 9927 http://sourceforge.net/p/docutils/code/9927 Author: milde Date: 2024-09-11 07:19:52 +0000 (Wed, 11 Sep 2024) Log Message: ----------- Fix test samples containing installation-specific path. Use a relative path in the tests for external MathML converters to make tests independent of the installation-specific Docutils project root directory. Modified Paths: -------------- trunk/docutils/test/functional/expected/math_experiments_mathml_blahtexml.html trunk/docutils/test/functional/expected/math_experiments_mathml_pandoc.html trunk/docutils/test/functional/expected/math_experiments_mathml_ttm.html trunk/docutils/test/functional/expected/mathematics_mathml.html trunk/docutils/test/functional/expected/mathematics_mathml_blahtexml.html trunk/docutils/test/functional/expected/mathematics_mathml_pandoc.html trunk/docutils/test/functional/expected/mathematics_mathml_ttm.html trunk/docutils/test/test_utils/test_math/test_tex2mathml_extern.py Modified: trunk/docutils/test/functional/expected/math_experiments_mathml_blahtexml.html =================================================================== --- trunk/docutils/test/functional/expected/math_experiments_mathml_blahtexml.html 2024-09-11 07:19:41 UTC (rev 9926) +++ trunk/docutils/test/functional/expected/math_experiments_mathml_blahtexml.html 2024-09-11 07:19:52 UTC (rev 9927) @@ -126,7 +126,7 @@ <dd><p><span class="math problematic">\mathbfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 21)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 21)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathbfit"</p> </aside> @@ -135,7 +135,7 @@ <dd><p><span class="math problematic">\mathbb{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 23)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 23)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The symbol "x" is not available in the font "bb"</p> </aside> @@ -144,7 +144,7 @@ <dd><p><span class="math problematic">\mathcal{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 25)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 25)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The symbol "x" is not available in the font "cal"</p> </aside> @@ -153,7 +153,7 @@ <dd><p><span class="math problematic">\mathscr{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 27)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 27)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathscr"</p> </aside> @@ -162,7 +162,7 @@ <dd><p><span class="math problematic">\mathfrak{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 29)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 29)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The symbol "\Gamma" is not available in the font "frak"</p> </aside> @@ -197,7 +197,7 @@ <dd><p><span class="math problematic">\mathsfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 33)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 33)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathsfit"</p> </aside> @@ -206,7 +206,7 @@ <dd><p><span class="math problematic">\mathsfbfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 35)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 35)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathsfbfit"</p> </aside> @@ -215,7 +215,7 @@ <dd><p><span class="math problematic">\mathbfsfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 37)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 37)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathbfsfit"</p> </aside> @@ -314,13 +314,13 @@ \quad\mbox{as $n\to\infty$,} </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 69)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 69)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\coloneq"</p> </aside> <p>or, equivalently, letting <span class="math problematic">S_n\coloneq\sum_1^n X_k</span>,</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 75)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 75)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\coloneq"</p> </aside> @@ -332,7 +332,7 @@ for every $f\in\mathrm{b} \mathcal{C}(\mathbb{R})$.} </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 77)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 77)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The command "$" is illegal in text mode (perhaps you intended to use "\$" instead?)</p> </aside> @@ -567,7 +567,7 @@ \left( \intop_0^1 \right) </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 127)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 127)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\intop"</p> </aside> @@ -1026,7 +1026,7 @@ \left./ b \right\backslash \ \bigl/ b \Bigr\backslash \ \biggl/ b \Biggr\backslash </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 199)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 199)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\lgroup"</p> </aside> @@ -1097,7 +1097,7 @@ \left.\bracevert b \right\bracevert \ \bigl\bracevert b \Bigr\bracevert \ \biggl\bracevert b \Biggr\bracevert </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 224)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 224)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\arrowvert"</p> </aside> @@ -1106,7 +1106,7 @@ \sum\ \prod\ \coprod\ \bigwedge\ \bigvee\ \bigcap\ \bigcup\ \biguplus\ \bigsqcup\ \bigodot\ \bigoplus\ \bigotimes</span> and Display:</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 241)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 241)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\idotsint"</p> </aside> @@ -1116,7 +1116,7 @@ \biguplus\ \bigsqcup\ \bigodot\ \bigoplus\ \bigotimes </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 245)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 245)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\idotsint"</p> </aside> @@ -1127,7 +1127,7 @@ \bigvee^N\ \bigcup^N\ \bigsqcup^N\ \bigotimes^N </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 249)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 249)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\intop"</p> </aside> @@ -1139,7 +1139,7 @@ \bigotimes_1^N </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 254)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 254)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\intop"</p> </aside> @@ -1159,7 +1159,7 @@ to get the result of the accent macros <span class="math problematic">\text{\c{c} \'e \`e \"e \^e \~n \r{u} \v{z} \textcircled{c}}</span>.</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 266)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 266)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\c"</p> </aside> Modified: trunk/docutils/test/functional/expected/math_experiments_mathml_pandoc.html =================================================================== --- trunk/docutils/test/functional/expected/math_experiments_mathml_pandoc.html 2024-09-11 07:19:41 UTC (rev 9926) +++ trunk/docutils/test/functional/expected/math_experiments_mathml_pandoc.html 2024-09-11 07:19:52 UTC (rev 9927) @@ -66,7 +66,7 @@ <dd><p><span class="math problematic">\mathsfbfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 35)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 35)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\mathsfbfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma</p> <pre class="literal-block"> \quad \forall x \in \mathbb{R}}', rendering as TeX: @@ -139,7 +139,7 @@ c = \sqrt\frac{\sin(x)}{23}, </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 91)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 91)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math 'a = \sqrt 2 + x,\quad</p> <pre class="literal-block"> b = \sqrt{1+x^2},\quad @@ -151,7 +151,7 @@ </aside> <p>inline: <span class="math problematic">a = \sqrt 2 + x, b = \sqrt{1+x^2}, c = \sqrt\frac{\sin(x)}{23}</span>.</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 95)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 95)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math 'a = \sqrt 2 + x, b = \sqrt{1+x^2}, c = \sqrt\frac{\sin(x)}{23}', rendering as TeX:</p> <pre class="literal-block"> ^2}, c = \sqrt\frac{\sin(x)}{23} @@ -214,7 +214,7 @@ \left( \intop_0^1 \right) </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 127)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 127)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\begin{aligned}</p> <pre class="literal-block"> \left( 3 \right) @@ -285,7 +285,7 @@ \left( \sum_0^1 \right) \left( \frac{\frac1x}{\frac{1}{n}}\right)</annotation></semantics></math></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 177)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 177)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\Bigl(\text{Big}\Bigr)', rendering as TeX:</p> <pre class="literal-block"> \Bigl(\text{Big}\Bigr) @@ -324,7 +324,7 @@ \left./ b \right\backslash \ \bigl/ b \Bigr\backslash \ \biggl/ b \Biggr\backslash </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 199)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 199)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\left.\lgroup b \right\rgroup \ \bigl\lgroup b \Bigr\rgroup \ \biggl\lgroup b \Biggr\rgroup</p> <pre class="literal-block"> \quad @@ -354,7 +354,7 @@ \left.\bracevert b \right\bracevert \ \bigl\bracevert b \Bigr\bracevert \ \biggl\bracevert b \Biggr\bracevert </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 224)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 224)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\left.\arrowvert b \right\arrowvert \ \bigl\arrowvert b \Bigr\arrowvert \ \biggl\arrowvert b \Biggr\arrowvert</p> <pre class="literal-block"> \quad @@ -371,7 +371,7 @@ \sum\ \prod\ \coprod\ \bigwedge\ \bigvee\ \bigcap\ \bigcup\ \biguplus\ \bigsqcup\ \bigodot\ \bigoplus\ \bigotimes</span> and Display:</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 241)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 241)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\int\ \iint\ \iiint\ \iiiint\ \idotsint \oint\ \smallint\</p> <pre class="literal-block"> \sum\ \prod\ \coprod\ \bigwedge\ \bigvee\ \bigcap\ \bigcup\ \biguplus\ @@ -387,7 +387,7 @@ \biguplus\ \bigsqcup\ \bigodot\ \bigoplus\ \bigotimes </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 245)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 245)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\int\ \iint\ \iiint\ \iiiint\ \idotsint\ \oint\ \smallint\</p> <pre class="literal-block"> \sum\ \prod\ \coprod\ \bigwedge\ \bigvee\ \bigcap\ \bigcup\ @@ -404,7 +404,7 @@ \bigvee^N\ \bigcup^N\ \bigsqcup^N\ \bigotimes^N </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 249)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 249)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\int_1 f\ \intop_1 f\ \iint_1 f\ \smallint_1 f\ \sum_1\</p> <pre class="literal-block"> \prod_1\ \bigwedge_1\ \bigcap_1\ \biguplus_1\ \bigodot_1\ \int^N\ @@ -423,7 +423,7 @@ \bigotimes_1^N </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 254)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 254)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\int_1^N\ \intop_1^N\ \iint_1^N\ \iiint_1^N\ \iiiint_1^N\</p> <pre class="literal-block"> \idotsint_1^N\ \oint_1^N\ \smallint_1^N\ \sum_1^N\ \prod_1^N\ @@ -444,7 +444,7 @@ to get the result of the accent macros <span class="math problematic">\text{\c{c} \'e \`e \"e \^e \~n \r{u} \v{z} \textcircled{c}}</span>.</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 266)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 266)</p> <p>TeX to MathML converter `pandoc` failed:</p> <p>[WARNING] Could not convert TeX math '\text{\c{c} \'e \`e \"e \^e \~n \r{u} \v{z} \textcircled{c}}', rendering as TeX:</p> <pre class="literal-block"> 'e \`e \"e \^e \~n \r{u} \v{z} \textcirc Modified: trunk/docutils/test/functional/expected/math_experiments_mathml_ttm.html =================================================================== --- trunk/docutils/test/functional/expected/math_experiments_mathml_ttm.html 2024-09-11 07:19:41 UTC (rev 9926) +++ trunk/docutils/test/functional/expected/math_experiments_mathml_ttm.html 2024-09-11 07:19:52 UTC (rev 9927) @@ -22,7 +22,7 @@ <dd><p><span class="math problematic">V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 13)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 13)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -31,7 +31,7 @@ <dd><p><span class="math problematic">\mathrm{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 15)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 15)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -40,7 +40,7 @@ <dd><p><span class="math problematic">\mathbf{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 17)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 17)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -49,7 +49,7 @@ <dd><p><span class="math problematic">\mathit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 19)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 19)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -58,7 +58,7 @@ <dd><p><span class="math problematic">\mathbfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 21)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 21)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbfit in equation, Line 1. Unknown command \mathbb in equation, Line 1.</p> @@ -68,7 +68,7 @@ <dd><p><span class="math problematic">\mathbb{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 23)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 23)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1. Unknown command \mathbb in equation, Line 1.</p> @@ -78,7 +78,7 @@ <dd><p><span class="math problematic">\mathcal{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 25)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 25)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -87,7 +87,7 @@ <dd><p><span class="math problematic">\mathscr{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 27)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 27)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathscr in equation, Line 1. Unknown command \mathbb in equation, Line 1.</p> @@ -97,7 +97,7 @@ <dd><p><span class="math problematic">\mathfrak{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 29)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 29)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathfrak in equation, Line 1. Unknown command \mathbb in equation, Line 1.</p> @@ -107,7 +107,7 @@ <dd><p><span class="math problematic">\mathsf{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 31)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 31)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -116,7 +116,7 @@ <dd><p><span class="math problematic">\mathsfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 33)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 33)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathsfit in equation, Line 1. Unknown command \mathbb in equation, Line 1.</p> @@ -126,7 +126,7 @@ <dd><p><span class="math problematic">\mathsfbfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 35)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 35)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathsfbfit in equation, Line 1. Unknown command \mathbb in equation, Line 1.</p> @@ -136,7 +136,7 @@ <dd><p><span class="math problematic">\mathbfsfit{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 37)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 37)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbfsfit in equation, Line 1. Unknown command \mathbb in equation, Line 1.</p> @@ -146,7 +146,7 @@ <dd><p><span class="math problematic">\mathtt{V_R x \pm \cos(\alpha_\text{out}) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 39)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 39)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -165,7 +165,7 @@ <dt>bold-fraktur<span class="colon">:</span></dt> <dd><p><span class="math problematic">\boldsymbol{\mathfrak{V_R x}}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 54)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 54)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathfrak in equation, Line 1.</p> </aside> @@ -190,7 +190,7 @@ <mrow><mn>1</mn></mrow></math> on a probability space <span class="math problematic">(\Omega,\mathcal{F},\mathbb{P})</span>. Then</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 65)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 65)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1.</p> </aside> @@ -202,7 +202,7 @@ \quad\mbox{as $n\to\infty$,} </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 69)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 69)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1. Unknown command \mathfrak in equation, Line 1. @@ -210,7 +210,7 @@ </aside> <p>or, equivalently, letting <span class="math problematic">S_n\coloneq\sum_1^n X_k</span>,</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 75)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 75)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \coloneq in equation, Line 1.</p> </aside> @@ -222,7 +222,7 @@ for every $f\in\mathrm{b} \mathcal{C}(\mathbb{R})$.} </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 77)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 77)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \mathbb in equation, Line 1. Unknown command \mathbb in equation, Line 4.</p> @@ -377,7 +377,7 @@ \left( \intop_0^1 \right) </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 127)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 127)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown or ignored environment: \begin{align*} Line 1. Unknown command \left, (0 user-defined) Line 2. @@ -431,7 +431,7 @@ c & d \end{smallmatrix} \right) \left( \bigotimes \right)</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 170)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 170)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \binom in equation, Line 1. Unknown or ignored environment: \begin{smallmatrix} Line 1. @@ -511,7 +511,7 @@ \left.\lVert b \right\rVert \ \bigl\lVert b \Bigr\rVert \ \biggl\lVert b \Biggr\rVert </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 199)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 199)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \lvert in equation, Line 1. Unknown command \rvert in equation, Line 1. @@ -534,7 +534,7 @@ \left./ b \right\backslash \ \bigl/ b \Bigr\backslash \ \biggl/ b \Biggr\backslash </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 199)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 199)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \lgroup in equation, Line 1. Unknown command \rgroup in equation, Line 1. @@ -563,7 +563,7 @@ \left.\bracevert b \right\bracevert \ \bigl\bracevert b \Bigr\bracevert \ \biggl\bracevert b \Biggr\bracevert </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 224)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 224)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \arrowvert in equation, Line 1. Unknown command \arrowvert in equation, Line 1. @@ -589,7 +589,7 @@ \sum\ \prod\ \coprod\ \bigwedge\ \bigvee\ \bigcap\ \bigcup\ \biguplus\ \bigsqcup\ \bigodot\ \bigoplus\ \bigotimes</span> and Display:</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 241)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 241)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \iiiint in equation, Line 1. Unknown command \idotsint in equation, Line 1. @@ -601,7 +601,7 @@ \biguplus\ \bigsqcup\ \bigodot\ \bigoplus\ \bigotimes </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 245)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 245)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \iiiint in equation, Line 1. Unknown command \idotsint in equation, Line 1. @@ -614,7 +614,7 @@ \bigvee^N\ \bigcup^N\ \bigsqcup^N\ \bigotimes^N </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 249)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 249)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \intop in equation, Line 1. Unknown command \smallint in equation, Line 1. @@ -630,7 +630,7 @@ \bigotimes_1^N </pre> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 254)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 254)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \intop in equation, Line 1. Unknown command \iiiint in equation, Line 1. @@ -649,11 +649,11 @@ to get the result of the accent macros <span class="math problematic">\text{\c{c} \'e \`e \"e \^e \~n \r{u} \v{z} \textcircled{c}}</span>.</p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 266)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 266)</p> <p>'latin-1' codec can't encode character '\u016f' in position 19: ordinal not in range(256)</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/test/functional/input/data/math_experiments.rst</span>, line 266)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../functional/input/data/math_experiments.rst</span>, line 266)</p> <p>TeX to MathML converter `ttm` failed:</p> <p class="pre-wrap">Unknown command \r, (0 user-defined) Line 1. Unknown command \textcircled, (0 user-defined) Line 1.</p> Modified: trunk/docutils/test/functional/expected/mathematics_mathml.html =================================================================== --- trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-09-11 07:19:41 UTC (rev 9926) +++ trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-09-11 07:19:52 UTC (rev 9927) @@ -26,7 +26,7 @@ Attention: this is not a standalone document. --> <nav class="contents" id="contents" role="doc-toc"> -<p class="topic-title">Contents</p> +<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p> <ul class="auto-toc simple"> <li><p><a class="reference internal" href="#inline-formulas-and-displayed-equations" id="toc-entry-1"><span class="sectnum">1 </span>Inline formulas and displayed equations</a></p></li> <li><p><a class="reference internal" href="#mathematical-symbols" id="toc-entry-2"><span class="sectnum">2 </span>Mathematical symbols</a></p> Modified: trunk/docutils/test/functional/expected/mathematics_mathml_blahtexml.html =================================================================== --- trunk/docutils/test/functional/expected/mathematics_mathml_blahtexml.html 2024-09-11 07:19:41 UTC (rev 9926) +++ trunk/docutils/test/functional/expected/mathematics_mathml_blahtexml.html 2024-09-11 07:19:52 UTC (rev 9927) @@ -26,7 +26,7 @@ Attention: this is not a standalone document. --> <nav class="contents" id="contents" role="doc-toc"> -<p class="topic-title">Contents</p> +<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p> <ul class="auto-toc simple"> <li><p><a class="reference internal" href="#inline-formulas-and-displayed-equations" id="toc-entry-1"><span class="sectnum">1 </span>Inline formulas and displayed equations</a></p></li> <li><p><a class="reference internal" href="#mathematical-symbols" id="toc-entry-2"><span class="sectnum">2 </span>Mathematical symbols</a></p> @@ -457,17 +457,17 @@ </tbody> </table> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 150)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 150)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\dddot"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 150)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 150)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathring"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 151)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 151)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\ddddot"</p> </aside> @@ -600,17 +600,17 @@ </tbody> </table> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 165)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 165)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\underleftarrow"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 166)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 166)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\underrightarrow"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 167)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 167)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\underleftrightarrow"</p> </aside> @@ -1054,12 +1054,12 @@ </tbody> </table> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 224)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 224)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\lgroup"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 225)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 225)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\lmoustache"</p> </aside> @@ -1104,17 +1104,17 @@ </tbody> </table> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 234)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 234)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\arrowvert"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 235)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 235)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\Arrowvert"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 236)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 236)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\bracevert"</p> </aside> @@ -1593,7 +1593,7 @@ <span class="math problematic m">\varGamma\ \varDelta\ \varLambda\ \varPhi\ \varPi\ \varPsi\ \varSigma\ \varTheta\ \varUpsilon\ \varXi\ \varOmega</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 315)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 315)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\varGamma"</p> </aside> @@ -1825,7 +1825,7 @@ <p>The listing below shows the characters supported by Unicode and Docutils with <a class="reference external" href="https://docutils.sourceforge.io/docs/user/config.html#math-output">math_output</a> MathML. <a class="brackets" href="#italic-digits" id="footnote-reference-3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 371)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 371)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathbfit"</p> </aside> @@ -1896,7 +1896,7 @@ <mn>0123456789</mn> </math></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 382)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 382)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Non-ASCII characters may only be used in text mode (try enclosing the problem characters in "\text{...}")</p> </aside> @@ -1917,7 +1917,7 @@ <mn>0123456789</mn> </math></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 386)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 386)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Non-ASCII characters may only be used in text mode (try enclosing the problem characters in "\text{...}")</p> </aside> @@ -1985,7 +1985,7 @@ <mn mathvariant="bold">0123456789</mn> </math></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 390)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 390)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Non-ASCII characters may only be used in text mode (try enclosing the problem characters in "\text{...}")</p> </aside> @@ -2109,12 +2109,12 @@ <dd><p><span class="math problematic m">\mathbfit{ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz}</span> <span class="math problematic m">\mathbfit{ΓΔΘΛΞΠΣΥΦΨΩ\ αβγδεζηθικλμνξπρςστυφχψω\ ϵϑϕϰϱϖ\ \partial∇}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 398)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 398)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathbfit"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 398)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 398)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathbfit"</p> </aside> @@ -2122,7 +2122,7 @@ <dt>mathcal:</dt> <dd><p><span class="math problematic m">\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 401)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 401)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The symbol "a" is not available in the font "cal"</p> </aside> @@ -2130,7 +2130,7 @@ <dt>mathscr:</dt> <dd><p><span class="math problematic m">\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 403)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 403)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathscr"</p> </aside> @@ -2140,17 +2140,17 @@ <span class="math problematic m">\mathbb{ΓΠΣ\ γπ}</span> <span class="math problematic m">\mathbb{0123456789}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 405)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 405)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The symbol "a" is not available in the font "bb"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 405)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 405)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The symbol "\Gamma" is not available in the font "bb"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 405)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 405)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">The symbol "0" is not available in the font "bb"</p> </aside> @@ -2279,7 +2279,7 @@ <dt>mathsfit:</dt> <dd><p><span class="math problematic m">\mathsfit{ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 414)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 414)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathsfit"</p> </aside> @@ -2288,12 +2288,12 @@ <dd><p><span class="math problematic m">\mathsfbfit{ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz}</span> <span class="math problematic m">\mathsfbfit{ΓΔΘΛΞΠΣΥΦΨΩ\ αβγδεζηθικλμνξπρςστυφχψω\ ϵϑϕϰϱϖ\ \partial∇}</span></p> <aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">/usr/local/src/docutils-git-svn/docutils/docs/ref/rst/mathematics.rst</span>, line 416)</p> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">../../../docs/ref/rst/mathematics.rst</span>, line 416)</p> <p>TeX to MathML converter `blahtexml` failed:</p> <p class="pre-wrap">Unrecognised command "\mathsfbfit"</p> </aside> <aside class="system-message"> -<p class="system-message-title">System Message: WAR... [truncated message content] |
From: <mi...@us...> - 2024-09-11 07:19:43
|
Revision: 9926 http://sourceforge.net/p/docutils/code/9926 Author: milde Date: 2024-09-11 07:19:41 +0000 (Wed, 11 Sep 2024) Log Message: ----------- Fixes for "scale" attribute handling in ODT and LaTeX writer. Remove redundant code in the ODT writer: Scale is validated as "non-negative integer" by the parser. No need to validate again. Use the "generic" numeral format instead of "float" in the LaTeX writer (%f -> %g). Modified Paths: -------------- trunk/docutils/docutils/writers/latex2e/__init__.py trunk/docutils/docutils/writers/odf_odt/__init__.py Modified: trunk/docutils/docutils/writers/latex2e/__init__.py =================================================================== --- trunk/docutils/docutils/writers/latex2e/__init__.py 2024-09-10 18:25:17 UTC (rev 9925) +++ trunk/docutils/docutils/writers/latex2e/__init__.py 2024-09-11 07:19:41 UTC (rev 9926) @@ -2435,7 +2435,7 @@ 'height=%s' % self.to_latex_length(attrs['height'])) if 'scale' in attrs: include_graphics_options.append( - 'scale=%f' % (attrs['scale'] / 100.0)) + 'scale=%g' % (attrs['scale'] / 100.0)) if 'width' in attrs: include_graphics_options.append( 'width=%s' % self.to_latex_length(attrs['width'])) Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py =================================================================== --- trunk/docutils/docutils/writers/odf_odt/__init__.py 2024-09-10 18:25:17 UTC (rev 9925) +++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2024-09-11 07:19:41 UTC (rev 9926) @@ -2236,14 +2236,8 @@ def get_image_scale(self, node): if 'scale' in node.attributes: scale = node.attributes['scale'] - try: - scale = int(scale) - except ValueError: + if scale < 1: self.document.reporter.warning( - 'Invalid scale for image: "%s"' % ( - node.attributes['scale'], )) - if scale < 1: # or scale > 100: - self.document.reporter.warning( 'scale out of range (%s), using 1.' % (scale, )) scale = 1 scale = scale * 0.01 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gr...@us...> - 2024-09-10 18:25:21
|
Revision: 9925 http://sourceforge.net/p/docutils/code/9925 Author: grubert Date: 2024-09-10 18:25:17 +0000 (Tue, 10 Sep 2024) Log Message: ----------- late commit to rename .txt to .rst Modified Paths: -------------- trunk/sandbox/infrastructure/README.rst trunk/sandbox/infrastructure/docutils-update.local trunk/sandbox/infrastructure/set_version.sh Added Paths: ----------- trunk/sandbox/infrastructure/crosstest/index.rst trunk/sandbox/infrastructure/releasing-log.rst trunk/sandbox/infrastructure/sdist-install-20240410.rst Removed Paths: ------------- trunk/sandbox/infrastructure/crosstest/index.txt trunk/sandbox/infrastructure/releasing-log.txt trunk/sandbox/infrastructure/sdist-install-20240410.txt Modified: trunk/sandbox/infrastructure/README.rst =================================================================== --- trunk/sandbox/infrastructure/README.rst 2024-09-10 18:17:15 UTC (rev 9924) +++ trunk/sandbox/infrastructure/README.rst 2024-09-10 18:25:17 UTC (rev 9925) @@ -12,7 +12,7 @@ The `infrastructure <.>`_ sandbox directory stores any scripts that are needed for the development of the Docutils project. -:`<releasing-log.txt>`_: What happend at release time ... what to do next time +:`<releasing-log.rst>`_: What happend at release time ... what to do next time better. :`<docutils-update.local>`_: The script to update the `web site`_ @@ -37,7 +37,7 @@ is not in use ... move to attic. :`<release.sh>`_: The script to make releases of Docutils. - For usage details see `release.txt`_ + For usage details see `release.rst`_ TODO : test. Allow release without testing, because tests must be done @@ -60,4 +60,4 @@ .. _web site: http://docutils.sourceforge.net/docs/dev/website.html .. _Docutils Subversion repository: http://docutils.sourceforge.net/docs/dev/repository.html -.. _release.txt: http://docutils.sourceforge.net/docs/dev/release.html +.. _release.rst: http://docutils.sourceforge.net/docs/dev/release.html Copied: trunk/sandbox/infrastructure/crosstest/index.rst (from rev 9924, trunk/sandbox/infrastructure/crosstest/index.txt) =================================================================== --- trunk/sandbox/infrastructure/crosstest/index.rst (rev 0) +++ trunk/sandbox/infrastructure/crosstest/index.rst 2024-09-10 18:25:17 UTC (rev 9925) @@ -0,0 +1,70 @@ +=================== +docutils cross test +=================== + +:Date: $Date$ + +Testing against/with/through several python installations. + +tox does this ... somehow ... trying to do it explicit. + +* test with PYTHONWARNINGS=default + + this shows deprecation warnings. + +* and LC_ALL=C + +Log +--- + +* setup a virtual environment with every python + include wheel + +* build a wheel with every python (in the venv ?) + + before build clean docutils:: + + find . -type f -name "*.pyc" -delete + + 3.7 and 3.10 fail : _ctypes missing + + 3.6 and 3.8 have the same md5sum, others differ. + +* missing _ctypes for 3.7 and 3.10 + + - install libffi-dev + + python 3.7 works + + but 3.10a6 fails building venv :: + + python3.10 -m venv a + Error: subprocess not supported for isolated subinterpreters + + find a + a/lib + a/lib/python3.10 + a/lib/python3.10/site-packages + a/lib64 + a/include + a/bin + a/bin/python3 + a/bin/python + a/bin/python3.10 + a/pyvenv.cfg + + For now skip 3.10 + +* test wheel from 3.7 in every venv + with + + export LC_ALL=C + export PYTHONPATH= + export PYTHONWARNINGS=default + +MAYBE + +* test every wheel in every venv + + + Deleted: trunk/sandbox/infrastructure/crosstest/index.txt =================================================================== --- trunk/sandbox/infrastructure/crosstest/index.txt 2024-09-10 18:17:15 UTC (rev 9924) +++ trunk/sandbox/infrastructure/crosstest/index.txt 2024-09-10 18:25:17 UTC (rev 9925) @@ -1,70 +0,0 @@ -=================== -docutils cross test -=================== - -:Date: $Date$ - -Testing against/with/through several python installations. - -tox does this ... somehow ... trying to do it explicit. - -* test with PYTHONWARNINGS=default - - this shows deprecation warnings. - -* and LC_ALL=C - -Log ---- - -* setup a virtual environment with every python - include wheel - -* build a wheel with every python (in the venv ?) - - before build clean docutils:: - - find . -type f -name "*.pyc" -delete - - 3.7 and 3.10 fail : _ctypes missing - - 3.6 and 3.8 have the same md5sum, others differ. - -* missing _ctypes for 3.7 and 3.10 - - - install libffi-dev - - python 3.7 works - - but 3.10a6 fails building venv :: - - python3.10 -m venv a - Error: subprocess not supported for isolated subinterpreters - - find a - a/lib - a/lib/python3.10 - a/lib/python3.10/site-packages - a/lib64 - a/include - a/bin - a/bin/python3 - a/bin/python - a/bin/python3.10 - a/pyvenv.cfg - - For now skip 3.10 - -* test wheel from 3.7 in every venv - with - - export LC_ALL=C - export PYTHONPATH= - export PYTHONWARNINGS=default - -MAYBE - -* test every wheel in every venv - - - Modified: trunk/sandbox/infrastructure/docutils-update.local =================================================================== --- trunk/sandbox/infrastructure/docutils-update.local 2024-09-10 18:17:15 UTC (rev 9924) +++ trunk/sandbox/infrastructure/docutils-update.local 2024-09-10 18:25:17 UTC (rev 9925) @@ -14,8 +14,8 @@ # # ATTENTION # -# Any .html document with a corresponding .rst or .txt file is regenerated -# if the .rst/.txt has changed, but no new .html files will be generated. +# Any .html document with a corresponding .rst file is regenerated +# if the .rst has changed, but no new .html files will be generated. # # ATTENTION # @@ -24,6 +24,8 @@ # add --smartquotes=true to convert smartquotes. # Maybe add special treatment and remove this general solution. # +# * Funny thing: sf hides README.rst and .txt files. +# # Options: # -f Do not give feedback. # -t Run the script in trace mode ("set -o xtrace"). Copied: trunk/sandbox/infrastructure/releasing-log.rst (from rev 9924, trunk/sandbox/infrastructure/releasing-log.txt) =================================================================== --- trunk/sandbox/infrastructure/releasing-log.rst (rev 0) +++ trunk/sandbox/infrastructure/releasing-log.rst 2024-09-10 18:25:17 UTC (rev 9925) @@ -0,0 +1,1871 @@ +Releasing +========= + +:Contact: gr...@us..., doc...@us... +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This document has been placed in the public domain. + +Notes on what happend while releasing. + +Release 0.22b0.dev0 (2024-08-14) +================================ + +To test installing sdist from testpyi: failed flit is required to be +available on testpypi (IMHO). + +* Make a clean checkout of svn.code.sf.net/p/docutils/code/trunk/docutils + +* skip till + + Run tests :: + + export PYTHONWARNINGS=default + python3 test/alltests.py + + and with tox. + + ``export PYTHONWARNINGS=default`` prints DeprecationWarnings in python3. + + No warnings or errors. + +* Generate wheel and source-distribution:: + + python3 -m pip install build + python3 -m build . + + check file sizes: the 0.21.2 wheel was 574K the sdist 2,2M. + ... similar sizes. + +* Upload wheel and source to test.pypi. + + Set repository and key in ~/.pypirc with a <server-name> and + password token:: + + python3 -m twine upload --repository <server-name> dist/* + + Change directory outside of checkout and test in venv. + NOTE use --pre for prereleases:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --index-url https://test.pypi.org/simple/ --pre --no-deps docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + Ignore missing HISTORY.txt it is not in the wheel file. + if ok :: + + deactivate ; cd .. ; rm -r du3 + + Test the sdist:: + + python3 -m venv du3s ; cd du3s + export PYTHONPATH= ; . bin/activate + + pip install --index-url https://test.pypi.org/simple/ --no-binary docutils docutils + + sdist installation fails with subprocess not finding flit_core . + test.pypi has flit 3.5.1 but installs 0.5 preinstalling flit_core did not work + either ... why. + + Installing build into the venv did not help and flit neither. + +Release 0.21.2 (2024-04-23) +=========================== + +follow docs/dev/release.txt + +Release 0.21.1 (2024-04-10) +=========================== + +Because adding post-release numbers in a rush is not considered good +and on pypi it 0.21.post2 would be a new release anyway. + +follow docs/dev/release.txt + +everything fine till ... install sdist +-------------------------------------- + +The error :: + + pip install --index-url https://test.pypi.org/simple/ --no-deps --no-binary docutils -U docutils + Looking in indexes: https://test.pypi.org/simple/ + Requirement already satisfied: docutils in ./lib/python3.12/site-packages (0.21) + Collecting docutils + Using cached https://test-files.pythonhosted.org/packages/14/1c/642f839d386b7e88da5ed5d15ad9ae100bac9e86b4cb0781ebfebdc9c42f/docutils-0.21.1.tar.gz (2.2 MB) + Installing build dependencies ... error + error: subprocess-exited-with-error + + × pip subprocess to install build dependencies did not run successfully. + │ exit code: 1 + ╰─> [3 lines of output] + Looking in indexes: https://test.pypi.org/simple/ + ERROR: Could not find a version that satisfies the requirement flit_core<4,>=3.4 (from versions: none) + ERROR: No matching distribution found for flit_core<4,>=3.4 + [end of output] + + note: This error originates from a subprocess, and is likely not a problem with pip. + error: subprocess-exited-with-error + + × pip subprocess to install build dependencies did not run successfully. + │ exit code: 1 + ╰─> See above for output. + + note: This error originates from a subprocess, and is likely not a problem with pip. + +there is no "flit_core" on testpypi only "flit 0.5". +Preinstalling "flit_core 3.9" in the "venv" does not help either. + +Even with preinstalled flit_core 3.9 :: + + Using cached https://test-files.pythonhosted.org/docutils-0.21.1.tar.gz (2.2 MB) + Installing build dependencies ... error + error: subprocess-exited-with-error + + × pip subprocess to install build dependencies did not run successfully. + │ exit code: 1 + ╰─> [3 lines of output] + Looking in indexes: https://test.pypi.org/simple/ + ERROR: Could not find a version that satisfies the requirement flit_core<4,>=3.4 (from versions: none) + ERROR: No matching distribution found for flit_core<4,>=3.4 + [end of output] + + note: This error originates from a subprocess, and is likely not a problem with pip. + + (du3s) engelbert@ooney:~/projects/du3s$ pip list + Package Version + --------- ------- + docutils 0.21.1 + flit 3.2.0 + flit_core 3.9.0 + pip 24.0 + +Postbone to pypi. + +* retest wheel from test.pypi. + +Continue release.txt + +* Commit changes ... the changed version number. + +* If final release tag #.# (Note: only directory docutils is copied):: + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils \ + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-#.# \ + -m "tagging release #.#" + +* Rebuild wheel and source-distribution :: + + rm dist/* + python3 -m flit build + +* Now upload to pypi:: + + python3 -m twine upload --repository <server-name> dist/docutils-#.#* + +* Remove previous package from local cache:: + + find .cache/pip/wheels -name docutils\*whl -exec rm -v -i {} \; + +* test sdist:: + + pip install --no-binary docutils docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + Ignore missing pil. + + Note: + + ``--no-binary all`` did install docutils wheel. + +* test the binary: ok + +Continue to end. + + +Release 0.21 (2024-04-09) +========================= + +(follow docs/dev/release.txt) + +everything fine till ... +------------------------ + +preparing docs upload + + For final releases continue + + * upload source and generated html to sf-htdocs/#.# :: + + mkdir tmp1 + cd tmp1 + tar xzvf ../dist/docutils-0.21.tar.gz + cd docutils-#.#/ + python3 tools/buildhtml.py . + +the sdist only contains :: + + COPYING.txt docutils PKG-INFO pyproject.toml + +on 20.1 it was :: + + BUGS.txt docutils.conf install.py README.txt test + COPYING.txt docutils.egg-info licenses RELEASE-NOTES.txt THANKS.txt + docs FAQ.txt MANIFEST.in setup.cfg tools + docutils HISTORY.txt PKG-INFO setup.py tox.ini + +HACK for the release, check flit later. +Copy following files and directories from source directory:: + + BUGS.txt docutils.conf FAQ.txt HISTORY.txt licenses README.txt RELEASE-NOTES.txt + THANKS.txt + docs + tools + +Stop release process before uploading source tarball to sourceforge. + +"flit"'s ``--use-vcs`` only works for "git" and "hg", therefore not for us. + +* fix: pyproject.toml +* build new distribution: ``python -m flit build`` +* check sdist +* copy the sdist to docutils-0.21.post1.tar.gz +* and upload to pypi + + Error : only one sdist per release allowed. + +* Deleting the sdist in pypi-web-interface. +* upload again ... worked. + +* Upload to sourceforge.net + +* commit changes: pyproject.toml, docs/dev/release.txt + +* set version 0.22b.dev + +pip does not like the post1 +--------------------------- + +installing from source breaks :: + + pip install --no-binary docutils docutils + + Discarding ... docutils-0.21.post1.tar.gz has inconsistent version: + expected '0.21.post1', but metadata has '0.21' + +* patch VersionInfo to use serial for post# when releaselevel is "fimal". +* flit build:: + + 591K docutils-0.21.post2-py3-none-any.whl + 2,2M docutils-0.21.post2.tar.gz + +* upload to testpypi +* test :: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + +* test nobinary :: + + python3 -m venv du3p ; cd du3p + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-binary all docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + passes except the missing pil and pngs ... as usual. + +But consensus is 0.21.1 + + +Release 0.20.1 (2023-05-17) +=========================== + +(follow docs/dev/release.txt) + +* Make a clean checkout of svn.code.sf.net/p/docutils/code/trunk/docutils + to avoid having development files in the released packages. + +* Update RELEASE-NOTES.txt add section ``Release <version>``. + + Consult HISTORY.txt for important changes. + +* Change HISTORY.txt title ``Changes Since <previous release>`` to ``Release <version>``. + +* Set new version (replace ``<version>`` with the new version indentifier + and ``<docutils-repository-root>`` with the dir containing + ``HISTORY.txt`` and ``RELEASE-NOTES.txt``):: + + cd <docutils-repository-root> + ../sandbox/infrastructure/set_version.sh <version> + + Check what was changed by ``set_version.sh``. + + Run tests :: + + export PYTHONWARNINGS=default + python3 test/alltests.py + + or use tox. + In case of errors, clearing ``docutils/__pycache__`` may help. + + ``export PYTHONWARNINGS=default`` prints DeprecationWarnings in python3. + +* Generate wheel and source-distribution:: + + python3.11 setup.py sdist + python3.11 setup.py bdist_wheel + +* check sdist for html-files in docutils.egg-info. +* Upload wheel and source to test.pypi:: + + python3.11 -m twine upload --repository docutils_testpypi dist/docutils-0.20.1* + + *docutils_testpypi* is a repository configured in .pypirc. + + Test in venv. NOTE use --pre for prereleases:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --pre --no-deps docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + As expected HISTORY fails because it is not in the package. + + python -m pip uninstall docutils + deactivate ; cd .. ; rm -r du3 + +* Commit changes ... the changed version number. + +* tag #.# (Note: only directory docutils is copied):: + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils \ + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-#.# \ + -m "tagging release #.#" + +* Update your source directory. + + Nothing changed. + +* Now upload the same files to pypi:: + + python3.11 -m twine upload --repository docutils_pypi dist/docutils-0.20.1* + +* Remove previous package from local cache:: + + find .cache/pip/wheels -name docutils\*whl -exec rm -v -i {} \; + +* and test:: + + python3.11 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps docutils + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + python -m pip uninstall docutils + deactivate ; cd .. ; rm -r du3 + +* Notify to docutils-developer and user. + +* upload source and generated html to sf-htdocs/0.20.1 :: + + mkdir tmp1 + cd tmp1 + tar xzvf ../dist/docutils-0.20.1.tar.gz + cd docutils-0.20.1/ + python3.11 tools/buildhtml.py . + + check for html-files in docutils.egg-info/ ... None:: + + find . -name \*.pyc -exec rm -v {} \; + find . -name __pycache__ -exec rmdir -v {} \; + rm -r docutils.egg-info + rsync -e ssh -r -t ./ web.sourceforge.net:/home/project-web/docutils/htdocs/0.20.1 + +* Check web/index.txt for necessary corrections. +* Run sandbox/infrastructure/docutils-update.local to update web-content. +* Release to sourceforge. + + - Upload docutils-#.#.tar.gz and release notes to sourceforge. + - Select docutils-#.#.tar.gz as default for all OS. + +* set_version 0.20.2b.dev +* tox: py3.7 3.8 3.9 3.10 3.11 +* docutils/HISTORY.txt: add title "Changes Since 0.20.1" +* run sandbox/infrastructure/docutils-update.local + + +Release 0.20 (2023-05-09) +========================= + +(follow docs/dev/release.txt) + +release (2023-05-09) + +* Update RELEASE-NOTES.txt add section ``Release 0.20``. + + Changes were already done on canditate + +* Change HISTORY.txt title ``Release 0.20 (2023-05-09)``. + +* Set new version (replace ``<version>`` with the new version indentifier + and ``<docutils-repository-root>`` with the dir containing + ``HISTORY.txt`` and ``RELEASE-NOTES.txt``):: + + cd <docutils-repository-root> + ../sandbox/infrastructure/set_version.sh <version> + +* run tox 3.7 ... 3.11, run python3.12 alltests.py + + all OK. + +* Generate wheel and source-distribution:: + + python3 setup.py sdist + python3 setup.py bdist_wheel + +* Upload wheel and source to test.pypi:: + + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + + Test in venv. :: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + python -m pip uninstall docutils + deactivate ; cd .. ; rm -r du3 + +* Commit changes ... the changed version number. + +* tag #.# (Note: only directory docutils is copied):: + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils \ + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-0.20 \ + -m "tagging release 0.20" + +* Update your source directory. +* Rebuild wheel and source-distribution :: + + python3 setup.py sdist + python3 setup.py bdist_wheel + +* Now upload to pypi:: + + python3 -m twine upload dist/docutils-0.20* + +* and test:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps docutils + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + deactivate ; cd .. ; rm -r du3 + +* Notify to docutils-developer and user. + +* upload source and generated html to sf-htdocs/#.# :: + + mkdir tmp1 + cd tmp1 + tar xzvf ../dist/docutils-0.20.tar.gz + cd docutils-0.20/ + python3 tools/buildhtml.py . + find . -name \*.pyc -exec rm -v {} \; + find . -name __pycache__ -exec rmdir -v {} \; + rm -r docutils.egg-info + rsync -e ssh -r -t ./ web.sourceforge.net:/home/project-web/docutils/htdocs/0.20 + +* Check web/index.txt for necessary corrections. Nothing changed. +* Run sandbox/infrastructure/docutils-update.local to update web-content. +* Release to sourceforge. + + - Upload docutils-0.20.tar.gz and release notes to sourceforge. + - Select docutils-0.20.tar.gz as default for all OS. + +* set_version 0.20.1b.dev +* run tox : OK +* docutils/HISTORY.txt: add title "Changes Since 0.20" +* commit +* run sandbox/infrastructure/docutils-update.local + +release candidate 1 (2023-05-04) +-------------------------------- + +* svn update +* run tox : py3.7 to py3.11 : OK +* run tests with 3.12.0a7 : OK + +* Update RELEASE-NOTES.txt add section ``Release <version>``. + + Consult HISTORY.txt for important changes. + +* Change HISTORY.txt title ``Changes Since <previous release>`` to ``Release <version>``. + +* Set new version with ``sandbox/infrastructure/set_version.sh <version>`` + + run tox (py3.7 to 3.11) + + Check docutils/__init__.py __version_info__ tuple. : OK + + Run tests :: + + export PYTHONWARNINGS=default + python3 test/alltests.py + + OK , no warnings (really no) + +* Generate wheel and source-distribution:: + + python3 setup.py sdist + python3 setup.py bdist_wheel + +* Upload wheel and source to test.pypi:: + + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + +* Test in venv. NOTE use --pre for prereleases:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --pre --no-deps docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + HISTORY.txt is not installed with wheel. + + Clean up:: + + python -m pip uninstall docutils + deactivate ; cd .. ; rm -r du3 + +* Commit changes ... the changed version number. + +* Now upload to pypi:: + + python3 -m twine upload dist/docutils-0.20* + +* Remove previous package from local cache:: + + find .cache/pip/wheels -name docutils\*whl -exec rm -v -i {} \; + +* and test:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --pre --no-deps docutils + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + HISTORY.txt is missing. + + Clean up:: + + deactivate ; cd .. ; rm -r du3 + +* Notify to docutils-developer and user. + +* update web page. + +TODO on release tag the source + +Release 0.19 (2022-07-05) +========================= + +(follow docs/dev/release.txt) + +* svn update +* run tox +* run tests with py3.6 to 3.11 + +* Update RELEASE-NOTES.txt add section ``Release <version>``. + + Consult HISTORY.txt for important changes. + +* Change HISTORY.txt title ``Changes Since <previous release>`` to ``Release <version>``. + +* Set new version with ``sandbox/infrastructure/set_version.sh <version>`` + + Check what was changed with version control system by ``set_version.sh`` + + Change docutils/__init__.py __version_info__ tuple. + + Run tests :: + + export PYTHONWARNINGS=default + python3 test/alltests.py + + or use tox. + + ``export PYTHONWARNINGS=default`` prints DeprecationWarnings in python3. + +* Generate wheel and source-distribution:: + + python3 setup.py sdist + python3 setup.py bdist_wheel + +* Upload wheel and source to test.pypi:: + + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + + Test in venv. NOTE use --pre for prereleases:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + python -m pip uninstall docutils + deactivate ; cd .. ; rm -r du3 + +* Commit changes ... the changed version number. + +* tag 0.## (Note: only directory docutils is copied):: + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils \ + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-0.19 \ + -m "tagging release 0.19" + +* Update your source directory. +* Rebuild wheel and source-distribution :: + + python3 setup.py sdist + python3 setup.py bdist_wheel + +* Now upload to pypi:: + + python3 -m twine upload dist/docutils-0.19* + +* Remove previous package from local cache:: + + find .cache/pip/wheels -name docutils\*whl -exec rm -v -i {} \; + +* and test:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps docutils + cp -Lr ../docutils-code/docutils/test . + python test/alltests.py + + deactivate ; cd .. ; rm -r du3 + +* Notify to docutils-developer and user. + +* upload source and generated html to sf-htdocs/0.19 :: + + mkdir tmp1 + cd tmp1 + tar xzvf ../dist/docutils-0.19.tar.gz + cd docutils-0.19/ + tools/buildhtml.py . + find . -name \*.pyc -exec rm -v {} \; + find . -name __pycache__ -exec rmdir -v {} \; + rm -r docutils.egg-info + rsync -e ssh -r -t ./ web.sourceforge.net:/home/project-web/docutils/htdocs/0.19 + +* Check web/index.txt for necessary corrections. +* Run sandbox/infrastructure/docutils-update.local to update web-content. +* Release to sourceforge. + + - Upload tar.gz and 0.19 release notes to sourceforge. + - Select docutils-0.19.tar.gz as default for all OS. + +* set_version 0.19.1b.dev +* test with py3 +* docutils/HISTORY.txt: add title "Changes Since 0.##" +* svn commit +* run sandbox/infrastructure/docutils-update.local + +Problems while releasing 0.19b1 +=============================== + +* If docutils is installed into virtual environment and + the test directory is copied from development directory + with ``cp -Lr ...``:: + + -L, --dereference + always follow symbolic links in SOURCE + + - finding ``HISTORY.txt`` in test_utils.py fails. + Create a HISTORY.txt file to avoid. + +setup.cfg contained the universal setting that generated py2py3 wheels. + +Release 0.19b1 (2022-06-21) +=========================== + +* run tox: +* set_version 0.19b1 +* tox again +* Generate universal wheel and source-distribution :: + + python3 setup.py sdist + python3 setup.py bdist_wheel + +* Upload universal wheel and source to test.pypi:: + + twine upload --repository-url https://test.pypi.org/legacy/ dist/docutils-0.19b* + +* test in venvs: ignore wrong paths and un-embedded images + +* upload to pypi:: + + twine upload dist/docutils-0.19* + +* and test: python uses the cached download from the previous test. + + - remove from pip cache:: + + find .cache/pip/wheels -name docutils\*whl + +ERROR (fixed in r9089) + + ``python3 setup.py bdist_wheel`` builds a docutils-0.19b1-py2.py3-none-any.whl + although python > 3.7 is required ... will this break python2 installations ? + + This happens with option universal and without and also if using *build*. + + Testing with python2.7 : only 0.18 is installed, even with --pre and -U. + + Locally cached wheels may pose a problem, though. + Cf. https://github.com/marshmallow-code/marshmallow/issues/1860 + +* set_version 0.19b2.dev and change __version_info_structure. +* tox +* commit +* Run sandbox/infrastructure/docutils-update.local to update web-content. + +Release 0.18.1 (2021-11-23) +=========================== + +follow docs/dev/release.txt + +Release 0.18.1b (2021-11-18) +============================ + +* run tox: passed 2.7, 3.5 ... 3.11 +* set_version 0.18.1b +* tox again +* commit : release 0.18.1b +* Generate universal wheel and source-distribution with py3.8:: + + python3 setup.py sdist + python3 setup.py bdist_wheel --universal + +* Upload universal wheel and source to test.pypi:: + + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/docutils-0.18.1b0* + +* test in venvs: ignore wrong paths and un-embedded images + +* upload to pypi:: + + python3.9 -m twine upload dist/docutils-0.18.1b0* + +* and test: Note python3 uses the cached download from the python2 test. + + - remove from pip cache:: + + find .cache/pip/wheels -name docutils\*whl + +* set_version 0.18.1b1.dev +* tox +* commit +* Run sandbox/infrastructure/docutils-update.local to update web-content. + +Release 0.18 (2021-10-26) +========================= + +* beta is out for three weeks. +* announce soft freeze on dev-mail. +* run tox: passed 2.7, 3.5 ... 3.11 +* set_version 0.18 +* tox again +* commit : release 0.18 +* Generate universal wheel and source-distribution with py39. +* Upload universal wheel and source to test.pypi. +* test in venvs: ignore wrong paths and un-embedded images +* tag release 0.18 + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-0.18 + -m "tagging release 0.18" + +* upload to pypi +* and test: Note python3 uses the cached download from the python2 test. + + +* upload source and generated html to sf-htdocs/0.18 + + mkdir tmp1 + cd tmp1 + tar xzvf ../dist/docutils-0.18.tar.gz + cd docutils-0.18/ + tools/buildhtml.py . + find . -name \*.pyc -exec rm {} \; + rm -rf docutils.egg-info + rsync -e ssh -r -t ./ web.sourceforge.net:/home/project-web/docutils/htdocs/0.18 + +* Check web/index.txt for necessary corrections : None necessary. +* Release to sourceforge. + + - Upload tar.gz and 0.18 release notes to sourceforge. + - Select docutils-0.18.tar.gz as default for all OS. + +* set_version 0.18.1.dev +* tox +* docutils/HISTORY.txt: add title "Changes Since 0.18" +* Notify docutils-developer and user. +* Run sandbox/infrastructure/docutils-update.local to update web-content. + +Release 0.17 aftermath +====================== + +:2021-04-05: Fixed: on-ASCII characters in docutils/writers/latex2e/docutils.sty + +:2021-04-04: Open: [readthedocs/recommonmark] + AttributeError: 'Values' object has no attribute 'tab_width' (#220) + + pinning to docutils 0.16 helped ... why ? + +Release 0.17.1 (2021-04-16) +=========================== + +* tox with 2.7 3.5, 3.6, 3.7, 3.8, 3.9, 3.10 +* set_version 0.17.1 +* tox again +* commit : release 0.17.1 +* Generate universal wheel and source-distribution with py38. +* Upload universal wheel and source to test.pypi. +* test in venvs ... and then next problem pypi caches 0.17.1b2. + + --no-cache-dir does not help. + + call twice, second time with ``--upgrade``. + +* tag release 0.17.1 +* upload to pypi +* and test +* Notify docutils-developer and user. +* upload source and generated html to sf-htdocs/0.17.1 +* Check web/index.txt for necessary corrections : None necessary. +* Release to sourceforge. +* set_version 0.17.2b.dev +* tox +* docutils/HISTORY.txt: add title "Changes Since 0.17.1" +* run sandbox/infrastructure/docutils-update.local + + +Release 0.17.1 (2021-04-12 ...) +=============================== + +* tox with 2.7 3.5, 3.6, 3.7, 3.8, 3.9, 3.10 + + - 3.7 and 3.10 fail. Both with :: + + from _ctypes import Union, Structure, Array + ModuleNotFoundError: No module named '_ctypes' + + testing against development source passes. + + Test crosstest, see subdirectory + + 3.7 and 3.10 require libffi-dev to build local + then tox passes for 3.5 to 3.10. + +Release 0.17.1b1 (2021-04-09) +============================= + +* tox with 2.7 3.5, 3.6, 3.8, 3.9 + +* with LC_ALL=C and PYTHONWARNINGS=default + + python3.6 and python3.10.0a :: + + docutils/utils/smartquotes.py:639: DeprecationWarning: invalid escape sequence \[ + ch_classes = {'open': u'[(\[{]', # opening braces + docutils/test/test_writers/test_manpage.py:62: DeprecationWarning: invalid escape sequence \- + ... several of the same + +* recommonmark tests:: + + python3.6 -m pip install --user recommonmark + # 0.7.1 + + python3.6 test/alltests.py + FAILED (failures=17, errors=17, skipped=1) + + input: + b'\nExternal hyperlink [target]s:\n\n[target]: http://www.python.org/\n' + -: expected + +: output + <document source="test data"> + <paragraph> + External hyperlink + - <reference name="target" refuri="http://www.python.org/"> + ? -------------- + + <reference refuri="http://www.python.org/"> + target + s: + + only works with recommonmark 0.4 + +* Generate universal wheel and source-distribution with py38. +* Upload universal wheel and source to test.pypi. +* Test in python3.8 venv + + Fails. + + Inside virtualenv :: + + >>> import docutils.parsers.recommonmark_wrapper as rw + >>> dir(rw) + ['Parser', '__builtins__', '__cached__', '__doc__', '__file__', + '__loader__', '__name__', '__package__', '__spec__', + '_recommonmarkParser', 'docutils', 'nodes', 'with_recommonmark'] + + In development directory :: + + >>> import docutils.parsers.recommonmark_wrapper as rw + >>> dir(rw) + ['CommonMarkParser', 'Component', 'Parser', '__builtins__', + '__cached__', '__doc__', '__file__', '__loader__', + '__name__', '__package__', '__spec__', 'docutils', 'nodes'] + + Depending on recommonmark being installed in the running python + version or not ``CommonMarkParser`` is a class or None. + +* Rebuild the wheel after running tox (this cleans caches). + Cannot be uploaded to testpypi because it is the same name. + + Install the whl from dist-directory into py38 venv. + Ok. + +* New version 0.17.1b1.dev because pypi does not allow changing uploads. +* Run tox and python3.10 test. +* Commit new version number +* build sdist and universal wheel with py39. +* Install wheel from dist into venv py39. + + Test passes (embedding fails because images are missing). + +* Upload universal wheel and source to test.pypi. +* Install into py39 venv : This time install the --pre release + tests pass. + +* upload to pypi. +* test in py39 venv. Passed +* test in py39 venv with LC_ALL=C. Passed +* test in venv with recommonmark==0.4: fails . requires module html. + +* notify docutils-develop and user and sphinx. +* New version 0.17.1b2.dev + +Release 0.17 (2021-04-03 ...) +============================= + +* tox with 2.7 3.8, 3.9 + + 3.10a6 misses _ctypes. + +* copy more things from HISTORY to RELEASE-NOTES + +* ``set_version.sh 0.17`` + +* Run tests manually and via tox: + + ======== ====== + pyvers time + ======== ====== + 2.7 7.3 + 3.8 6.5 + 3.9 6.5 + 3.10 7.2 + ======== ====== + +* Generate universal wheel and source-distribution. +* Upload universal wheel and source to test.pypi. + Wait some minutes to test in python2 virtualenv. + + Test in python3.10 venv. + + Stylesheet paths are different and image embedding fails + because images are not found. + + After copying ``docs/user/rst/images`` from docutils into the + venv-directory/docs/user/rst/images image embedding works. + +* Commit changes to version control system. +* tag 0.17 (Note: only directory docutils is copied):: + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils \ + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-0.17 \ + -m "tagging release 0.17" + +* Generate universal wheel and source-distribution. + Do it again and check for differences: svn-numbers and sha-fingerprints + +* Now upload to pypi (the newly created s- and bdist). +* ... and test in venv and virtualenv. +* Notify to docutils-developer and user. +* Upload source and html to sf-htdocs/0.17 + +* Check web/index.txt for necessary corrections: nothing to do. + +* Run sandbox/infrastructure/docutils-update.local to update web-content. +* Release to sourceforge. + + - Upload tar.gz and 0.17 release notes to sourceforge. + - Select docutils-0.17.tar.gz as default for all OS. + +* set_version 0.18b.dev +* test with py2 and py3 +* docutils/HISTORY.txt: add title "Changes Since 0.17" + +* run sandbox/infrastructure/docutils-update.local + +BetaRelease 0.17b1 (2021-02-10) to test.pypi +============================================ + +* tox with 2.7 3.8 and 3.9 :: + + functional/expected/standalone_rst_html5.html + + -<dl class="footnote brackets"> + ... + -<dd><p>Requires support for attributes to inline + -roles to make sense.</p> + -</dd> + -</dl> + + seams to be a moved chunk in test input but not in expected + +* Version numbering + + ``python3 setup.py clean`` tells :: + + setuptools/dist.py:473: UserWarning: Normalizing '0.17b.dev' to '0.17b0.dev0'. + + According to https://peps.python.org/pep-0440/#pre-releases + + set_version 0.17b1 + +* test :: + + export PYTHONPATH= + export PYTHONWARNINGS=default + python2 test/alltests.py + + Ran 1454 tests + OK (skipped=3) + + python3 test/alltests.py + Ran 1442 tests + OK (skipped=5) + + python has some ResourceWarning:: + + docutils/parsers/rst/directives/images.py:145: ResourceWarning: + unclosed file <_io.BufferedReader name=b'../docs/user/rst/images/title.png'> + del img + + docutils/writers/html4css1/__init__.py:578: ResourceWarning: + unclosed file <_io.BufferedReader name=b'../docs/user/rst/images/biohazard.png'> + del img + +* Upload universal wheel and source to test.pypi:: + + python3 setup.py sdist + python3 setup.py bdist_wheel --universal + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + + Wait some minutes to test in virtualenv :: + + python2 -m virtualenv du2 ; cd du2 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps --pre docutils + # Successfully installed docutils-0.17b1 + + cp -r ~/projects/docutils-code/docutils/test . + # copy docs too for inlined images to be found + python2 test/alltests.py + # IGNORE stylesheet path differences ? + + Test in venv :: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --pre docutils + # Successfully installed docutils-0.17b1 + + cp -r ~/projects/docutils-code/docutils/test . + cp -r ~/projects/docutils-code/docutils/docs . + python test/alltests.py + # Python 3.8.5 Linux 5.4.0 + # IGNORE stylesheet path differences ? + +* commit 0.17b1 to code.sf + +* Now upload to pypi:: + + python3 -m twine upload dist/docutils-0.17b1* + +* and test:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps --pre docutils + # 0.17b1 + cp -r ~/projects/docutils-code/docutils/test . + cp -r ~/projects/docutils-code/docutils/docs . + python test/alltests.py + # css paths fail + +* Notify to docutils-developer and user. + +* ON RELEASE then: tag 0.16 (Note: only directory docutils is copied):: + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils \ + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-0.16 \ + -m "tagging release 0.16" + +* run sandbox/infrastructure/docutils-update.local + +* set version 0.17b2.dev +* test with tox: py27 and py38 39 +* commit to code.sf +* run sandbox/infrastructure/docutils-update.local + +.. note:: final release has some extra steps + +Release 0.16 (2020-01-12) +========================= + +Set version 0.16 + +test :: + + export PYTHONWARNINGS=default + python2 test/alltests.py + python3 test/alltests.py + +Upload universal wheel and source to test.pypi:: + + python3 setup.py sdist + python3 setup.py bdist_wheel --universal + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + +Wait some minutes to test in virtualenv :: + + python2 -m virtualenv du2 ; cd du2 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + # Successfully installed docutils-0.16 + + cp -r ~/projects/docutils-code/docutils/test . + python2 test/alltests.py + # IGNORE stylesheet path differences ? + + python -m pip uninstall docutils + deactivate ; cd .. ; rm -rf du2 + +Test in venv :: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + # Successfully installed docutils-0.16 + + cp -r ~/projects/docutils-code/docutils/test . + python test/alltests.py + # IGNORE stylesheet path differences ? + # FAIL: test_find_file_in_dirs (test_utils.HelperFunctionTests) + # FAIL: test_rst/ interpreted directives/code ... + # classes="keyword" is "name builtin" in 3.8.0b3 on Darwin 15.6.0 + +Now upload to pypi:: + + python3 -m twine upload dist/docutils-0.16* + +and test:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps docutils + # 0.16 + cp -r ~/projects/docutils-code/docutils/test . + python test/alltests.py + # css paths fail + + python2 -m virtualenv du2 ; cd du2 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps docutils + # 0.16 + cp -r ~/projects/docutils-code/docutils/test . + python test/alltests.py + # css paths fail + +Notify to docutils-developer and user. + +* tag 0.16 (Note: only directory docutils is copied):: + + svn copy svn+ssh://gr...@sv.../p/docutils/code/trunk/docutils \ + svn+ssh://gr...@sv.../p/docutils/code/tags/docutils-0.16 \ + -m "tagging release 0.16" + +* upload doc/0.16 :: + + mkdir tmp1 + cd tmp1 + tar xzvf ../dist/docutils-0.16.tar.gz + cd docutils-0.16/ + tools/buildhtml.py . + find . -name \*.pyc -exec rm {} \; + rm -rf docutils.egg-info + rsync -e ssh -r -t ./ web.sourceforge.net:/home/project-web/docutils/htdocs/0.16 + +* change web index.txt +* run sandbox/infrastructure/docutils-update.local + +* set version 0.17b.dev +* test with py2 and py3 +* run sandbox/infrastructure/docutils-update.local + +* docutils/HISTORY.txt: change title "Changes since 0.15" to "Release 0.16" + add "Changes since 0.16" +* docutils/RELEASE-NOTES.txt change title "Release 0.16b ..." to Release 0.16 ..." + +* Release to sourceforge. + + - Remove test/outputs from tar.gz. + - Upload tar.gz and 0.16 release notes to sourceforge. + - Select docutils-0.16.tar.gz as default for all OS. + +Release 0.16rc1 +--------------- + +Set version 0.16rc1 + +test :: + + export PYTHONWARNINGS=default + python2 test/alltests.py + python3 test/alltests.py + +Fix: DeprecationWarning: Please use assertEqual in test_nodes. + +Upload universal wheel and source to test.pypi:: + + python3 setup.py sdist + python3 setup.py bdist_wheel --universal + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* + +Wait some minutes to test in virtualenv :: + + python2 -m virtualenv du2 ; cd du2 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + # Successfully installed docutils-0.15.2 + python -m pip uninstall docutils + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps --pre docutils + # Successfully installed docutils-0.16Crc1 + + cp -r ~/projects/docutils-code/docutils/test . + python2 test/alltests.py + # IGNORE stylesheet path differences ? + + # -<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" /> + # -<link rel="stylesheet" href="../input/data/math.css" type="text/css" /> + # +<link rel="stylesheet" href="../../html4css1.css" type="text/css" /> + # +<link rel="stylesheet" href="../../math.css" type="text/css" /> + + deactivate ; cd .. ; rm -rf du2 + +Test in venv :: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + # Successfully installed docutils-0.15.2 + python -m pip uninstall docutils + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps --pre docutils + # Successfully installed docutils-0.16b0.dev0 + cp -r ~/projects/docutils-code/docutils/test . + python test/alltests.py + +Seven CSS-path failures ... ignored for now:: + + deactivate ; cd .. ; rm -rf du3 + +Now upload to pypi:: + + python3 -m twine upload dist/docutils-0.16rc1* + +and test:: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps --pre docutils + # 0.16rc1 + cp -r ~/projects/docutils-code/docutils/test . + python test/alltests.py + # css paths fail + + python2 -m virtualenv du2 ; cd du2 + export PYTHONPATH= ; . bin/activate + + pip install --no-deps --pre docutils + # 0.16rc1 + cp -r ~/projects/docutils-code/docutils/test . + python test/alltests.py + # css paths fail + +Notify to docutils-developer and user. + +Release 0.15 (2019-07-24) +========================= + +branches/rel-0.15 + +CAUTION (2019-07-22) +==================== + + While releasing 0.15 :: + + python3 setup.py sdist bdist_wheel + python2 setup.py bdist_wheel + + This will result in the py2 wheel being identical to the py3 one. + + The name ``docutils-0.15-py2-none-any.whl`` cannot be used twice on pypi, + build the py2-wheel and rename it ``docutils-0.15.post1-py2-none-any.whl``. + (No code was changed therefore only filename change.) + + Name it ``docutils-0.15-post1-py2-none-any.whl`` then the version in the filename + corresponds to the directory names in the wheel file. + + Maybe change the the version number in setup.py ? + +Release 0.15.2 (2019-07-30) +=========================== + +Bump the version number to ease tool live. + +Bump version :: + + set_version 0.15.2 + python2 test/alltests.py + python3 setup.py test3/alltests.py + # visual inspection + svn di | grep '^[+-]' | less -p '0.15.[12]' + svn ci + +Build py2 release upload to test.pypi :: + + mkdir py2 ; cd py2 + svn export svn+ssh://gr...@sv.../p/docutils/code/branches/rel-0.15/docutils + cd docutils + python2 setup.py sdist bdist_wheel + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/docutils-0.15.2-py2-none-any.whl + +Test in virtualenv :: + + virtualenv du2 ; cd du2 + export PYTHONPATH= ; . bin/activate + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + cp -r ~/projects/docutils-rel-0.15/docutils/py2/docutils/test . + python2 test/alltests.py + # IGNORE stylesheet path differences + + deactivate ; cd .. ; rm -rf du2 + +release to pypi from the exported source directory :: + + python3 -m twine upload dist/docutils-0.15.2* + +Test in new virtualenv :: + + virtualenv du2 ; cd du2 + export PYTHONPATH= ; . bin/activate + + pip install docutils + # Successfully installed docutils-0.15.2 + + cp -r ~/projects/docutils-rel-0.15/docutils/py2/docutils/test . + python2 test/alltests.py + # IGNORE stylesheet path differences + + deactivate ; cd .. ; rm -rf du2 + +Build py3 release upload to test.pypi. +In the export/docutils :: + + # py3 and source + python3 setup.py bdist_wheel + python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/docutils-0.15.2-py3-none-any.whl + +Test in virtualenv :: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + +BUG install 0.15 source. Check test.pypi web interface ... py3-wheel is there. +Retry:: + + # Successfully installed docutils-0.15.2 + cp -r ~/projects/docutils-rel-0.15/docutils/py2/docutils/test3 . + python test3/alltests.py + # IGNORE upper directory Failure + + deactivate ; cd .. ; rm -rf du3 + +release to pypi from the exported source directory :: + + python3 -m twine upload dist/docutils-0.15.2-py3* + +Wait for wheel to appear on pypi.org. + +Test in virtualenv :: + + python3 -m venv du3 ; cd du3 + export PYTHONPATH= ; . bin/activate + + pip install docutils + # Successfully installed docutils-0.15.2 + + cp -r ~/projects/docutils-rel-0.15/docutils/py2/docutils/test3 . + python test3/alltests.py + # IGNORE upper directory Failure + + deactivate ; cd .. ; rm -rf du3 + +FINE 0.15.2 + +Release 0.15.1 (2019-07-24) +=========================== + +Bug fix release for python2 only. + +* set version 0.15.1 +* ``python2 setup.py sdist bdist_wheel`` +* ``python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/docutils-0.15.1-py2-none-any.whl `` +* in a new virtualenv:: + + python -m pip install --index-url https://test.pypi.org/simple/ --no-deps docutils + + and then test/alltests.py + +* ``python3 -m twine upload dist/docutils-0.15.1*`` + + upload py2-wheel and source. + +* in a new virtualenv:: + + python -m pip install docutils + + and then test/alltests.py + +* (2019-07-25) replace source by -post1 + + Name it ``docutils-0.15.1-post1.tar.gz`` to make sure + + * It is unchanged library code: *post1* + * the version is still 0.15.1: therefore separate with ``-`` + + * run the tests somewhere, fix and commit. + Then:: + + svn export svn+ssh://@svn.code.sf.net/p/docutils/code/branches/rel-0.15/docutils d + cd d + python2 setup.py sdist + + * check ``tar tzf dist/docutils-0.15.1.tar.gz`` for remaining files. + Then:: + + mv dist/docutils-0.15.1.tar.gz dist/docutils-0.15.1-post1.tar.gz + python -m twine upload dist/docutils-0.15.1-post1.tar.gz + + * Build a venv (python3), install docutils, copy test3 from development + directory and run the test. + + As there is no 0.15.1 wheel for python3 this will be the source package. + +Release 0.15 +============ + +svn revision: 8258 - start of release + +* test on linux 2.7 3.7 : passed +* test on macosx python2.6: + + - 7 failures due to different error messages. see below + - 4 errors: python2.6 sys.version_info is a tuple no dictionary + FIXED: revision 8260 + +* test on macosx 2.7 3.4 3.6 3.7 : passed +* change version to : 0.15rc1.dev + + - run tests: python 2.7 and 3.7 + +* extract changes from HISTORY.txt to RELEASE-NOTES.txt +* rename headings in HISTORY.txt and RELEASE-NOTES.txt +* run release.sh stage 2: do a clean checkout and packing +* run local test with python 2.6 2.7 3.4 3.6 3.7 +* upload to sourceforge.net. Keep 0.15 as latest, stable. +* Fix: README.txt version number BY HAND +* pypi : + + - docutils is registered + - check setup.py : add classifier 'Programming Language :: Python :: 3.7' + - Login to pypi (see https://packaging.python.org/tutorials/packaging-projects/) + + - python3 -m pip install --user --upgrade setuptools wheel + + (warns about not being in PATH. symlink into my/bin) + - python3 setup.py sdist bdist_wheel :: + + /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'python_requires' + warnings.warn(msg) + + error: invalid command 'bdist_wheel' + + - add import setuptools to setup.py + - python3 setup.py sdist bdist_wheel + - python2 setup.py bdist_wheel + - python3 -m pip install --user --upgrade twine + - twine upload dist/* + + check on pypi: 0.15 is there. + +* update website docs + + - in directory web edit index.txt + - in sandbox/infrastructure run ./docutils-update.local + +* set version of repository to 0.16b.dev + +Release 0.14 +============ + +svn revision: 8145 - start of release - 0.15.0 beta + +Prerelease 0.14a0 +================= + +svn revision: 8082 Prerelease 0.14a0 +svn revision: 8078 Prerelease 0.14.0a + +* merge changes from HISTORY.txt to RELEASE-NOTES.txt +* extract release number description setting from release.sh +* rename headings in HISTORY.txt and RELEASE-NOTES.txt +* run release.sh stage 2: do a clean checkout and packing +* run local test with python2.7 +* upload to sourceforge.net. Keep 0.13 as latest, stable. +* reister on to pypi and upload tgz +* pypi: unset hide old releases + + +Release 0.13 +============ + +svn revision: 7980 + +Tests +----- + +Tests are run from svn checkout, only few from install. + +* windows7 python 2.7.5: OK + +* windows7 python 3.4.1: as in previous release + + * test.css path error (filed #256) + * test_parsers\test_rst\test_directives\test_include.py:: + +* macosx 10.10 python 2.7.10: OK +* macosx 10.10 python 3.3.2: OK +* macosx 10.10 python 3.4.1: OK + +* ubuntu 12.04 python 2.7.3: OK +* ubuntu 12.04 python 3.2.3: OK + +* testing tarball 0.13.1 (build sdist) :: + + +++ functional/output/standalone_rst_html5.html + @@ -7,9 +7,9 @@ + <meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description" xml:lang="en" /> + -<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" /> + -<link rel="stylesheet" href="../input/data/plain.css" type="text/css" /> + -<link rel="stylesheet" href="../input/data/math.css" type="text/css" /> + +<link rel="stylesheet" href="../../minimal.css" type="text/css" /> + +<link rel="stylesheet" href="../../plain.css" type="text/css" /> + +<link rel="stylesheet" href="../../math.css" type="text/css" /> + </head> + + this is because ``test/functional/input/data/minimal.css`` is a symlink to + ``../../../../docutils/writers/html5_polyglot/minimal.css`` and release_test.sh + removes directory docutils to ensure the test uses the installed docutils + not the unzipped. + + FIX: remove docutils/__init__.py + +Release 0.12 +============ + +svn revision: 7749 + +Tests +----- + +Tests are run from svn checkout, only few from install. + +Python3 tests are run :: + + rm -rf build test3 + python3 setup.py build + PYTHONPATH=build/lib python3 test3/alltests.py + +* ubuntu 8.04: python 2.4.5, 2.5.2, 2.6.7, 2.7.2 OK + + python 2.6.4rc1 6 failure due to change in error message: no such file ... + + python 3.2.3 OK + +* macosx 10.6.8: python 2.5.4, 2.7.3 + + python 2.6.1 6 failure due to change in error message: no such file ... + + python 3.2, 3.4.1 OK + +* ubuntu 14.04: pyton 2.7.6, python 3.4.0 OK + +* windows7: python 2.7.5 + + Error (filed #256): test_writers/test_html4css1_template.py:: + + stylesheet = """\ + - <link rel="stylesheet" href="/test.css" type="text/css" />""" + + <link rel="stylesheet" href="C:/test.css" type="text/css" />""" + ? ++ + + python 3.4.1 + + * test.css path error (filed #256) + * test_parsers\test_rst\test_directives\test_include.py:: + + b'Encoding:\n\n.. include:: test_parsers/test_rst/test_directives/utf-16.csv\n :encoding: utf-16\n' + File "test3\alltests.py", line 40, in write + string = string.encode('raw_unicode_escape').decode('ascii') + UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 994: ordinal not in range(128) + + fiddling with alltests.py (uncommitted) :: + + <system_message level="4" line="1" source="test data" type="SEVERE"> + <paragraph> + Problem with "raw" directive: + UnicodeDecodeError: \'utf-16-be\' codec can\'t decode bytes in position 90-91: illegal encoding + <literal_block xml:space="preserve"> + .. raw:: html + :file: test_parsers/test_rst/test_directives/utf-16.csv + :encoding: utf-16''' != '''\ + + + +Release 0.11 +============ + +Summary +------- + +``sandbox/infrastructure/release.sh`` tries running ``test/alltests.py`` after +installing the new release, this fails because + +* tests depends on e.g. ``../docs/user/rst/images/title.png`` or ``../HISTORY.txt``, + but thess are neither in the test directory tree nor in the installed software. + +* there is a lot of code trying to handle varying installation targets ``/usr/lib`` + ``/usr/local/lib` and not yet ``/usr/lib/pymodules``. + +Change testing to: + +1. build and install +2. extract docutils-<release>.tar.gz into tmp +3. remove docutils/docutils directory, just to make shure it is not used. +4. run test/alltest.py in this directory, so all files are where they are + while development. + +Following failure becuase docutils-library directory was removed, therefore +docutils/writers/html4css1/html4css1.css is not found:: + + ====================================================================== + FAIL: test_custom_stylesheet_dir (test_writers.test_html4css1_misc.SettingsTestCase) + ---------------------------------------------------------------------- + Traceback (most recent call last): + File "/... 0.11/test/test_writers/test_html4css1_misc.py", line 81, in test_custom_stylesheet_dir + self.assertIn('docutils/writers/html4css1/html4css1.css', styles) + File "/... 0.11/test/DocutilsTestSupport.py", line 138, in assertIn + msg or '%s not in %s' % _format_str(a, b)) + AssertionError: 'docutils/writers/html4css1/html4css1.css' not in u'''\ + <link rel="stylesheet" href="html4css1.css" type="text/css" /> + <link rel="stylesheet" href="data/ham.css" type="text/css" /> + ''' + + +Tests +----- + +* ubuntu 8.04 2.4.5, 2.5.2, 2.6.7, 2.7.2 OK + + python 2.6.4rc1 6 failure due to change in error message: no such file ... + + Python 3.2.3 : OK (roman.py left over from last release) + +* macosx 10.6.8: python 2.5.4, 2.7.3 + + python 2.6.1 6 failure due to change in error message: no such file ... + + python 3.2: roman.py for py3 required. + +Release.sh +---------- + +release.sh does not work on MacOSX. + +installation on ubuntu 10.04 breaks test script:: + + Working directory: /usr/local/lib/python2.6/site-packages/docutils-test + Docutils package: /usr/local/lib/python2.6/dist-packages/docutils + + ====================================================================== + FAIL: test_find_file_in_dirs (test_utils.HelperFunctionsTests) + ---------------------------------------------------------------------- + Traceback (most recent call last): + File "/usr/local/lib/python2.6/site-packages/docutils-test/test_utils.py", line 295, in test_find_file_in_dirs + '../HISTORY.txt') + AssertionError: 'HISTORY.txt' != '../HISTORY.txt' + +Stopping for now. + + + +Release 0.10 +============ + +* same failures for some python2.6 versions :: + + Problems with "raw" directive path: + - InputError: [Errno 2] No such file or directory: 'non-existent.file'. + + InputError: (2, 'No such file or directory'). + +* testing release tarball :: + + ====================================================================== + FAIL: test_dependencies (__main__.RecordDependenciesTests) + ---------------------------------------------------------------------- + Traceback (most recent call last): + File "docutils-test/test_dependencies.py", line 61, in test_dependencies + self.assertEqual(record, expected) + AssertionError: [u'data/include.txt', u'data/raw.txt'] != [u'../docs/user/rst/images/title.png', + u'data/include.txt', u'data/raw.txt'] + + ... + + because ../docs is not there if run from /usr/../pythonx.x/site-packages/docutils-test. + +Release 0.9.1 +============= + +same failures as for 0.9 plus + +* python 2.3: twice, ignored :: + + - [Errno 2] No such file or directory: 'bogus.csv'. + + [Errno 2] No such file or directory: u'bogus.csv'. + + python 2.3 :: + + ====================================================================== + ERROR: test_unicode (test_error_reporting.ErrorStringTests) + ---------------------------------------------------------------------- + Traceback (most ... [truncated message content] |
From: <gr...@us...> - 2024-09-10 18:17:16
|
Revision: 9924 http://sourceforge.net/p/docutils/code/9924 Author: grubert Date: 2024-09-10 18:17:15 +0000 (Tue, 10 Sep 2024) Log Message: ----------- FIX test_writers html4css when PIL is not installed Modified Paths: -------------- trunk/docutils/test/test_writers/test_html4css1.py Modified: trunk/docutils/test/test_writers/test_html4css1.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1.py 2024-09-10 15:30:31 UTC (rev 9923) +++ trunk/docutils/test/test_writers/test_html4css1.py 2024-09-10 18:17:15 UTC (rev 9924) @@ -21,6 +21,7 @@ import docutils import docutils.core +from docutils.parsers.rst.directives.images import PIL from docutils.utils.code_analyzer import with_pygments from docutils.writers import html4css1 @@ -36,6 +37,11 @@ DATA_ROOT = TEST_ROOT / 'data' ROOT_PREFIX = (TEST_ROOT / 'functional/input').as_posix() +# Pillow/PIL is optional: +if PIL: + SCALING_OUTPUT = 'style="width: 32px; height: 32px;" ' +else: + SCALING_OUTPUT = '' class Html5WriterPublishPartsTestCase(unittest.TestCase): """Test case for HTML5 writer via the publish_parts() interface.""" @@ -416,8 +422,8 @@ :scale: 100% .. figure:: /data/blue%20square.png """, -"""\ -<img alt="/data/blue%20square.png" src="/data/blue%20square.png" style="width: 32.0px; height: 32.0px;" /> +f"""\ +<img alt="/data/blue%20square.png" src="/data/blue%20square.png" {SCALING_OUTPUT}/> <div class="figure"> <img alt="/data/blue%20square.png" src="/data/blue%20square.png" /> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-10 15:30:34
|
Revision: 9923 http://sourceforge.net/p/docutils/code/9923 Author: milde Date: 2024-09-10 15:30:31 +0000 (Tue, 10 Sep 2024) Log Message: ----------- Documentation update. Fix/update links, add crosslinks. Restructure and update content. Modified Paths: -------------- trunk/docutils/FAQ.rst trunk/docutils/docs/howto/html-stylesheets.rst trunk/docutils/docs/ref/doctree.rst trunk/docutils/docs/ref/rst/directives.rst trunk/docutils/docs/ref/rst/restructuredtext.rst trunk/docutils/docs/user/config.rst trunk/docutils/docs/user/html.rst trunk/docutils/docs/user/latex.rst trunk/docutils/docs/user/links.rst trunk/docutils/docs/user/rst/quickstart.rst trunk/docutils/test/functional/expected/standalone_rst_html5.html trunk/docutils/test/functional/input/data/html5-features.rst trunk/sandbox/stylesheets/index.txt Modified: trunk/docutils/FAQ.rst =================================================================== --- trunk/docutils/FAQ.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/FAQ.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -199,14 +199,10 @@ What's the standard abbreviation for "reStructuredText"? -------------------------------------------------------- -"RST" and "ReST" (or "reST") are both acceptable. Care should be -taken with capitalization, to avoid confusion with "REST__", an -acronym for "Representational State Transfer". +"RST" (or "rST") and "ReST" (or "reST") are both acceptable. +Care should be taken with capitalization, to avoid confusion with +"REST__", an acronym for "Representational State Transfer". -The abbreviations "reSTX" and "rSTX"/"rstx" should **not** be used; -they overemphasize reStructuredText's predecessor, Zope's -StructuredText. - __ https://en.wikipedia.org/wiki/Representational_State_Transfer @@ -213,13 +209,8 @@ What's the standard filename extension for a reStructuredText file? ------------------------------------------------------------------- -It's ".txt". ReStructuredText source files are meant to be readable as -plaintext, and most operating systems already associate ".txt" with text -files. +The most commonly used extensions are ".rst" and ".txt". -That said, we see an increasing number of projects settling on -the extension ".rst". - Also see `What's the official MIME type for reStructuredText data?`_ @@ -245,55 +236,25 @@ Here's an ordinary paragraph. -Counterexample:: +See also `A reStructuredText Primer`__ +and the `reStructuredText Markup Specification`__. - Here's an ordinary paragraph. +__ docs/user/rst/quickstart.html#document-title-subtitle +__ docs/ref/rst/restructuredtext.html#document-title - This is *not* a Document Title - ============================== - - The "ordinary paragraph" above the section title - prevents it from becoming the document title. - -Another counterexample:: - - This is not the Document Title, because... - =========================================== - - Here's an ordinary paragraph. - - ... the title adornment is not unique - ===================================== - - Another ordinary paragraph. - - How can I represent esoteric characters (e.g. character entities) in a document? -------------------------------------------------------------------------------- For example, say you want an em-dash (XML character entity —, -Unicode character U+2014) in your document: use a real em-dash. -Insert literal characters (e.g. type a *real* em-dash) into your -input file, using whatever encoding suits your application, and tell -Docutils the input encoding. Docutils uses Unicode internally, so the -em-dash character is U+2014 internally. +Unicode character U+2014) in your document. -Emacs users should refer to the `Emacs Support for reStructuredText`__ -document. Tips for other editors are welcome. +ReStructuredText has no character entity subsystem. [#]_ +However, Docutils uses Unicode so you use a literal character +(e.g. a "real" em-dash) for all charactes supported by the +`input encoding`_ (by default "UTF-8"). -__ tools/editors/emacs/README.html - -ReStructuredText has no character entity subsystem; it doesn't know -anything about XML character entities. -To Docutils, "—" in input text is -7 discrete characters; no interpretation happens. When writing HTML, -the "&" is converted to "&", so in the raw output you'd see -"&mdash;". There's no difference in interpretation for text -inside or outside inline literals or literal blocks -- there's no -character entity interpretation in either case. - -If you can't use a Unicode-compatible encoding and must rely on 7-bit -ASCII, there is a workaround: +If you are restricted to 7-bit ASCII or a legacy encoding, +there is a workaround: `Standard Substitution Definition Sets`_ provide equivalents of XML & HTML character entity sets as substitution definitions. [#]_ For example, the Japanese yen currency symbol can be used as follows:: @@ -302,9 +263,7 @@ |yen| 600 for a complete meal? That's cheap! -.. [#] Thanks to David Priest for the original idea. - -You can create custom `substitution definitions`_ in your document +You can also create custom `substitution definitions`_ in your document using the "unicode_" directive, e.g.:: .. |--| unicode:: U+2013 .. en dash @@ -322,6 +281,15 @@ thus you need to add spaces ("``foo |---| bar``") and advise the reStructuredText parser to trim the spaces. +.. [#] reStructuredText doesn't know anything about XML character + entities. To Docutils, "—" in input text is 7 discrete + characters; no interpretation happens. When writing HTML, the + "&" is converted to "``&``", so in the raw output you'd see + "``&mdash;``" and in the HTML browser "—". + +.. [#] Thanks to David Priest for the original idea. + +.. _input encoding: docs/user/config.html#input-encoding .. _Standard Substitution Definition Sets: docs/ref/rst/definitions.html .. _substitution definitions: docs/ref/rst/restructuredtext.html #substitution-definitions @@ -382,8 +350,7 @@ ----------------------------------------------------------------------- People have tossed the idea around, and some implementations of -reStructuredText-generating tools can be found in the `Docutils Link -List`_. +reStructuredText-generating tools can be found in the `Docutils Links`_. There's no reason why reStructuredText should not be round-trippable to/from XML; any technicalities which prevent round-tripping would be @@ -399,44 +366,19 @@ tool that does 80% of the work automatically, leaving the other 20% for manual tweaks. -.. _Docutils Link List: docs/user/links.html +.. _Docutils Link List: +.. _Docutils Links: docs/user/links.html Are there any Wikis that use reStructuredText syntax? ----------------------------------------------------- -There are several, with various degrees of completeness. With no -implied endorsement or recommendation, and in no particular order: +Yes, see `Wikis`__ in the `Docutils Links`_. -* `Ian Bicking's experimental code - <https://docutils.sourceforge.io/sandbox/ianb/wiki/Wiki.py>`__ +__ docs/user/links.html#wikis -* `MoinMoin <http://moinmoin.wikiwikiweb.de/>`__ has some support; - `here's a sample <http://moinmoin.wikiwikiweb.de/RestSample>`__ -* Zope-based `Zwiki <http://zwiki.org/>`__ -* Zope3-based Zwiki (in the Zope 3 source tree as - ``zope.products.zwiki``) - -* `StikiWiki <http://mithrandr.moria.org/code/stikiwiki/>`__ - -* `Trac <http://trac.edgewall.com//>`__ `supports using - reStructuredText - <http://trac.edgewall.com//wiki/WikiRestructuredText>`__ as - an alternative to wiki markup. This includes support for `TracLinks - <http://trac.edgewall.com//wiki/TracLinks>`__ from within - RST text via a custom RST reference-directive or, even easier, an - interpreted text role 'trac' - -Please `let us know`_ of any other reStructuredText Wikis. - -.. dead link -.. The example application for the `Web Framework Shootout -.. <http://colorstudy.com/docs/shootout.html>`__ article is a Wiki using -.. reStructuredText. - - Are there any Weblog (Blog) projects that use reStructuredText syntax? ---------------------------------------------------------------------- Modified: trunk/docutils/docs/howto/html-stylesheets.rst =================================================================== --- trunk/docutils/docs/howto/html-stylesheets.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/howto/html-stylesheets.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -61,7 +61,7 @@ __ https://developer.mozilla.org/en-US/docs/Web/CSS It is important that you do not edit a copy of ``html4css1.css`` -directly because ``html4css1.css`` is frequently updated with each new +directly because ``html4css1.css`` may be updated with a new release of Docutils. Also make sure that you import ``html4css1.css`` (using "``@import Modified: trunk/docutils/docs/ref/doctree.rst =================================================================== --- trunk/docutils/docs/ref/doctree.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/ref/doctree.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -4001,7 +4001,10 @@ _`%measure` | A number which may be immediately followed by a unit or percent sign. - Resolves to CDATA_. + ReStructuredText supports `CSS2 length units`_. + Handling of values without unit depends on the writer/output format + (see the writer specific documentation in the `user documentation`__ + for details). Resolves to CDATA_. | Used in the `height`_ and `width`_ attributes. Python data type: ``str``. _`%number` @@ -4028,7 +4031,9 @@ and `stub`_ attributes. Python data type: ``int``. +__ ../index.html#introductory-tutorial-material-for-end-users + Names and identifiers ===================== @@ -5312,6 +5317,7 @@ .. _bibliographic fields: rst/restructuredtext.html#bibliographic-fields .. _block quote: rst/restructuredtext.html#block-quotes .. _bullet list: rst/restructuredtext.html#bullet-lists +.. _CSS2 length units: rst/restructuredtext.html#length-units .. _citations: rst/restructuredtext.html#citations .. _definition list: rst/restructuredtext.html#definition-lists .. _directive: rst/restructuredtext.html#directives Modified: trunk/docutils/docs/ref/rst/directives.rst =================================================================== --- trunk/docutils/docs/ref/rst/directives.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/ref/rst/directives.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -2203,14 +2203,19 @@ A _`list of integers` may be comma- or whitespace-separated. -:_`length`: number followed by one of the supported `length units`_ +:_`length`: number, optionally followed by one of the + supported `length units`_ + Handling of values without unit depends on the writer/output format. + See the writer specific documentation in the `user doc`__ for details. + + __ ../../index.html#introductory-tutorial-material-for-end-users + :_`path`: local filesystem path Newlines are removed. The `root_prefix`_ configuration setting can be used to tell Docutils - to interpret root paths (starting with "/") relative to a "project - directory". + to interpret paths starting with "/" relative to a "project directory". :_`text`: free text @@ -2218,8 +2223,8 @@ :_`URI`: _`URI reference` - Full URI or `relative reference`_ (absolute or relative path reference), - cf. :RFC:`3986`. + Full URI or `relative reference`_ + (absolute or relative path reference, cf. :RFC:`3986`). Whitespace is removed (cf. `external hyperlink targets`_ in the reStructuredText specification). Modified: trunk/docutils/docs/ref/rst/restructuredtext.rst =================================================================== --- trunk/docutils/docs/ref/rst/restructuredtext.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/ref/rst/restructuredtext.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -490,18 +490,22 @@ title and possibly other metadata elements (author, date, etc.; see `Bibliographic Fields`_). -.. _document title: +Document Title +`````````````` -Specifically, there is no way to indicate a document title and subtitle -explicitly in reStructuredText. [#]_ Instead, a lone top-level `section -title`_ can be treated as the *document title*. Similarly, a lone -second-level section title immediately after the document title can -become the *document subtitle*. The rest of the sections are then lifted -up a level or two. See the `DocTitle transform`_ for details. +Specifically, there is no special syntax to indicate a *document title* +and *subtitle* in reStructuredText. [#]_ +Instead, a uniquely-adorned top-level `section title`_ can be treated as +the document title. Similarly, a uniquely-adorned second-level section +title immediately after the document title can become the document +subtitle. The rest of the sections are then lifted up a level or two. +See `A ReStructuredText Primer`__ for examples +and the `DocTitle transform`_ for details. .. [#] The `"title"`_ directive sets the document's `metadata title`_ that does not become part of the document body. +__ ../../user/rst/quickstart.html#document-title-subtitle Sections -------- @@ -3112,9 +3116,8 @@ https://www.w3.org/TR/css-values-3/#lengths .. _How to configure the size of a pixel: ../../user/latex.html#size-of-a-pixel -__ ../../user/ +__ ../../index.html#introductory-tutorial-material-for-end-users - Percentage Units ---------------- Modified: trunk/docutils/docs/user/config.rst =================================================================== --- trunk/docutils/docs/user/config.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/user/config.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -171,9 +171,9 @@ Configuration File Sections & Entries ------------------------------------- -Below are the Docutils `runtime settings`_, listed by config file section. -Sections correspond to Docutils components (module name -or alias; section names are always in lowercase letters). +Below are the Docutils runtime settings, listed by config file section. +Sections correspond to Docutils components (module name or alias; always +in lowercase letters). .. important:: Any setting may be specified in any section, but only settings from "`active sections`_" will be used. @@ -1080,6 +1080,8 @@ [html writers] -------------- +Common settings for the `Docutils HTML writers`_. + .. _attribution [html writers]: attribution @@ -2538,6 +2540,8 @@ .. _option lists: ../ref/rst/restructuredtext.html#option-lists .. _tables: ../ref/rst/restructuredtext.html#tables +.. _Docutils HTML writers: html.html + .. _front end tools: tools.html .. _buildhtml.py: tools.html#buildhtml-py Modified: trunk/docutils/docs/user/html.rst =================================================================== --- trunk/docutils/docs/user/html.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/user/html.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -6,6 +6,12 @@ .. contents:: +This document describes the HTML writers provided by Docutils. + +The default `length unit`_ in HTML is "px" (pixels, 1 px = 1/96 in). + +.. _length unit: ../ref/rst/restructuredtext.html#length-units + html ---- @@ -26,19 +32,58 @@ post-processing that may break otherwise. +html5 +----- + +:aliases: _`html5_polyglot` +:front-end: rst2html5_ +:config: `[html5 writer]`_ + +The *html5* writer generates valid XML that conforms to the +`HTML standard`_ (`polyglot HTML`_). [#safetext]_ +New features and elements are used if they are widely supported. +See the `HTML5 test page`_ (and the sources `html5-features.rst`_ and +`html5-text-level-tags.rst`_) for differences to the html4css1_ writer. + +There is no hard-coded formatting information in the HTML document. +Correct rendering of elements not directly supported by HTML depends on a +CSS_ style sheet. The provided style sheet minimal.css_ defines required +styling rules; plain.css_ and responsive.css_ add optional rules for +better legibility. Adaption of the layout is possible with `custom style +sheets`_. [#safetext]_ + +.. [#safetext] The validity of raw HTML and custom stylesheets must be + ensured by the author. + +.. _HTML5 test page: https://docutils.sourceforge.io/test/functional/ + expected/standalone_rst_html5.html#differences-to-the-html4css1-writer +.. _html5-features.rst: https://docutils.sourceforge.io/test/functional/ + input/data/html5-features.rst +.. _html5-text-level-tags.rst: https://docutils.sourceforge.io/test/functional/ + input/data/html5-text-level-tags.rst +.. _rst2html5: tools.html#rst2html5 +.. _[html5 writer]: config.html#html5-writer +.. _minimal.css: ../../docutils/writers/html5_polyglot/minimal.css +.. _plain.css: ../../docutils/writers/html5_polyglot/plain.css +.. _responsive.css: ../../docutils/writers/html5_polyglot/responsive.css +.. _custom style sheets: ../howto/html-stylesheets.html +.. _viewable with any browser: http://www.anybrowser.org/campaign +.. _Benefits of polyglot XHTML5: http://xmlplease.com/xhtml/xhtml5polyglot/ + + html4css1 --------- -:aliases: html4, html_ -:front-ends: rst2html4_, rst2html_ -:config: `[html4css1 writer]`_ +:aliases: html4, html_ +:front-end: rst2html4_ +:config: `[html4css1 writer]`_ The HTML Writer module, ``docutils/writers/html4css1.py``, was the first Docutils writer and up to release 0.13 the only official HTML writer. -The output conforms to the `XHTML 1 Transitional`_ specification. It does -not validate as `HTML 4.01 Transitional`_ due to the closing of empty tags -required in XML but not allowed in HTML 4. However, the output follows the +The output conforms to the `XHTML 1 Transitional`_ specification. It does +not validate as `HTML 4.01 Transitional`_ due to the closing of empty tags +required in XML but not allowed in HTML 4. However, the output follows the `HTML Compatibility Guidelines`_ for proper rendering on most HTML user agents. @@ -45,12 +90,17 @@ Correct rendering depends on a CSS_ style sheet. A reference style sheet, `html4css1.css`_, is provided and used by default. -To support the `Internet Explorer` (with a market share of about 90% around -2002, the time this writer was written), documents contain some hard-coded -formatting hints and are tagged as "text/html" (instead of -"application/xhtml+xml"). [#IE]_ +To support the `Internet Explorer` (with a market share of about 90% +around 2002, the time this writer was written), documents contain some +hard-coded formatting hints and are tagged as "text/html" (instead of +"application/xhtml+xml"). Additional class values serve as surrogate for +the "first"/"last" pseudo-classes introduced in CSS 2.1. [#IE]_ -.. [#IE] Conformance to `CSS 2.1`_ has been added in IE 8 (2009), support +Tables are used for description lists, field lists, docinfo, footnotes, +and option lists. Videos and SVG images are wrapped in <object> elements +and cannot be embedded. + +.. [#IE] Conformance to `CSS 2.1`_ has been added in IE 8 (2009), support for XHTML in IE 9 (2011). .. _rst2html: tools.html#rst2html @@ -62,7 +112,7 @@ ~~~~~~~~ :front-end: ``docutils --reader=pep --writer=pep_html`` -:config: `[pep_html writer]`_ +:config: `[pep_html writer]`_, `[html4css1 writer]`_ This is a special writer for the generation of `Python Enhancement Proposals`_ (PEPs). It inherits from html4css1_ and adds some `PEP-specific @@ -78,7 +128,7 @@ :alias: s5 :front-end: rst2s5_ -:config: `[s5_html writer]`_ +:config: `[s5_html writer]`_, `[html4css1 writer]`_ The `s5` writer inherits from html4css1_. It produces XHTML for use with S5_, the “Simple Standards-based Slide Show System” by Eric Meyer. See @@ -91,69 +141,12 @@ .. _theme: tools.html#themes -html5 ------ +3rd-party HTML writers +---------------------- -:aliases: _`html5_polyglot` -:front-end: rst2html5_ -:config: `[html5 writer]`_ +For additional HTML writers, see the `Docutils link list`__ +and the sandbox_. -The ``html5`` writer generates `polyglot HTML`_ output, valid -XML [#safetext]_ that is compatible with `HTML5`_. New features and elements -are used if they are widely supported. -See the `HTML5 test page`_ (and the sources `html5-features.rst`_ and -`html5-text-level-tags.rst`_) for further differences to the html4css1_ -writer. - -There is no hard-coded formatting information in the HTML document. -Correct rendering of elements not directly supported by HTML depends on a -CSS_ style sheet. The provided style sheet minimal.css_ defines required -styling rules; plain.css_ and responsive.css_ add optional rules for -better legibility. Adaption of the layout is possible with `custom style -sheets`_. [#safetext]_ - -New in Docutils 0.13 - -.. [#safetext] The validity of raw HTML and custom stylesheets must be - ensured by the author. -.. _HTML5 test page: https://docutils.sourceforge.io/test/functional/ - expected/standalone_rst_html5.html#changes-to-the-html4css1-writer -.. _html5-features.rst: https://docutils.sourceforge.io/test/functional/ - input/data/html5-features.rst -.. _html5-text-level-tags.rst: https://docutils.sourceforge.io/test/functional/ - input/data/html5-text-level-tags.rst -.. _rst2html5: tools.html#rst2html5 -.. _[html5 writer]: config.html#html5-writer -.. _minimal.css: ../../docutils/writers/html5_polyglot/minimal.css -.. _plain.css: ../../docutils/writers/html5_polyglot/plain.css -.. _responsive.css: ../../docutils/writers/html5_polyglot/responsive.css -.. _custom style sheets: ../howto/html-stylesheets.html -.. _viewable with any browser: http://www.anybrowser.org/campaign -.. _Benefits of polyglot XHTML5: http://xmlplease.com/xhtml/xhtml5polyglot/ - - -Overview --------- - -================ =========== ============== ================= =========== -name aliases `front-end`_ HTML version CSS version -================ =========== ============== ================= =========== -html4css1_ html4, rst2html4, `XHTML 1 `CSS 1`_ - html_ rst2html Transitional`_ - -pep_html_ .. rstpep2html `XHTML 1 `CSS 1`_ - Transitional`_ - -s5_html_ s5 rst2s5 `XHTML 1 `CSS 1`_ - Transitional`_ - -html5_polyglot_ html5 rst2html5 `HTML5`_ `CSS 3`_ - -================ =========== ============== ================= =========== - -For additional alternatives, see the `Docutils link list`__ and the -sandbox_. - __ https://docutils.sourceforge.io/docs/user/links.html #website-generators-and-html-variants .. _sandbox: ../dev/policies.html#the-sandbox @@ -162,16 +155,10 @@ References ---------- -_`HTML5` - `HTML5, A vocabulary and associated APIs for HTML and XHTML`, - W3C Recommendation, 28 October 2014. - https://www.w3.org/TR/2014/REC-html5-20141028/ +_`HTML Standard` + `HTML Living Standard`. + https://html.spec.whatwg.org/multipage/ -_`XHTML 1.1` - `XHTML™ 1.1 - Module-based XHTML - Second Edition`, - W3C Recommendation, 23 November 2010. - https://www.w3.org/TR/xhtml11/ - _`XHTML 1 Transitional` `Transitional version`_ of: `XHTML™ 1.0 The Extensible HyperText Markup Language (Second @@ -179,15 +166,7 @@ W3C Recommendation, 26 January 2000, revised 1 August 2002. https://www.w3.org/TR/xhtml1/ -_`XHTML Basic` - `XHTML™ Basic 1.1 - Second Edition`, - W3C Recommendation, 23 November 2010. - https://www.w3.org/TR/xhtml-basic/ - -.. _transitional version: - https://www.w3.org/TR/xhtml1/#a_dtd_XHTML-1.0-Transitional - -_`HTML 4.01 Transitional` +_`HTML 4.01 Transitional` Transitional version of: `HTML 4.01 Specification`, W3C Recommendation 24 December 1999. https://www.w3.org/TR/html4/ @@ -194,33 +173,37 @@ .. _`CSS 1`: -_`CSS Level 1`: +_`CSS Level 1`: The features defined in the `CSS1 specification`_, but using the syntax and definitions in the `CSS 2.1`_ specification. -_`CSS 2.1` `Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification`, +_`CSS 2.1` + `Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification`, W3C Recommendation 07 June 2011. https://www.w3.org/TR/CSS21/ -_`CSS 3`: - CSS Level 3 builds on CSS Level 2 module by module, using the CSS2.1 +_`CSS 3`: + CSS Level 3 builds on CSS Level 2 module by module, using the CSS 2.1 specification as its core. - Specifications: https://www.w3.org/Style/CSS/specs.en.html + | Specifications: https://www.w3.org/Style/CSS/specs.en.html + | Validator: http://jigsaw.w3.org/css-validator/ - Validator: http://jigsaw.w3.org/css-validator/ - .. other references ---------------- .. _HTML Compatibility Guidelines: https://www.w3.org/TR/xhtml1/#guidelines -.. _CSS: https://www.w3.org/TR/CSS/ -.. _CSS1 specification: https://www.w3.org/TR/2008/REC-CSS1-20080411/ +.. _transitional version: + https://www.w3.org/TR/xhtml1/#a_dtd_XHTML-1.0-Transitional + .. _polyglot HTML: https://www.w3.org/TR/html-polyglot/ .. Beware. This specification is no longer in active maintenance and the HTML Working Group does not intend to maintain it further. +.. _CSS: https://www.w3.org/TR/CSS/ +.. _CSS1 specification: https://www.w3.org/TR/2008/REC-CSS1-20080411/ + .. Appendix Modified: trunk/docutils/docs/user/latex.rst =================================================================== --- trunk/docutils/docs/user/latex.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/user/latex.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -100,6 +100,9 @@ :sp: scaled point (1sp = 1/65536pt) :bp: "big" point (`DTP point`) (1 bp = 1/72 in) +The **default length unit** (added by the latex writer to length +values without unit) is the `DTP point` "bp". + .. attention:: Different definitions of the unit "pt"! * In Docutils (as well as CSS) the unit symbol "pt" denotes the @@ -118,9 +121,6 @@ In `raw LaTeX`_ and `custom style sheets`_, the `DTP point` must be specified as "bp", while "pt" is interpreted as `LaTeX point`. -The default length unit (added by Docutils to length specifications -without unit) is the "DTP point". - .. _length units: ../ref/rst/restructuredtext.html#length-units Modified: trunk/docutils/docs/user/links.rst =================================================================== --- trunk/docutils/docs/user/links.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/user/links.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -14,16 +14,17 @@ .. contents:: -This document contains links users of Docutils and reStructuredText -may find useful. Many of the projects -listed here are hosted in the `Docutils Sandbox`_. If you have -something to publish, you can get write access, too! +This document contains links that users of Docutils_ and reStructuredText_ +may find useful. The most current version of this link list can always be found at https://docutils.sourceforge.io/docs/user/links.html. +If you find outdated or broken links or want to suggest additions, +please `let us know`__ and we'll update the list here. .. _Docutils: https://docutils.sourceforge.io/ -.. _Docutils Sandbox: https://docutils.sourceforge.io/sandbox/README.html +.. _reStructuredText: https://docutils.sourceforge.io/rst.html +__ mailing-lists.html#docutils-users Editors @@ -45,7 +46,7 @@ plugin for Vim that emulates two-pane outliner with support for reStructuredText (since version 4.0b2). - - `Riv: Take notes in rst <https://github.com/Rykka/riv.vim>`__ Vim + - `Riv: Take notes in rST <https://github.com/Rykka/riv.vim>`__ Vim plugin to take notes in reStructured text. * `reStructuredText Language Support for Visual Studio Code`__ @@ -279,7 +280,7 @@ .. _DashTable: https://github.com/gustavklopp/DashTable -* Sphinx_ includes a `LaTeX to Rst converter +* Sphinx_ includes a `LaTeX to rST converter <https://svn.python.org/projects/doctools/converter/>`__ in its source code (trimmed to importing the old Python docs). @@ -326,14 +327,14 @@ .. _rst2blogger: https://github.com/dhellmann/rst2blogger#readme +.. _Docutils Sandbox: https://docutils.sourceforge.io/sandbox/README.html + Related Applications -------------------- Applications using docutils/reStructuredText and helper applications. -* For Wikis, please see the `FAQ entry about Wikis`_. - * For Blogs (Weblogs), please see the `FAQ entry about Blogs`_. * `Project Gutenberg`_ uses Docutils for its "ebookmaker_" @@ -362,6 +363,31 @@ .. _repository: ../dev/repository.html +Wikis +````` + +* Trac_ supports `using reStructuredText`__ as an alternative to wiki markup. + This includes support for TracLinks_ from within reStructuredText + via a custom rST reference-directive or, even easier, an interpreted + text role "trac". + + __ http://trac.edgewall.com//wiki/WikiRestructuredText + +* MoinMoin_ includes a `ReStructuredText Parser + <http://moinmo.in/HelpOnParsers/ReStructuredText>`__. + +* Ian Bicking's experimental `wiki module`__ in the sandbox. + + __ https://docutils.sourceforge.io/sandbox/ianb/wiki + +* Zope-based Zwiki_ + (requires Zope2, which reached end of life on December 31, 2020). + +.. _TracLinks: http://trac.edgewall.com//wiki/TracLinks +.. _MoinMoin: http://moinmo.in/ +.. _ZWiki: https://github.com/simonmichael/ZWiki + + Tools ````` @@ -370,7 +396,7 @@ .. _rstcheck: https://pypi.python.org/pypi/rstcheck -* restview_ is a viewer for ReStructuredText documents. +* restview_ is a viewer for reStructuredText documents. Pass the name of a ReStructuredText document to restview, and it will launch a web server on localhost:random-port and open a web browser. It @@ -402,7 +428,7 @@ .. _Sphinx extensions: https://www.sphinx-doc.org/en/master/usage/extensions/ .. _Python documentation: https://docs.python.org/ -.. _Trac: https://trac.edgewall.org/ +.. _Trac: https://trac.edgewall.org .. _PyLit: https://codeberg.org/milde/pylit Modified: trunk/docutils/docs/user/rst/quickstart.rst =================================================================== --- trunk/docutils/docs/user/rst/quickstart.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/docs/user/rst/quickstart.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -329,10 +329,10 @@ may be formatted somewhat differently (e.g. the HTML writer by default shows it as a centered heading). -To indicate the document title in reStructuredText, use a unique adornment -style at the beginning of the document. To indicate the document subtitle, -use another unique adornment style immediately after the document title. For -example:: +To indicate the document title in reStructuredText, use a section title +with unique adornment style at the beginning of the document. +To indicate the document subtitle, use another unique adornment style +immediately after the document title. For example:: ================ Document Title @@ -351,7 +351,29 @@ overline-and-underlined titles (but not underlined-only) may be inset for aesthetics. +Counterexample:: + Here's an ordinary paragraph. + + This is *not* a Document Title + ============================== + + The "ordinary paragraph" above the section title + prevents it from becoming the document title. + +Another counterexample:: + + This is not the Document Title, because... + =========================================== + + Here's an ordinary paragraph. + + ... the title adornment is not unique + ===================================== + + Another ordinary paragraph. + + Images ------ Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2024-09-10 15:30:31 UTC (rev 9923) @@ -1283,7 +1283,7 @@ </li> <li><p>Set table column widths with <style="width: ...">, not "width" argument.</p></li> <li><p>Horizontal alignment of table heads with CSS.</p></li> -<li><p>Do not drop paragraph objects, use CSS rules to prevent unwanted vertical +<li><p>Do not drop paragraph elements, use CSS rules to prevent unwanted vertical space.</p></li> <li><p>Put subtitles in <p> elements.</p></li> <li><p>Use the new semantic tags <main>, <section>, <header>, Modified: trunk/docutils/test/functional/input/data/html5-features.rst =================================================================== --- trunk/docutils/test/functional/input/data/html5-features.rst 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/docutils/test/functional/input/data/html5-features.rst 2024-09-10 15:30:31 UTC (rev 9923) @@ -14,7 +14,7 @@ * Horizontal alignment of table heads with CSS. -* Do not drop paragraph objects, use CSS rules to prevent unwanted vertical +* Do not drop paragraph elements, use CSS rules to prevent unwanted vertical space. * Put subtitles in <p> elements. Modified: trunk/sandbox/stylesheets/index.txt =================================================================== --- trunk/sandbox/stylesheets/index.txt 2024-09-10 08:01:52 UTC (rev 9922) +++ trunk/sandbox/stylesheets/index.txt 2024-09-10 15:30:31 UTC (rev 9923) @@ -3,7 +3,7 @@ ======================= :Author: Lea Wiemann and others -:Contact: LeW...@gm... +:Contact: doc...@li... :Revision: $Revision$ :Date: $Date$ :Copyright: This document has been placed in the public domain. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gr...@us...> - 2024-09-10 08:01:54
|
Revision: 9922 http://sourceforge.net/p/docutils/code/9922 Author: grubert Date: 2024-09-10 08:01:52 +0000 (Tue, 10 Sep 2024) Log Message: ----------- FIX change hard coded uris to f-string expansions Modified Paths: -------------- trunk/docutils/test/test_writers/test_html4css1.py Modified: trunk/docutils/test/test_writers/test_html4css1.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1.py 2024-09-04 19:33:39 UTC (rev 9921) +++ trunk/docutils/test/test_writers/test_html4css1.py 2024-09-10 08:01:52 UTC (rev 9922) @@ -517,8 +517,8 @@ .. image:: {DATA_ROOT.as_uri()}/circle-broken.svg :loading: embed """, -"""\ -<object data="file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg" type="image/svg+xml">file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg</object> +f"""\ +<object data="{DATA_ROOT.as_uri()}/circle-broken.svg" type="image/svg+xml">{DATA_ROOT.as_uri()}/circle-broken.svg</object> """ ], [r"""Broken :math:`\sin \my`. @@ -583,8 +583,8 @@ .. image:: {DATA_ROOT.as_uri()}/circle-broken.svg :loading: embed """, -"""\ -<object data="file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg" type="image/svg+xml">file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg</object> +f"""\ +<object data="{DATA_ROOT.as_uri()}/circle-broken.svg" type="image/svg+xml">{DATA_ROOT.as_uri()}/circle-broken.svg</object> """], [r'Broken :math:`\sin \my`.', '<p>Broken <tt class="math">\\sin \\my</tt>.</p>\n' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-04 19:33:42
|
Revision: 9921 http://sourceforge.net/p/docutils/code/9921 Author: milde Date: 2024-09-04 19:33:39 +0000 (Wed, 04 Sep 2024) Log Message: ----------- Revise `HTMLTranslator.prepare_svg()`. Change oder of method arguments (sort by importance). Use a dictionary to update the `<svg style="..."> declarations keeping exisisting declarations intact. Simplify conversion of "align" attribute. Add test cases. Modified Paths: -------------- trunk/docutils/docutils/writers/_html_base.py trunk/docutils/test/test_writers/test_html5_polyglot.py trunk/docutils/test/test_writers/test_html5_polyglot_misc.py Modified: trunk/docutils/docutils/writers/_html_base.py =================================================================== --- trunk/docutils/docutils/writers/_html_base.py 2024-09-04 19:33:30 UTC (rev 9920) +++ trunk/docutils/docutils/writers/_html_base.py 2024-09-04 19:33:39 UTC (rev 9921) @@ -28,7 +28,7 @@ import urllib.parse import urllib.request import warnings -import xml.etree.ElementTree as ET # TODO: lazy import in prepare_svg()? +import xml.etree.ElementTree as ET from pathlib import Path from typing import TYPE_CHECKING @@ -474,39 +474,36 @@ return None return imgsize - def prepare_svg(self, node, imagedata, size_declaration): - # Edit `imagedata` for embedding as SVG image. - # Use ElementTree to add node attributes. - # ET also removes comments and preamble code. + def prepare_svg(self, code: str, node: nodes.Element, atts: dict) -> str: + # Parse SVG source `code` (ignoring comments and preamble code), + # add relevant attributes from `node` and `atts` to the root element. # - # Internal: interface and behaviour may change without notice. - - # SVG namespace + # Internal auxiliary method called from `self.visit_image()`. svg_ns = {'': 'http://www.w3.org/2000/svg', - 'xlink': 'http://www.w3.org/1999/xlink'} + 'xlink': 'http://www.w3.org/1999/xlink'} # SVG namespace # don't add SVG namespace to all elements - ET.register_namespace('', svg_ns['']) - ET.register_namespace('xlink', svg_ns['xlink']) + for key, value in svg_ns.items(): + ET.register_namespace(key, value) + # Parse: try: - svg = ET.fromstring(imagedata) + svg = ET.fromstring(code) except ET.ParseError as err: self.messages.append(self.document.reporter.error( f'Cannot parse SVG image "{node["uri"]}":\n {err}', base_node=node)) - return imagedata - # apply image node attributes: - if size_declaration: # append to style, replacing width & height - declarations = [d.strip() for d in svg.get('style', '').split(';')] - declarations = [d for d in declarations - if d - and not d.startswith('width') - and not d.startswith('height')] - svg.set('style', '; '.join(declarations+[size_declaration])) - if node['classes'] or 'align' in node: + return code + # Apply image node attributes: + if 'style' in atts: + # update style declarations + style_att = f"{svg.get('style', '')}; {atts['style']}" + style_att = [d.partition(':') for d in style_att.split(';') + if d.strip()] + style_att = dict((k.strip(), v.strip()) for k, p, v in style_att) + style_att = ' '.join(f'{k}: {v};' for k, v in style_att.items()) + svg.set('style', style_att) + if 'classes' in atts or node['classes']: classes = svg.get('class', '').split() - classes += node.get('classes', []) - if 'align' in node: - classes.append(f'align-{node["align"]}') + classes += node['classes'] + atts.get('classes', []) svg.set('class', ' '.join(classes)) if 'alt' in node and svg.find('title', svg_ns) is None: svg_title = ET.Element('title') @@ -598,7 +595,7 @@ infix = ' /' else: infix = '' - return ''.join(prefix) + '<%s%s>' % (' '.join(parts), infix) + suffix + return f"{''.join(prefix)}<{' '.join(parts)}{infix}>{suffix}" def emptytag(self, node, tagname, suffix='\n', **attributes): """Construct and return an XML-compatible empty tag.""" @@ -1173,14 +1170,11 @@ mimetype = mimetypes.guess_type(uri)[0] element = '' # the HTML element (including potential children) atts = {} # attributes for the HTML tag - # alignment is handled by CSS rules - if 'align' in node: - atts['class'] = 'align-%s' % node['align'] - # set size with "style" attribute (more universal, accepts dimensions) size_declaration = self.image_size(node) if size_declaration: atts['style'] = size_declaration - + if 'align' in node: + atts['classes'] = [f"align-{node['align']}"] # ``:loading:`` option (embed, link, lazy), default from setting, # exception: only embed videos if told via directive option loading = 'link' if mimetype in self.videotypes else self.image_loading @@ -1201,8 +1195,7 @@ else: self.settings.record_dependencies.add(imagepath) if mimetype == 'image/svg+xml': - element = self.prepare_svg(node, imagedata, - size_declaration) + element = self.prepare_svg(imagedata, node, atts) else: data64 = base64.b64encode(imagedata).decode() uri = f'data:{mimetype};base64,{data64}' Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-04 19:33:30 UTC (rev 9920) +++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-04 19:33:39 UTC (rev 9921) @@ -2,9 +2,10 @@ # $Id$ # Author: reggie dugard <re...@us...> +# Maintainer: doc...@li... # Copyright: This module has been placed in the public domain. -"""Test HTML5 writer output ("fragment" part). +"""Test HTML5 writer output ("fragment"/"body" part). This is the document body (not HTML <body>). """ @@ -89,7 +90,7 @@ self.assertEqual(case_expected, parts['body']) -totest = {} +totest = {} # expected samples contain only the "body" part of the HMTL output totest['standard'] = ({}, [ ["""\ @@ -147,6 +148,18 @@ </div> """, ], +[f"""\ +.. image:: {DATA_ROOT.as_uri()}/circle.svg + :loading: embed + :width: 50% + :height: 30 + :align: left +""", +"""\ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" style="width: 50%; height: 30px;" class="align-left"> + <circle cx="5" cy="5" r="4" fill="lightblue" /> +</svg> +"""], ]) Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-09-04 19:33:30 UTC (rev 9920) +++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-09-04 19:33:39 UTC (rev 9921) @@ -247,6 +247,19 @@ settings = frontend.get_default_settings(_html_base.Writer) document = utils.new_document('test data', settings) translator = _html_base.HTMLTranslator(document) + svg_sample = """\ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" + style="background: blue; width: 5ex" viewBox="0 0 10 10"> + <circle cx="5" cy="5" r="4" fill="lightblue" /> + <!-- comments are ignored --> +</svg> +""" + expected = """\ +<svg xmlns="http://www.w3.org/2000/svg" style="background: blue; width: 4em; height: 32px;" viewBox="0 0 10 10" class="test me"> + <title>blue circle</title><circle cx="5" cy="5" r="4" fill="lightblue" /> + \n\ +</svg>""" def test_image_size(self): image = nodes.image(height='3', width='4em') @@ -256,6 +269,27 @@ self.assertEqual(self.translator.image_size(image), 'width: 2em; height: 1.5px;') + def test_prepare_svg(self): + # Internal method: the test is no guaranty for stability, + # interface and behaviour may change without notice. + image = nodes.image(height='32', width='4em', alt='blue circle', + align='left', classes=['test', 'me']) + atts = {'style': self.translator.image_size(image)} + rv = self.translator.prepare_svg(self.svg_sample, image, atts) + self.assertEqual(rv, self.expected) + def test_prepare_svg_syntax_variants(self): + # parsing "style" declarations must be robust: + svg_sample = '<svg style="width:3em"></svg>' + + atts = {'style': 'colon:in:value'} + rv = self.translator.prepare_svg(svg_sample, nodes.image(), atts) + self.assertEqual(rv, '<svg style="width: 3em; colon: in:value;" />') + + atts = {'style': 'no-colon;'} + rv = self.translator.prepare_svg(svg_sample, nodes.image(), atts) + self.assertEqual(rv, '<svg style="width: 3em; no-colon: ;" />') + + if __name__ == '__main__': unittest.main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-04 19:33:33
|
Revision: 9920 http://sourceforge.net/p/docutils/code/9920 Author: milde Date: 2024-09-04 19:33:30 +0000 (Wed, 04 Sep 2024) Log Message: ----------- Refactor `HTMLTranslator.image_size()`. Use `nodes.parse_measure()` instead of ad-hoc parsing when scaling size values. Split "spaghetti code" into auxiliary method `read_size_with_PIL()`. Modified Paths: -------------- trunk/docutils/docutils/writers/_html_base.py trunk/docutils/test/test_writers/test_html5_polyglot.py trunk/docutils/test/test_writers/test_html5_polyglot_misc.py Modified: trunk/docutils/docutils/writers/_html_base.py =================================================================== --- trunk/docutils/docutils/writers/_html_base.py 2024-09-04 19:33:12 UTC (rev 9919) +++ trunk/docutils/docutils/writers/_html_base.py 2024-09-04 19:33:30 UTC (rev 9920) @@ -14,18 +14,23 @@ # # .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause -"""common definitions for Docutils HTML writers""" +"""Common definitions for Docutils HTML writers.""" +from __future__ import annotations + +__docformat__ = 'reStructuredText' + import base64 import mimetypes import os import os.path -from pathlib import Path import re import urllib.parse import urllib.request import warnings import xml.etree.ElementTree as ET # TODO: lazy import in prepare_svg()? +from pathlib import Path +from typing import TYPE_CHECKING import docutils from docutils import frontend, languages, nodes, utils, writers @@ -36,6 +41,10 @@ unichar2tex, wrap_math_code, MathError) +if TYPE_CHECKING: + from numbers import Real + + class Writer(writers.Writer): supported = ('html', 'xhtml') # update in subclass @@ -404,58 +413,67 @@ text = str(text) return text.translate(self.special_characters) - def image_size(self, node): - # Determine the image size from the node arguments or the image file. - # Return a size declaration suitable as "style" argument value, - # e.g., ``'width: 4px; height: 2em;'``. - # TODO: consider feature-request #102? - size = [node.get('width', None), node.get('height', None)] - if 'scale' in node: - if 'width' not in node or 'height' not in node: - # try reading size from image file - reading_problems = [] - uri = node['uri'] - if not PIL: - reading_problems.append('Requires Python Imaging Library.') - if mimetypes.guess_type(uri)[0] in self.videotypes: - reading_problems.append('PIL cannot read video images.') - if not self.settings.file_insertion_enabled: - reading_problems.append('Reading external files disabled.') - if not reading_problems: - try: - imagepath = self.uri2imagepath(uri) - with PIL.Image.open(imagepath) as img: - imgsize = img.size - except (ValueError, OSError, UnicodeEncodeError) as err: - reading_problems.append(str(err)) - else: - self.settings.record_dependencies.add( - imagepath.replace('\\', '/')) - if reading_problems: - msg = ['Cannot scale image!', - f'Could not get size from "{uri}":', - *reading_problems] - self.messages.append(self.document.reporter.warning( - '\n '.join(msg), base_node=node)) - else: - for i in range(2): - size[i] = size[i] or '%dpx' % imgsize[i] - # scale provided/determined size values: - factor = float(node['scale']) / 100 - for i in range(2): - if size[i]: - match = re.match(r'([0-9.]+)(\S*)$', size[i]) - size[i] = '%s%s' % (factor * float(match.group(1)), - match.group(2)) - size_declarations = [] - for i, dimension in enumerate(('width', 'height')): - if size[i]: - # Interpret unitless values as pixels: - if re.match(r'^[0-9.]+$', size[i]): - size[i] += 'px' - size_declarations.append(f'{dimension}: {size[i]};') - return ' '.join(size_declarations) + def image_size(self, node: nodes.image) -> str: + """Determine the image size from node arguments or the image file. + Auxiliary method called from `self.visit_image()`. + + Provisional. + """ + # TODO: Use "width" and "hight" for unitless integers? + # [feature-requests:#102] + + # List with optional width and height measures ((value, unit)-tuples) + measures: list[tuple[Real, str] | None] = [None, None] + dimensions = ('width', 'height') + for i, dimension in enumerate(dimensions): + if dimension in node: + measures[i] = nodes.parse_measure(node[dimension]) + if None in measures and 'scale' in node: + # supplement with (unitless) values read from image file + imgsize = self.read_size_with_PIL(node) + if imgsize: + measures = [measure or (imgvalue, '') + for measure, imgvalue in zip(measures, imgsize)] + # scale values + factor = node.get('scale', 100) / 100 # scaling factor + if factor != 1: + measures = [(measure[0] * factor, measure[1]) + for measure in measures if measure] + # format as CSS declarations and return + return ' '.join(f'{dimension}: {measure[0]:g}{measure[1] or "px"};' + for dimension, measure in zip(dimensions, measures) + if measure) + + def read_size_with_PIL(self, node) -> tuple[int, int] | None: + # Try reading size from image file. + # Internal auxiliary method called from `self.image_size()`. + reading_problems = [] + uri = node['uri'] + if not PIL: + reading_problems.append('Requires Python Imaging Library.') + if mimetypes.guess_type(uri)[0] in self.videotypes: + reading_problems.append('PIL cannot read video images.') + if not self.settings.file_insertion_enabled: + reading_problems.append('Reading external files disabled.') + if not reading_problems: + try: + imagepath = self.uri2imagepath(uri) + with PIL.Image.open(imagepath) as img: + imgsize = img.size + except (ValueError, OSError, UnicodeEncodeError) as err: + reading_problems.append(str(err)) + else: + self.settings.record_dependencies.add(imagepath) + if reading_problems: + msg = ['Cannot scale image!', + f'Could not get size from "{uri}":', + *reading_problems] + self.messages.append(self.document.reporter.warning( + '\n '.join(msg), base_node=node)) + return None + return imgsize + def prepare_svg(self, node, imagedata, size_declaration): # Edit `imagedata` for embedding as SVG image. # Use ElementTree to add node attributes. @@ -607,7 +625,7 @@ child['classes'].append(class_) def uri2imagepath(self, uri): - """Get filesystem path corresponding to an URI. + """Get POSIX filesystem path corresponding to an URI. The image directive expects an image URI__. Some writers require the corresponding image path to read the image size from the file or to Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-04 19:33:12 UTC (rev 9919) +++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-09-04 19:33:30 UTC (rev 9920) @@ -46,7 +46,7 @@ if (tuple(int(i) for i in PIL.__version__.split('.')) >= (10, 3)): DUMMY_PNG_NOT_FOUND = ("[Errno 2] No such file or directory: '%s'" % Path('dummy.png').resolve()) - SCALING_OUTPUT = 'style="width: 32.0px; height: 32.0px;" ' + SCALING_OUTPUT = 'style="width: 32px; height: 32px;" ' NO_PIL_SYSTEM_MESSAGE = '' else: REQUIRES_PIL = '\n Requires Python Imaging Library.' Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-09-04 19:33:12 UTC (rev 9919) +++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-09-04 19:33:30 UTC (rev 9920) @@ -18,8 +18,8 @@ # so we import the local `docutils` package. sys.path.insert(0, str(Path(__file__).resolve().parents[2])) -from docutils import core -from docutils.writers import html5_polyglot +from docutils import core, frontend, nodes, utils +from docutils.writers import html5_polyglot, _html_base # TEST_ROOT is ./test/ from the docutils root TEST_ROOT = Path(__file__).parents[1] @@ -241,5 +241,21 @@ self.assertNotIn('MathJax', head) +class ImagesTestCase(unittest.TestCase): + """Test image handling routines.""" + + settings = frontend.get_default_settings(_html_base.Writer) + document = utils.new_document('test data', settings) + translator = _html_base.HTMLTranslator(document) + + def test_image_size(self): + image = nodes.image(height='3', width='4em') + self.assertEqual(self.translator.image_size(image), + 'width: 4em; height: 3px;') + image = nodes.image(height='3', width='4em', scale=50) + self.assertEqual(self.translator.image_size(image), + 'width: 2em; height: 1.5px;') + + if __name__ == '__main__': unittest.main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-04 19:33:14
|
Revision: 9919 http://sourceforge.net/p/docutils/code/9919 Author: milde Date: 2024-09-04 19:33:12 +0000 (Wed, 04 Sep 2024) Log Message: ----------- New function `nodes.parse_measure()`. Relax `validate_measure()`. Allow "arbitrary" units: Check for a run of ASCII-letters or a percent sign. (The definition of "measure" in docutils.dtd and its description in doctree.txt do not include a restriction of the valid units.) Modified Paths: -------------- trunk/docutils/HISTORY.rst trunk/docutils/docutils/nodes.py trunk/docutils/docutils/parsers/rst/directives/__init__.py trunk/docutils/test/test_nodes.py trunk/docutils/test/test_parsers/test_docutils_xml/test_parse_element.py Modified: trunk/docutils/HISTORY.rst =================================================================== --- trunk/docutils/HISTORY.rst 2024-09-04 06:16:29 UTC (rev 9918) +++ trunk/docutils/HISTORY.rst 2024-09-04 19:33:12 UTC (rev 9919) @@ -63,6 +63,7 @@ convert string representations to correct data type, normalize values, raise ValueError for invalid attribute names or values. + - New function `parse_measure()`. - Removed `Element.set_class()`. * docutils/parsers/docutils_xml.py Modified: trunk/docutils/docutils/nodes.py =================================================================== --- trunk/docutils/docutils/nodes.py 2024-09-04 06:16:29 UTC (rev 9918) +++ trunk/docutils/docutils/nodes.py 2024-09-04 19:33:12 UTC (rev 9919) @@ -3074,6 +3074,22 @@ return '"%s"' % value +def parse_measure(measure: str) -> tuple[float, str]: + """Parse a measure__, return value + optional unit. + + __ https://docutils.sourceforge.io/docs/ref/doctree.html#measure + + Provisional. + """ + match = re.fullmatch('(-?[0-9.]+) *([a-zA-Zµ]*|%?)', measure) + try: + value = float(match.group(1)) + unit = match.group(2) + except (AttributeError, ValueError): + raise ValueError(f'"{measure}" is no valid measure.') + return value, unit + + # Methods to validate `Element attribute`__ values. # Ensure the expected Python `data type`__, normalize, and check for @@ -3139,24 +3155,25 @@ return value -def validate_measure(value: str) -> str: +def validate_measure(measure: str) -> str: """ - Validate a length measure__ (number + recognized unit). + Validate a measure__ (number + optional unit). Return normalized `str`. - __ https://docutils.sourceforge.io/docs/ref/doctree.html#measure + See `parse_measure()` for a function returning a "number + unit" tuple. + The unit may be any run of letters or a percent sign. + Provisional. + + __ https://docutils.sourceforge.io/docs/ref/doctree.html#measure """ - units = 'em|ex|px|in|cm|mm|pt|pc|%' - if not re.fullmatch(f'[-0-9.]+ *({units}?)', value): - raise ValueError(f'"{value}" is no valid measure. ' - f'Valid units: {units.replace("|", " ")}.') - return value.replace(' ', '').strip() + value, unit = parse_measure(measure) + return f'{value:g}{unit}' def validate_NMTOKEN(value: str) -> str: """ - Validate a "name token": a `str` of letters, digits, and [-._]. + Validate a "name token": a `str` of ASCII letters, digits, and [-._]. Provisional. """ Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py =================================================================== --- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2024-09-04 06:16:29 UTC (rev 9918) +++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2024-09-04 19:33:12 UTC (rev 9919) @@ -261,8 +261,8 @@ float(match.group(1)) except (AttributeError, ValueError): raise ValueError( - 'not a positive measure of one of the following units:\n%s' - % ' '.join('"%s"' % i for i in units)) + 'not a positive measure of one of the following units:\n"%s"' + % '" "'.join(units)) return match.group(1) + match.group(2) Modified: trunk/docutils/test/test_nodes.py =================================================================== --- trunk/docutils/test/test_nodes.py 2024-09-04 06:16:29 UTC (rev 9918) +++ trunk/docutils/test/test_nodes.py 2024-09-04 19:33:12 UTC (rev 9919) @@ -502,11 +502,10 @@ node.validate() def test_validate_wrong_attribute_value(self): - node = nodes.image(uri='test.png', width='20 inch') # invalid unit + node = nodes.image(uri='test.png', width='1in 3pt') with self.assertRaisesRegex(nodes.ValidationError, 'Element <image.*> invalid:\n' - '.*"width" has invalid value "20 inch".\n' - '.*Valid units: em ex '): + '.*"width" has invalid value "1in 3pt".'): node.validate() def test_validate_spurious_element(self): @@ -1114,7 +1113,25 @@ self.assertEqual(nodes.split_name_list(r'a\ n\ame two\\ n\\ames'), ['a name', 'two\\', r'n\ames']) + def test_parse_measure(self): + # measure is number + optional unit (letter(s) or percentage) + self.assertEqual(nodes.parse_measure('8ex'), (8, 'ex')) + self.assertEqual(nodes.parse_measure('2.5'), (2.5, '')) + self.assertEqual(nodes.parse_measure('-2s'), (-2, 's')) + self.assertEqual(nodes.parse_measure('2 µF'), (2, 'µF')) + self.assertEqual(nodes.parse_measure('10 EUR'), (10, 'EUR')) + self.assertEqual(nodes.parse_measure('.5 %'), (.5, '%')) + # scientific notation not supported + with self.assertRaisesRegex(ValueError, '"3e-4 mm" is no valid '): + nodes.parse_measure('3e-4 mm') + # unit must follow the number + with self.assertRaisesRegex(ValueError, '"EUR 23" is no valid '): + nodes.parse_measure('EUR 23') + # only single percent sign allowed + with self.assertRaisesRegex(ValueError, '"2%%" is no valid measure'): + nodes.parse_measure('2%%') + class AttributeTypeTests(unittest.TestCase): """Test validator functions for the supported `attribute data types`__ @@ -1154,17 +1171,19 @@ nodes.validate_identifier_list(s2) def test_validate_measure(self): - # number (may be decimal fraction) + optional CSS2 length unit + # number (may be decimal fraction) + optional unit self.assertEqual(nodes.validate_measure('8ex'), '8ex') + self.assertEqual(nodes.validate_measure('2'), '2') + # internal whitespace is removed self.assertEqual(nodes.validate_measure('3.5 %'), '3.5%') - self.assertEqual(nodes.validate_measure('2'), '2') - with self.assertRaisesRegex(ValueError, '"2km" is no valid measure. ' - 'Valid units: em ex '): - nodes.validate_measure('2km') - # negative numbers are currently not supported - # TODO: allow? the spec doesnot mention negative numbers. - # but a negative width or height of an image is odd. - # nodes.validate_measure('-2') + # padding whitespace is not valid + with self.assertRaisesRegex(ValueError, '"8ex " is no valid measure'): + nodes.validate_measure('8ex ') + # Negative numbers: + # * ``doctree.txt`` does not mention negative numbers, + # * in rST, negative numbers are not valid. + # Provisional: currently valid but may become invalid! + # self.assertEqual(nodes.validate_measure('-2'), '-2') def test_validate_NMTOKEN(self): # str with ASCII-letters, digits, hyphen, underscore, and full-stop. Modified: trunk/docutils/test/test_parsers/test_docutils_xml/test_parse_element.py =================================================================== --- trunk/docutils/test/test_parsers/test_docutils_xml/test_parse_element.py 2024-09-04 06:16:29 UTC (rev 9918) +++ trunk/docutils/test/test_parsers/test_docutils_xml/test_parse_element.py 2024-09-04 19:33:12 UTC (rev 9919) @@ -93,12 +93,10 @@ """ xml = ('<image breadth="3 cm" height="3 inch"/>') node = docutils_xml.parse_element(xml) - self.assertEqual(xml, str(node)) + self.assertEqual(xml.replace('3 inch', '3inch'), str(node)) with self.assertRaisesRegex(ValueError, 'Element <image breadth="3 cm".*invalid:\n' - '.*"breadth" not one of "ids",.*\n' - '.*"height" has invalid value "3 inch".\n' - '.*Valid units: em ex px in cm mm pt ' + '.*"breadth" not one of "ids", ' ): node.validate() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-04 06:16:32
|
Revision: 9918 http://sourceforge.net/p/docutils/code/9918 Author: milde Date: 2024-09-04 06:16:29 +0000 (Wed, 04 Sep 2024) Log Message: ----------- Fixes for `nodes.Node` and `_html_base.SimpleListChecker` Ensure that all methods and attributes that are common to `nodes.Element` and `nodes.Text` are also defined in the abstract base class `nodes.Node`. Rename the node validation hook `check_position()` to `validate_position()` to indicate its relation to element validation. Define `_html_base.SimpleListChecker.default_departure` (as required per documentation in `nodes.GenericNodeVisitor`). Fixup for [r9901] Modified Paths: -------------- trunk/docutils/docutils/nodes.py trunk/docutils/docutils/writers/_html_base.py Modified: trunk/docutils/docutils/nodes.py =================================================================== --- trunk/docutils/docutils/nodes.py 2024-09-03 09:35:59 UTC (rev 9917) +++ trunk/docutils/docutils/nodes.py 2024-09-04 06:16:29 UTC (rev 9918) @@ -71,7 +71,7 @@ class Node: """Abstract base class of nodes in a document tree.""" - parent: Node = None + parent: Element | None = None """Back-reference to the Node immediately containing this Node.""" children: Sequence[Node] = () @@ -398,7 +398,16 @@ Override in subclasses that define validity constraints. """ + def validate_position(self) -> None: + """Hook for additional checks of the parent's content model. + Raise ValidationError, if `self` is at an invalid position. + + Override in subclasses with complex validity constraints. See + `subtitle.validate_position()` and `transition.validate_position()`. + """ + + class Text(Node, str): # NoQA: SLOT000 (Node doesn't define __slots__) """ Instances are terminal nodes (leaves) containing text only; no child @@ -1120,10 +1129,7 @@ def clear(self) -> None: self.children = [] - def replace(self, - old: Node, - new: Node | Iterable[Node], - ) -> None: + def replace(self, old: Node, new: Node | Iterable[Node]) -> None: """Replace one child `Node` with another child or children.""" index = self.index(old) if isinstance(new, Node): @@ -1318,10 +1324,7 @@ continue # try same child with next part of content model else: # Check additional placement constraints (if applicable): - try: - child.check_position() - except AttributeError: - pass + child.validate_position() # advance: if quantifier in ('.', '?'): # go to next element child = next(ichildren, None) @@ -1330,7 +1333,7 @@ if not isinstance(child, category): break try: - child.check_position() + child.validate_position() except AttributeError: pass else: @@ -1355,13 +1358,6 @@ return (f'{msg} Expecting child of type <{_type}>, ' f'not {child.starttag()}.') - def check_position(self) -> None: - """Hook for additional checks of the parent's content model. - - Raise ValidationError, if `self` is at an invalid position. - See `subtitle.check_position()` and `transition.check_position()`. - """ - def validate(self, recursive: bool = True) -> None: """Validate Docutils Document Tree element ("doctree"). @@ -1601,7 +1597,7 @@ class subtitle(Titular, PreBibliographic, SubStructural, TextElement): """Sub-title of `document`, `section` and `sidebar`.""" - def check_position(self) -> None: + def validate_position(self) -> None: """Check position of subtitle: must follow a title.""" if self.parent and self.parent.index(self) == 0: raise ValidationError(f'Element {self.parent.starttag()} invalid:' @@ -1645,7 +1641,7 @@ __ https://docutils.sourceforge.io/docs/ref/doctree.html#transition """ - def check_position(self) -> None: + def validate_position(self) -> None: """Check additional constraints on `transition` placement. A transition may not begin or end a section or document, @@ -1697,7 +1693,7 @@ ((topic, Body), '+'), ) # ((title, subtitle?)?, (%body.elements; | topic)+) - # "subtitle only after title" is ensured in `subtitle.check_position()`. + # "subtitle only after title" is ensured in `subtitle.validate_position()`. class section(Structural, Element): @@ -1714,7 +1710,7 @@ ((section, transition), '*'), ) # (title, subtitle?, %structure.model;) -# Correct transition placement is ensured in `transition.check_position()`. +# Correct transition placement is ensured in `transition.validate_position()`. # Root Element @@ -1743,7 +1739,7 @@ # (docinfo, transition?)?, # %structure.model; ) # Additional restrictions for `subtitle` and `transition` are tested - # with the respective `check_position()` methods. + # with the respective `validate_position()` methods. def __init__(self, settings: Values, Modified: trunk/docutils/docutils/writers/_html_base.py =================================================================== --- trunk/docutils/docutils/writers/_html_base.py 2024-09-03 09:35:59 UTC (rev 9917) +++ trunk/docutils/docutils/writers/_html_base.py 2024-09-04 06:16:29 UTC (rev 9918) @@ -1831,6 +1831,9 @@ def default_visit(self, node): raise nodes.NodeFound + def default_departure(self, node): + pass + def visit_list_item(self, node): children = [child for child in node.children if not isinstance(child, nodes.Invisible)] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-09-03 09:36:01
|
Revision: 9917 http://sourceforge.net/p/docutils/code/9917 Author: milde Date: 2024-09-03 09:35:59 +0000 (Tue, 03 Sep 2024) Log Message: ----------- Update documentation of `uri2imagepath()` method. Update wording around `URI references`__. Cf. [r9883]. __ https://www.rfc-editor.org/rfc/rfc3986.html#section-4.1 Modified Paths: -------------- trunk/docutils/docutils/writers/_html_base.py Modified: trunk/docutils/docutils/writers/_html_base.py =================================================================== --- trunk/docutils/docutils/writers/_html_base.py 2024-08-21 13:45:27 UTC (rev 9916) +++ trunk/docutils/docutils/writers/_html_base.py 2024-09-03 09:35:59 UTC (rev 9917) @@ -609,18 +609,21 @@ def uri2imagepath(self, uri): """Get filesystem path corresponding to an URI. - The image directive expects an image URI. Some writers require the + The image directive expects an image URI__. Some writers require the corresponding image path to read the image size from the file or to embed the image in the output. - Absolute URIs consider the "root_prefix" setting. + URIs with absolute "path" part consider the ``root_prefix`` setting. - In order to work in the output document, relative image URIs relate - to the output directory. For access by the writer, the corresponding - image path must be relative to the current working directory. + In order to work in the output document, URI references with relative + path relate to the output directory. For access by the writer, the + corresponding image path must be relative to the current working + directory. Provisional: the function's location, interface and behaviour may change without advance warning. + + __ https://www.rfc-editor.org/rfc/rfc3986.html """ destination = self.settings._destination or '' uri_parts = urllib.parse.urlparse(uri) @@ -630,7 +633,7 @@ if imagepath.startswith('/'): # cf. config.html#root-prefix root_prefix = Path(self.settings.root_prefix) imagepath = (root_prefix/imagepath[1:]).as_posix() - elif not os.path.isabs(imagepath): # exclude absolute Windows paths + elif not os.path.isabs(imagepath): # path may be absolute Windows path destdir = os.path.abspath(os.path.dirname(destination)) imagepath = utils.relative_path(None, os.path.join(destdir, imagepath)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-21 13:45:30
|
Revision: 9916 http://sourceforge.net/p/docutils/code/9916 Author: milde Date: 2024-08-21 13:45:27 +0000 (Wed, 21 Aug 2024) Log Message: ----------- Refactor HTML4 writer tests. New test script "test_html4css1.py": Split basic output tests (which happen to use the "fragment" returned by `publish_parts()` to get the interesting part of the output) from other tests of `publish_parts()` Really test all returned parts in "test_html4css1_parts.py". Cf. "Refactor HTML5 writer tests". Modified Paths: -------------- trunk/docutils/test/test_writers/test_html4css1_parts.py Added Paths: ----------- trunk/docutils/test/test_writers/test_html4css1.py Added: trunk/docutils/test/test_writers/test_html4css1.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1.py (rev 0) +++ trunk/docutils/test/test_writers/test_html4css1.py 2024-08-21 13:45:27 UTC (rev 9916) @@ -0,0 +1,596 @@ +#! /usr/bin/env python3 + +# $Id$ +# Author: reggie dugard <re...@us...> +# Copyright: This module has been placed in the public domain. + +"""Test HTML4 writer output ("fragment" part). + +This is the document body (not HTML <body>). +""" + +from pathlib import Path +import re +import sys +import unittest + +if __name__ == '__main__': + # prepend the "docutils root" to the Python library path + # so we import the local `docutils` package. + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + +import docutils +import docutils.core +from docutils.utils.code_analyzer import with_pygments +from docutils.writers import html4css1 + +if with_pygments: + import pygments + _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__) + if (int(_pv[1]), int(_pv[2])) >= (2, 14): + # pygments output changed in version 2.14 + with_pygments = False + +# TEST_ROOT is ./test/ from the docutils root +TEST_ROOT = Path(__file__).parents[1] +DATA_ROOT = TEST_ROOT / 'data' +ROOT_PREFIX = (TEST_ROOT / 'functional/input').as_posix() + + +class Html5WriterPublishPartsTestCase(unittest.TestCase): + """Test case for HTML5 writer via the publish_parts() interface.""" + + maxDiff = None + + def test_publish(self): + if not with_pygments: + del totest['syntax_highlight'] + for name, (settings_overrides, cases) in totest.items(): + for casenum, (case_input, case_expected) in enumerate(cases): + with self.subTest(id=f'totest[{name!r}][{casenum}]'): + parts = docutils.core.publish_parts( + source=case_input, + writer=html4css1.Writer(), + settings_overrides={ + '_disable_config': True, + 'strict_visitor': True, + 'stylesheet_path': '', + 'section_self_link': True, + **settings_overrides, + } + ) + self.assertEqual(case_expected, parts['body']) + + +totest = {} + +totest['standard'] = ({}, [ +["""\ +Simple String +""", +'<p>Simple String</p>\n', +], +["""\ +Simple String with *markup* +""", +'<p>Simple String with <em>markup</em></p>\n', +], +["""\ +Simple String with an even simpler ``inline literal`` +""", +'<p>Simple String with an even simpler <tt class="docutils literal">inline literal</tt></p>\n', +], +["""\ +A simple `anonymous reference`__ + +__ http://www.test.com/test_url +""", +'<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\n', +], +["""\ +One paragraph. + +Two paragraphs. +""", +"""\ +<p>One paragraph.</p> +<p>Two paragraphs.</p> +""", +], +["""\ +A simple `named reference`_ with stuff in between the +reference and the target. + +.. _`named reference`: http://www.test.com/test_url +""", +"""\ +<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the +reference and the target.</p> +""", +], +["""\ +.. [CIT2022] A citation. +""", +"""\ +<table class="docutils citation" frame="void" id="cit2022" rules="none"> +<colgroup><col class="label" /><col /></colgroup> +<tbody valign="top"> +<tr><td class="label">[CIT2022]</td><td>A citation.</td></tr> +</tbody> +</table> +""", +], +]) + + +totest['no_title_promotion'] = ({'doctitle_xform': False}, [ +["""\ ++++++ +Title ++++++ + +Not A Subtitle +============== + +Some stuff + +Section +------- + +Some more stuff + +Another Section +............... + +And even more stuff +""", +"""\ +<div class="section" id="title"> +<h1>Title</h1> +<div class="section" id="not-a-subtitle"> +<h2>Not A Subtitle</h2> +<p>Some stuff</p> +<div class="section" id="section"> +<h3>Section</h3> +<p>Some more stuff</p> +<div class="section" id="another-section"> +<h4>Another Section</h4> +<p>And even more stuff</p> +</div> +</div> +</div> +</div> +""", +], +["""\ +* bullet +* list +""", +"""\ +<ul class="simple"> +<li>bullet</li> +<li>list</li> +</ul> +""", +], +["""\ +.. table:: + :align: right + + +-----+-----+ + | 1 | 2 | + +-----+-----+ + | 3 | 4 | + +-----+-----+ +""", +"""\ +<table border="1" class="docutils align-right"> +<colgroup> +<col width="50%" /> +<col width="50%" /> +</colgroup> +<tbody valign="top"> +<tr><td>1</td> +<td>2</td> +</tr> +<tr><td>3</td> +<td>4</td> +</tr> +</tbody> +</table> +""", +], +["""\ +Not a docinfo. + +:This: .. _target: + + is +:a: +:simple: +:field: list +""", +"""\ +<p>Not a docinfo.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p> +</td> +</tr> +<tr class="field"><th class="field-name">a:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td> +</tr> +</tbody> +</table> +""", +], +["""\ +Not a docinfo. + +:This is: a +:simple field list with loooong field: names +""", +"""\ +<p>Not a docinfo.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">This is:</th><td class="field-body">a</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">simple field list with loooong field:</th></tr> +<tr class="field"><td> </td><td class="field-body">names</td> +</tr> +</tbody> +</table> +""", +], +["""\ +Not a docinfo. + +.. class:: field-indent-200 + +:This: is a +:simple: field list with custom indent. +""", +"""\ +<p>Not a docinfo.</p> +<table class="field-indent-200 docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">This:</th><td class="field-body">is a</td> +</tr> +<tr class="field"><th class="field-name">simple:</th><td class="field-body">field list with custom indent.</td> +</tr> +</tbody> +</table> +""", +], +["""\ +Not a docinfo. + +.. class:: field-indent-200uf + +:This: is a +:simple: field list without custom indent, + because the unit "uf" is invalid. +""", +"""\ +<p>Not a docinfo.</p> +<table class="field-indent-200uf docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">This:</th><td class="field-body">is a</td> +</tr> +<tr class="field"><th class="field-name">simple:</th><td class="field-body">field list without custom indent, +because the unit "uf" is invalid.</td> +</tr> +</tbody> +</table> +""", +], +["""\ +.. figure:: dummy.png + + The figure's caption. + + A legend. + + The legend's second paragraph. +""", +"""\ +<div class="figure"> +<img alt="dummy.png" src="dummy.png" /> +<p class="caption">The figure's caption.</p> +<div class="legend"> +<p>A legend.</p> +<p>The legend's second paragraph.</p> +</div> +</div> +""", +], +["""\ +.. figure:: dummy.png + + The figure's caption, no legend. +""", +"""\ +<div class="figure"> +<img alt="dummy.png" src="dummy.png" /> +<p class="caption">The figure's caption, no legend.</p> +</div> +""", +], +["""\ +.. figure:: dummy.png + + .. + + A legend without caption. +""", +"""\ +<div class="figure"> +<img alt="dummy.png" src="dummy.png" /> +<div class="legend"> +A legend without caption.</div> +</div> +""", +], +["""\ +.. figure:: dummy.png + +No caption nor legend. +""", +"""\ +<div class="figure"> +<img alt="dummy.png" src="dummy.png" /> +</div> +<p>No caption nor legend.</p> +""", +], +[f"""\ +.. include:: {DATA_ROOT}/multiple-term-definition.xml + :parser: xml +""", +"""\ +<dl class="docutils"> +<dt>New in Docutils 0.22</dt> +<dd><p class="first">A definition list item may contain several +terms with optional classifier(s).</p> +<p class="last">However, there is currently no corresponding +reStructuredText syntax.</p> +</dd> +<dt>term 2a</dt> +<dt>term 2b</dt> +<dd>definition 2</dd> +<dt>term 3a <span class="classifier-delimiter">:</span> <span class="classifier">classifier 3a</span> <span class="classifier-delimiter">:</span> <span class="classifier">classifier 3aa</span><dt>term 3b <span class="classifier-delimiter">:</span> <span class="classifier">classifier 3b</span></dt> +<dd>definition 3</dd> +</dl> +""", +], +]) + + +totest['lazy_loading'] = ({'image_loading': 'lazy', + 'report_level': 4}, [ +["""\ +Lazy loading by default, overridden by :loading: option +("cannot embed" warning ignored). + +.. image:: dummy.png +.. image:: dummy.png + :loading: link +.. figure:: dummy.png +.. figure:: dummy.png + :loading: embed +""", +"""\ +<p>Lazy loading by default, overridden by :loading: option +("cannot embed" warning ignored).</p> +<img alt="dummy.png" src="dummy.png" /> +<img alt="dummy.png" src="dummy.png" /> +<div class="figure"> +<img alt="dummy.png" src="dummy.png" /> +</div> +<div class="figure"> +<img alt="dummy.png" src="dummy.png" /> +</div> +""", +], +]) + + +totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX, + 'image_loading': 'embed', + 'warning_stream': '', + }, [ +["""\ +.. image:: /data/blue%20square.png + :scale: 100% +.. figure:: /data/blue%20square.png +""", +"""\ +<img alt="/data/blue%20square.png" src="/data/blue%20square.png" style="width: 32.0px; height: 32.0px;" /> +<div class="figure"> +<img alt="/data/blue%20square.png" src="/data/blue%20square.png" /> +</div> +""" +], +]) + + +totest['no_backlinks'] = ({'footnote_backlinks': False}, [ + +["""\ +Two footnotes [#f1]_ [#f2]_ and two citations [once]_ [twice]_. + +The latter are referenced a second time [#f2]_ [twice]_. + +.. [#f1] referenced once +.. [#f2] referenced twice +.. [once] citation referenced once +.. [twice] citation referenced twice +""", +"""\ +<p>Two footnotes <a class="footnote-reference" href="#f1" id="footnote-reference-1">[1]</a> <a class="footnote-reference" href="#f2" id="footnote-reference-2">[2]</a> and two citations <a class="citation-reference" href="#once" id="citation-reference-1">[once]</a> <a class="citation-reference" href="#twice" id="citation-reference-2">[twice]</a>.</p> +<p>The latter are referenced a second time <a class="footnote-reference" href="#f2" id="footnote-reference-3">[2]</a> <a class="citation-reference" href="#twice" id="citation-reference-3">[twice]</a>.</p> +<table class="docutils footnote" frame="void" id="f1" rules="none"> +<colgroup><col class="label" /><col /></colgroup> +<tbody valign="top"> +<tr><td class="label">[1]</td><td>referenced once</td></tr> +</tbody> +</table> +<table class="docutils footnote" frame="void" id="f2" rules="none"> +<colgroup><col class="label" /><col /></colgroup> +<tbody valign="top"> +<tr><td class="label">[2]</td><td>referenced twice</td></tr> +</tbody> +</table> +<table class="docutils citation" frame="void" id="once" rules="none"> +<colgroup><col class="label" /><col /></colgroup> +<tbody valign="top"> +<tr><td class="label">[once]</td><td>citation referenced once</td></tr> +</tbody> +</table> +<table class="docutils citation" frame="void" id="twice" rules="none"> +<colgroup><col class="label" /><col /></colgroup> +<tbody valign="top"> +<tr><td class="label">[twice]</td><td>citation referenced twice</td></tr> +</tbody> +</table> +""", +], +]) + + +totest['syntax_highlight'] = ({'syntax_highlight': 'short', + }, [ +["""\ +.. code:: shell + + cat <<EOF + Hello World + EOF +""", +"""\ +<pre class="code shell literal-block"> +cat <span class="s"><<EOF +Hello World +EOF</span> +</pre> +""", +], +["""\ +.. role:: shell(code) + :language: shell + +:shell:`cat <<EOF Hello World EOF` +""", +"""\ +<p><code class="shell">cat <span class="s"><<EOF Hello World EOF</span></code></p> +""", +], +]) + + +totest['system_messages'] = ({'math_output': 'mathml', + 'warning_stream': '', + }, [ +# No warning with HTML4 ("embed" error is silently ignored). +["""\ +.. image:: https://dummy.png + :loading: embed +""", +"""\ +<img alt="https://dummy.png" src="https://dummy.png" /> +""", +], +# No error with HTML4 (silently ignored) +[f"""\ +.. image:: {DATA_ROOT.as_uri()}/circle-broken.svg + :loading: embed +""", +"""\ +<object data="file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg" type="image/svg+xml">file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg</object> +""" +], +[r"""Broken :math:`\sin \my`. +""", +"""\ +<p>Broken <span class="math problematic">\\sin \\my</span>.</p> +<div class="system-message"> +<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils"><string></tt>, line 1)</p> +Unknown LaTeX command "\\my".</div> +"""], +]) + +totest['system_messages-PIL'] = ({'math_output': 'mathml', + 'warning_stream': '', + }, [ +["""\ +.. image:: dummy.png + :scale: 100% + :loading: embed +""", +"""\ +<img alt="dummy.png" src="dummy.png" /> +""", +], +["""\ +.. image:: dummy.mp4 + :scale: 100% +""", +"""\ +<object data="dummy.mp4" type="video/mp4">dummy.mp4</object> +""", +], +["""\ +.. image:: https://dummy.png + :scale: 100% + :loading: embed +""", +"""\ +<img alt="https://dummy.png" src="https://dummy.png" /> +""", +], +]) + +totest['no_system_messages'] = ({'math_output': 'mathml', + 'report_level': 4, + 'warning_stream': '', + }, [ +["""\ +.. image:: dummy.png + :scale: 100% + :loading: embed + +.. image:: dummy.mp4 + :scale: 100% +""", +"""\ +<img alt="dummy.png" src="dummy.png" /> +<object data="dummy.mp4" type="video/mp4">dummy.mp4</object> +""", +], +[f"""\ +.. image:: {DATA_ROOT.as_uri()}/circle-broken.svg + :loading: embed +""", +"""\ +<object data="file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg" type="image/svg+xml">file:///usr/local/src/docutils-git-svn/docutils/test/data/circle-broken.svg</object> +"""], +[r'Broken :math:`\sin \my`.', +'<p>Broken <tt class="math">\\sin \\my</tt>.</p>\n' +], +]) + + +if __name__ == '__main__': + unittest.main() Property changes on: trunk/docutils/test/test_writers/test_html4css1.py ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Modified: trunk/docutils/test/test_writers/test_html4css1_parts.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1_parts.py 2024-08-21 13:45:18 UTC (rev 9915) +++ trunk/docutils/test/test_writers/test_html4css1_parts.py 2024-08-21 13:45:27 UTC (rev 9916) @@ -5,11 +5,9 @@ # Copyright: This module has been placed in the public domain. """ -Test for fragment code in HTML writer. +Test `core.publish_parts()`__ with the html4css1 writer. -Note: the 'body' and 'whole' entries have been removed from the parts -dictionaries (redundant), along with 'meta' and 'stylesheet' entries with -standard values, and any entries with empty values. +__ https://docutils.sourceforge.io/docs/api/publisher.html#publish-parts """ from pathlib import Path @@ -23,142 +21,145 @@ import docutils import docutils.core -from docutils.parsers.rst.directives.images import PIL from docutils.writers import html4css1 -ROOT_PREFIX = (Path(__file__).parent.parent/'functional'/'input').as_posix() -if PIL: - SCALING_OUTPUT = 'style="width: 32.0px; height: 32.0px;" ' -else: - SCALING_OUTPUT = '' +# TEST_ROOT is ./test/ from the docutils root +TEST_ROOT = Path(__file__).parents[1] +DATA_ROOT = TEST_ROOT / 'data' +ROOT_PREFIX = (TEST_ROOT / 'functional/input').as_posix() -class Html4WriterPublishPartsTestCase(unittest.TestCase): - """ - Test case for HTML writer via the publish_parts interface. - """ +# Parts returned by `publish_parts()` for the HTML5 writer by default: +# * empty input string +# * default configuration settings. +# See format_parts() below for the substitution of unresolved format markers. +default_parts = { + 'body': '{fragment}', + 'body_pre_docinfo': '', + 'body_prefix': '</head>\n<body>\n{header}<div class="document">\n', + 'body_suffix': '</div>\n{footer}</body>\n</html>\n', + 'docinfo': '', + 'encoding': 'utf-8', + 'errors': 'xmlcharrefreplace', + 'footer': '', + 'fragment': '', + 'head': '{meta}<title>{metatitle}</title>\n', + 'head_prefix': + '<?xml version="1.0" encoding="utf-8"?>\n' + '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' + ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n' + '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' + '<head>\n', + 'header': '', + 'html_body': '{header}<div class="document">\n{fragment}</div>\n{footer}', + 'html_head': '{meta}<title>{metatitle}</title>\n', + 'html_prolog': + '<?xml version="1.0" encoding="%s"?>\n' + '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' + ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n', + 'html_subtitle': '', + 'html_title': '', + 'meta': '<meta http-equiv="Content-Type" content="text/html; charset=%s" />\n' + f'<meta name="generator" content="Docutils {docutils.__version__}: https://docutils.sourceforge.io/" />\n', + 'stylesheet': '', + 'subtitle': '', + 'title': '', + 'version': f'{docutils.__version__}', + 'whole': + '{head_prefix}\n' + '{head}\n' + '{stylesheet}\n' + '{body_prefix}\n' + '{body_pre_docinfo}\n' + '{docinfo}\n' + '{body}\n' + '{body_suffix}\n', + } - maxDiff = None - def test_publish(self): - for name, (settings_overrides, cases) in totest.items(): - for casenum, (case_input, case_expected) in enumerate(cases): - with self.subTest(id=f'totest[{name!r}][{casenum}]'): - parts = docutils.core.publish_parts( - source=case_input, - writer=html4css1.Writer(), - settings_overrides={ - '_disable_config': True, - 'strict_visitor': True, - 'stylesheet_path': '', - **settings_overrides, - } - ) - # if the formatted output is a just single fragment, - # compare the text directly for a nicer diff on failure - formatted = self.format_output(parts) - if len(formatted) == 1 and 'fragment' in formatted: - fragment = formatted['fragment'] - self.assertEqual(case_expected, fragment) - else: - self.assertEqual(case_expected, formatted) +def format_parts(parts): + # fill in part values that depend on other parts + # https://docutils.sourceforge.io/docs/api/publisher.html#html4-writer - standard_content_type_template = ('<meta http-equiv="Content-Type"' - ' content="text/html; charset=%s" />\n') - standard_generator_template = ( - '<meta name="generator"' - f' content="Docutils {docutils.__version__}: ' - f'https://docutils.sourceforge.io/" />\n') - standard_html_meta_value = ( - standard_content_type_template - + standard_generator_template) - standard_meta_value = standard_html_meta_value % 'utf-8' - standard_html_prolog = ( - '<?xml version="1.0" encoding="%s"?>\n' - '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' - '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n') - standard_html_body_template = '<div class="document">\n%s</div>\n' + # metadata title: either the visible title or document['source'] + metatitle = parts['title'] or '<string>' - def format_output(self, parts): - """Minimize & standardize the output.""" - # remove redundant parts & uninteresting parts: - del parts['whole'] - assert parts['body'] == parts['fragment'] - del parts['body'] - del parts['body_pre_docinfo'] - del parts['body_prefix'] - del parts['body_suffix'] - del parts['head'] - del parts['head_prefix'] - del parts['encoding'] - del parts['errors'] - del parts['version'] - # remove standard portions: - parts['meta'] = parts['meta'].replace(self.standard_meta_value, '') - parts['html_head'] = parts['html_head'].replace( - self.standard_html_meta_value, '...') - parts['html_head'] = parts['html_head'].replace( - '...<title><string></title>\n', '') - parts['html_prolog'] = parts['html_prolog'].replace( - self.standard_html_prolog, '') - parts['html_body'] = parts['html_body'].replace( - self.standard_html_body_template % parts['fragment'], '') - # remove empty keys and return - return {k: v for k, v in parts.items() if v} + # "html_head" leaves the encoding unresolved, as "%s": + parts['html_head'] = parts['html_head'].format(metatitle=metatitle, + **parts) + # now resolve encoding: + try: + parts['meta'] = parts['meta'] % parts['encoding'] + except TypeError: # charset-<meta> missing if encoding is 'unicode' + pass + parts['head'] = parts['head'].format(metatitle=metatitle, **parts) + parts['body_prefix'] = parts['body_prefix'].format(**parts) + parts['body'] = parts['body'].format(**parts) + parts['body_suffix'] = parts['body_suffix'].format(**parts) + parts['html_body'] = parts['html_body'].format(**parts) + # newlines are stripped when parts are used to expand the template file + parts['whole'] = parts['whole'].format(**{k: v.rstrip('\n') + for k, v in parts.items()}) + return parts -totest = {} +class Html5WriterPublishPartsTestCase(unittest.TestCase): + """Test HTML5 writer `publish_parts()` interface.""" -totest['title_promotion'] = ({}, [ -["""\ -Simple String -""", -'<p>Simple String</p>\n', -], -["""\ -Simple String with *markup* -""", -'<p>Simple String with <em>markup</em></p>\n', -], -["""\ -Simple String with an even simpler ``inline literal`` -""", -'<p>Simple String with an even simpler <tt class="docutils literal">inline literal</tt></p>\n', -], -["""\ -Simple ``inline\xA0literal`` with NBSP -""", -'<p>Simple <tt class="docutils literal">inline literal</tt> with NBSP</p>\n', -], -["""\ -A simple `anonymous reference`__ + maxDiff = None -__ http://www.test.com/test_url -""", -'<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\n', -], -["""\ -One paragraph. + def test_publish_parts(self): + for name, (settings_overrides, cases) in totest.items(): + for casenum, (case_input, expected_parts) in enumerate(cases): + _stgns = {'_disable_config': True, + 'strict_visitor': True, + 'stylesheet_path': '', + 'section_self_link': True, + **settings_overrides, + } + parts = docutils.core.publish_parts(source=case_input, + writer=html4css1.Writer(), + settings_overrides=_stgns, + ) + expected = format_parts(default_parts | expected_parts) + for key in parts.keys(): + with self.subTest(id=f'totest[{name!r}][{casenum}][{key}]'): + self.assertEqual(f'{expected[key]}', + f'{parts[key]}') -Two paragraphs. -""", -"""\ -<p>One paragraph.</p> -<p>Two paragraphs.</p> -""", -], -["""\ -A simple `named reference`_ with stuff in between the -reference and the target. -.. _`named reference`: http://www.test.com/test_url -""", -"""\ -<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the -reference and the target.</p> -""", -], -["""\ +totest = {} + +totest['standard'] = ({}, [ + ['', # empty input string + {} # results in default parts + ], + ['Simple String with *markup*', + {'fragment': '<p>Simple String with <em>markup</em></p>\n'} + ], + ['.. header:: custom document header\n\n' + 'A paragraph.', + {'header': '<div class="header">\ncustom document header\n' + '<hr class="header"/>\n</div>\n', + 'body_prefix': '</head>\n' + '<body>\n' + '<div class="header">\n' + 'custom document header\n' + '<hr class="header"/>\n' + '</div>\n' + '<div class="document">\n', + 'fragment': '<p>A paragraph.</p>\n', + } + ], + ['.. footer:: custom document footer\n\n' + 'A paragraph.', + {'footer': '<div class="footer">\n' + '<hr class="footer" />\n' + 'custom document footer\n</div>\n', + 'fragment': '<p>A paragraph.</p>\n', + } + ], + ["""\ +++++ Title +++++ @@ -178,7 +179,10 @@ And even more stuff """, -{'fragment': """\ + {'body_pre_docinfo': '<h1 class="title">Title</h1>\n' + '<h2 class="subtitle" id="subtitle">Subtitle</h2>\n', + 'body_prefix': '</head>\n<body>\n<div class="document" id="title">\n', + 'fragment': """\ <p>Some stuff</p> <div class="section" id="section"> <h1>Section</h1> @@ -189,7 +193,8 @@ </div> </div> """, - 'html_body': """<div class="document" id="title"> + 'html_body': """\ +<div class="document" id="title"> <h1 class="title">Title</h1> <h2 class="subtitle" id="subtitle">Subtitle</h2> <p>Some stuff</p> @@ -203,13 +208,12 @@ </div> </div> """, - 'html_head': '...<title>Title</title>\n', - 'html_subtitle': '<h2 class="subtitle" id="subtitle">Subtitle</h2>\n', - 'html_title': '<h1 class="title">Title</h1>\n', - 'subtitle': 'Subtitle', - 'title': 'Title' -}], -["""\ + 'html_subtitle': '<h2 class="subtitle" id="subtitle">Subtitle</h2>\n', + 'html_title': '<h1 class="title">Title</h1>\n', + 'subtitle': 'Subtitle', + 'title': 'Title' + }], + ["""\ +++++ Title +++++ @@ -218,7 +222,10 @@ Some stuff """, -{'docinfo': """<table class="docinfo" frame="void" rules="none"> + {'body_pre_docinfo': '<h1 class="title">Title</h1>\n', + 'body_prefix': '</head>\n<body>\n<div class="document" id="title">\n', + 'docinfo': """\ +<table class="docinfo" frame="void" rules="none"> <col class="docinfo-name" /> <col class="docinfo-content" /> <tbody valign="top"> @@ -227,8 +234,9 @@ </tbody> </table> """, - 'fragment': '<p>Some stuff</p>\n', - 'html_body': """<div class="document" id="title"> + 'fragment': '<p>Some stuff</p>\n', + 'html_body': """\ +<div class="document" id="title"> <h1 class="title">Title</h1> <table class="docinfo" frame="void" rules="none"> <col class="docinfo-name" /> @@ -241,50 +249,14 @@ <p>Some stuff</p> </div> """, - 'html_head': """...<meta name="author" content="me" /> -<title>Title</title> -""", - 'html_title': '<h1 class="title">Title</h1>\n', - 'meta': '<meta name="author" content="me" />\n', - 'title': 'Title' -}] -]) + 'html_title': '<h1 class="title">Title</h1>\n', + 'meta': default_parts['meta'] + '<meta name="author" content="me" />\n', + 'title': 'Title' + }], + ]) totest['no_title_promotion'] = ({'doctitle_xform': False}, [ -["""\ -Simple String -""", -'<p>Simple String</p>\n', -], -["""\ -Simple String with *markup* -""", -'<p>Simple String with <em>markup</em></p>\n', -], -["""\ -Simple String with an even simpler ``inline literal`` -""", -'<p>Simple String with an even simpler <tt class="docutils literal">inline literal</tt></p>\n', -], -["""\ -A simple `anonymous reference`__ - -__ http://www.test.com/test_url -""", -'<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\n', -], -["""\ -A simple `named reference`_ with stuff in between the -reference and the target. - -.. _`named reference`: http://www.test.com/test_url -""", -"""\ -<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the -reference and the target.</p> -""", -], -["""\ + ["""\ +++++ Title +++++ @@ -304,7 +276,7 @@ And even more stuff """, -"""\ + {'fragment': """\ <div class="section" id="title"> <h1>Title</h1> <div class="section" id="not-a-subtitle"> @@ -320,109 +292,25 @@ </div> </div> </div> -""", -], -["""\ -* bullet -* list -""", -"""\ -<ul class="simple"> -<li>bullet</li> -<li>list</li> -</ul> -""", -], -["""\ -.. table:: - :align: right +"""}, + ], + ]) - +-----+-----+ - | 1 | 2 | - +-----+-----+ - | 3 | 4 | - +-----+-----+ -""", -"""\ -<table border="1" class="docutils align-right"> -<colgroup> -<col width="50%" /> -<col width="50%" /> -</colgroup> -<tbody valign="top"> -<tr><td>1</td> -<td>2</td> -</tr> -<tr><td>3</td> -<td>4</td> -</tr> -</tbody> -</table> -""", -], -["""\ -Not a docinfo. +totest['unknown-encoding'] = ({'output_encoding': 'unicode'}, [ + ['Simple String\n', + {'encoding': 'unicode', + 'fragment': '<p>Simple String</p>\n', + 'head_prefix': + '<?xml version="1.0"?>\n' + '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' + ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n' + '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' + '<head>\n', + 'html_head': f'{default_parts["meta"]}<title>{{metatitle}}</title>\n', + 'meta': f'<meta name="generator" content="Docutils {docutils.__version__}: https://docutils.sourceforge.io/" />\n', + }], + ]) -:This: .. _target: - is -:a: -:simple: -:field: list -""", -"""\ -<p>Not a docinfo.</p> -<table class="docutils field-list" frame="void" rules="none"> -<col class="field-name" /> -<col class="field-body" /> -<tbody valign="top"> -<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p> -</td> -</tr> -<tr class="field"><th class="field-name">a:</th><td class="field-body"></td> -</tr> -<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td> -</tr> -<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td> -</tr> -</tbody> -</table> -""", -], -["""\ -Not a docinfo. - -:This is: a -:simple field list with loooong field: names -""", -"""\ -<p>Not a docinfo.</p> -<table class="docutils field-list" frame="void" rules="none"> -<col class="field-name" /> -<col class="field-body" /> -<tbody valign="top"> -<tr class="field"><th class="field-name">This is:</th><td class="field-body">a</td> -</tr> -<tr class="field"><th class="field-name" colspan="2">simple field list with loooong field:</th></tr> -<tr class="field"><td> </td><td class="field-body">names</td> -</tr> -</tbody> -</table> -""", -], -]) - -totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX}, [ - -["""\ -.. image:: /data/blue%20square.png - :scale: 100% -""", -'<img alt="/data/blue%20square.png"' -f' src="/data/blue%20square.png" {SCALING_OUTPUT}/>\n', -], -]) - - if __name__ == '__main__': unittest.main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-21 13:45:21
|
Revision: 9915 http://sourceforge.net/p/docutils/code/9915 Author: milde Date: 2024-08-21 13:45:18 +0000 (Wed, 21 Aug 2024) Log Message: ----------- HTML4 writer: catch/report errors when reading image file. The html writers read image files when embedding an image or scaling an image without size options. Catch errors from converting the image URI to a file system path. Report errors as warning. Modified Paths: -------------- trunk/docutils/docutils/writers/html4css1/__init__.py Modified: trunk/docutils/docutils/writers/html4css1/__init__.py =================================================================== --- trunk/docutils/docutils/writers/html4css1/__init__.py 2024-08-21 13:45:08 UTC (rev 9914) +++ trunk/docutils/docutils/writers/html4css1/__init__.py 2024-08-21 13:45:18 UTC (rev 9915) @@ -571,12 +571,13 @@ if 'scale' in node: if (PIL and ('width' not in node or 'height' not in node) and self.settings.file_insertion_enabled): - imagepath = self.uri2imagepath(uri) try: + imagepath = self.uri2imagepath(uri) with PIL.Image.open(imagepath) as img: img_size = img.size - except (OSError, UnicodeEncodeError): - pass # TODO: warn/info? + except (ValueError, OSError, UnicodeEncodeError) as e: + self.document.reporter.warning( + f'Problem reading image file: {e}') else: self.settings.record_dependencies.add( imagepath.replace('\\', '/')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-21 13:45:11
|
Revision: 9914 http://sourceforge.net/p/docutils/code/9914 Author: milde Date: 2024-08-21 13:45:08 +0000 (Wed, 21 Aug 2024) Log Message: ----------- Use writer instances instead of names in test scripts. Calling the publisher convenience functions with a component instance instead of its name gives a slight speedup. Also, don't specify a component argument if it is the default. Modified Paths: -------------- trunk/docutils/test/test_dependencies.py trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py trunk/docutils/test/test_publisher.py trunk/docutils/test/test_traversals.py trunk/docutils/test/test_writers/test_docutils_xml.py trunk/docutils/test/test_writers/test_html4css1_misc.py trunk/docutils/test/test_writers/test_html4css1_parts.py trunk/docutils/test/test_writers/test_html4css1_template.py trunk/docutils/test/test_writers/test_html5_polyglot.py trunk/docutils/test/test_writers/test_html5_polyglot_misc.py trunk/docutils/test/test_writers/test_latex2e.py trunk/docutils/test/test_writers/test_latex2e_misc.py trunk/docutils/test/test_writers/test_manpage.py trunk/docutils/test/test_writers/test_null.py trunk/docutils/test/test_writers/test_odt.py trunk/docutils/test/test_writers/test_pseudoxml.py trunk/docutils/test/test_writers/test_s5.py Modified: trunk/docutils/test/test_dependencies.py =================================================================== --- trunk/docutils/test/test_dependencies.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_dependencies.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -23,6 +23,7 @@ import docutils.utils import docutils.io from docutils.parsers.rst.directives.images import PIL +from docutils.writers import html4css1, html5_polyglot, latex2e, docutils_xml TEST_ROOT = Path(__file__).parent # ./test/ from the docutils root DATA_ROOT = TEST_ROOT / 'data' @@ -76,7 +77,7 @@ if PIL and os.path.exists('../docs/user/rst/images/'): keys += ['figure-image'] expected = [paths[key] for key in keys] - record, _output = self.get_record(writer='xml') + record, _output = self.get_record(writer=docutils_xml.Writer()) # the order of the files is arbitrary self.assertEqual(sorted(expected), sorted(record)) @@ -89,7 +90,7 @@ settings = {'stylesheet_path': None, 'stylesheet': None, 'report_level': 4} # drop warning if PIL is missing - record, output = self.get_record(writer='html5', + record, output = self.get_record(writer=html5_polyglot.Writer(), settings_overrides=settings) # the order of the files is arbitrary self.assertEqual(sorted(expected), sorted(record), @@ -105,7 +106,7 @@ keys += ['figure-image'] expected = [paths[key] for key in keys] record, output = self.get_record( - writer='latex', + writer=latex2e.Writer(), settings_overrides=latex_settings_overwrites) # the order of the files is arbitrary self.assertEqual(sorted(expected), sorted(record), @@ -123,22 +124,22 @@ 'stylesheet': None} settings.update(latex_settings_overwrites) settings['embed_stylesheet'] = False - record, _output = self.get_record(writer='html', + record, _output = self.get_record(writer=html4css1.Writer(), settings_overrides=settings) self.assertTrue(stylesheet not in record, f'{stylesheet!r} should not be in {record!r}') - record, _output = self.get_record(writer='latex', + record, _output = self.get_record(writer=latex2e.Writer(), settings_overrides=settings) self.assertTrue(stylesheet not in record, f'{stylesheet!r} should not be in {record!r}') settings['embed_stylesheet'] = True - record, _output = self.get_record(writer='html', + record, _output = self.get_record(writer=html4css1.Writer(), settings_overrides=settings) self.assertTrue(stylesheet in record, f'{stylesheet!r} should be in {record!r}') settings['embed_stylesheet'] = True - record, _output = self.get_record(writer='latex', + record, _output = self.get_record(writer=latex2e.Writer(), settings_overrides=settings) self.assertTrue(stylesheet in record, f'{stylesheet!r} should be in {record!r}') Modified: trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py =================================================================== --- trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -26,9 +26,7 @@ from docutils.core import publish_string from docutils.parsers import docutils_xml -parser = docutils_xml.Parser() - class XMLParserTests(unittest.TestCase): maxDiff = None @@ -42,7 +40,8 @@ settings = self.mysettings | settings for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): - output = publish_string(case_input, parser=parser, + output = publish_string(case_input, + parser=docutils_xml.Parser(), settings_overrides=settings) self.assertEqual(case_expected, output) Modified: trunk/docutils/test/test_publisher.py =================================================================== --- trunk/docutils/test/test_publisher.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_publisher.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -18,8 +18,9 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1])) import docutils +import docutils.parsers.null from docutils import core, nodes, parsers, readers, writers -import docutils.parsers.null +from docutils.writers import html4css1, odf_odt, pseudoxml # DATA_ROOT is ./test/data/ from the docutils root DATA_ROOT = Path(__file__).parent / 'data' @@ -227,7 +228,7 @@ 'warning_stream': ''} with self.assertRaisesRegex(docutils.utils.SystemMessage, 'The ODT writer returns `bytes` '): - core.publish_string('test', writer='odt', + core.publish_string('test', writer=odf_odt.Writer(), settings_overrides=settings) def test_publish_string_deprecation_warning(self): @@ -253,7 +254,7 @@ # Produce the document tree. with self.assertWarns(PendingDeprecationWarning): doctree = core.publish_doctree( - source=test_document, reader='standalone', + source=test_document, parser_name='restructuredtext', settings_spec=self, settings_overrides={'expose_internals': ['refnames', 'do_not_expose'], @@ -274,7 +275,7 @@ # Write out the document: output = core.publish_from_doctree( doctree, - writer='pseudoxml', + writer=pseudoxml.Writer(), settings_spec=self, settings_overrides={'expose_internals': ['refnames', 'do_not_expose'], @@ -285,7 +286,7 @@ # Test publishing parts using document as the source. parts = core.publish_parts( reader='doctree', source_class=docutils.io.DocTreeInput, - source=doctree, source_path='test', writer='html', + source=doctree, source_path='test', writer=html4css1.Writer(), settings_spec=self) self.assertTrue(isinstance(parts, dict)) @@ -295,8 +296,6 @@ # Produce the document tree. doctree = core.publish_doctree( source=test_document, - reader='standalone', - parser='restructuredtext', settings_spec=self) self.assertTrue(isinstance(doctree, nodes.document)) Modified: trunk/docutils/test/test_traversals.py =================================================================== --- trunk/docutils/test/test_traversals.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_traversals.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -68,8 +68,6 @@ # Load some document tree in memory. doctree = core.publish_doctree( source=stop_traversal_input, - reader='standalone', - parser='restructuredtext', settings_spec=self) self.assertTrue(isinstance(doctree, nodes.document)) Modified: trunk/docutils/test/test_writers/test_docutils_xml.py =================================================================== --- trunk/docutils/test/test_writers/test_docutils_xml.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_docutils_xml.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -19,6 +19,7 @@ import docutils import docutils.core +from docutils.writers import docutils_xml from io import StringIO @@ -122,8 +123,7 @@ def publish_xml(settings, source): return docutils.core.publish_string(source=source, - reader='standalone', - writer='docutils_xml', + writer=docutils_xml.Writer(), settings_overrides=settings) Modified: trunk/docutils/test/test_writers/test_html4css1_misc.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1_misc.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_html4css1_misc.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -19,6 +19,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from docutils import core +from docutils.writers import html4css1 # TEST_ROOT is ./test/ from the docutils root TEST_ROOT = Path(__file__).parents[1] @@ -36,11 +37,11 @@ # error handler. settings_overrides = { 'output_encoding': 'latin1', - 'stylesheet': '', + 'stylesheet-path': '', '_disable_config': True, } result = bytes(core.publish_string( - 'EUR = \u20ac', writer='html4css1', + 'EUR = \u20ac', writer=html4css1.Writer(), settings_overrides=settings_overrides)) # Encoding a euro sign with latin1 doesn't work, so the # xmlcharrefreplace handler is used. @@ -49,10 +50,7 @@ class MovingArgsTestCase(unittest.TestCase): - mys = {'stylesheet_path': '', - # 'embed_stylesheet': False, - '_disable_config': True, - } + mys = {'_disable_config': True} def test_definition_list_item_classes(self): # Do not drop class arguments for the definition list item. @@ -66,7 +64,7 @@ second term: second def """ - result = core.publish_string(data, writer='html4css1', + result = core.publish_string(data, writer=html4css1.Writer(), settings_overrides=self.mys) self.assertIn(b'<dt class="for the second item">second term:</dt>', result) @@ -83,7 +81,7 @@ second term: second def """ - result = core.publish_string(data, writer='html4css1', + result = core.publish_string(data, writer=html4css1.Writer(), settings_overrides=self.mys) self.assertIn(b'<dt id="second-item">second term:</dt>', result) @@ -98,7 +96,7 @@ def test_default_stylesheet(self): # default style sheet, embedded mys = {'_disable_config': True} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('Default cascading style sheet ' 'for the HTML output of Docutils.', styles) @@ -107,7 +105,7 @@ # default style sheet, linked mys = {'_disable_config': True, 'embed_stylesheet': False} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('docutils/writers/html4css1/html4css1.css', styles) @@ -116,7 +114,7 @@ mys = {'_disable_config': True, 'embed_stylesheet': False, 'stylesheet_path': 'html4css1.css, math.css'} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('docutils/writers/html4css1/html4css1.css', styles) self.assertIn('docutils/writers/html5_polyglot/math.css', styles) @@ -127,7 +125,7 @@ 'embed_stylesheet': False, 'stylesheet_path': 'html4css1.css, ' 'data/ham.css'} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('docutils/writers/html4css1/html4css1.css', styles) self.assertIn('href="data/ham.css"', styles) @@ -139,7 +137,7 @@ TEST_ROOT / '../docutils/writers/html4css1/', DATA_ROOT), 'stylesheet_path': 'html4css1.css, ham.css'} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] if (TEST_ROOT / '../docutils/writers/html4css1/').is_dir(): self.assertIn('docutils/writers/html4css1/html4css1.css', styles) @@ -152,7 +150,7 @@ TEST_ROOT / '../docutils/writers/html4css1/', DATA_ROOT), 'stylesheet_path': 'ham.css'} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('dl.docutils dd {\n margin-bottom: 0.5em }', styles) @@ -175,7 +173,7 @@ def test_math_output_default(self): # HTML with math.css stylesheet (since 0.11) mys = {'_disable_config': True} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('convert LaTeX equations to HTML output.', styles) @@ -185,7 +183,7 @@ mys = {'_disable_config': True, 'report_level': 3, 'math_output': 'MathJax'} - head = core.publish_parts(self.data, writer='html4css1', + head = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['head'] self.assertIn(self.mathjax_script % self.default_mathjax_url, head) @@ -194,7 +192,7 @@ mys = {'_disable_config': True, 'math_output': 'mathjax %s' % self.custom_mathjax_url} - head = core.publish_parts(self.data, writer='html4css1', + head = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['head'] self.assertIn(self.mathjax_script % self.custom_mathjax_url, head) @@ -201,7 +199,7 @@ def test_math_output_html(self): mys = {'_disable_config': True, 'math_output': 'HTML'} - head = core.publish_parts(self.data, writer='html4css1', + head = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['head'] # There should be no MathJax script when math_output is not MathJax self.assertNotIn('MathJax.js', head) @@ -213,7 +211,7 @@ TEST_ROOT, os.path.join(TEST_ROOT, 'functional/input/data')), 'embed_stylesheet': False} - styles = core.publish_parts(self.data, writer='html4css1', + styles = core.publish_parts(self.data, writer=html4css1.Writer(), settings_overrides=mys)['stylesheet'] self.assertEqual(f"""\ <link rel="stylesheet" href="{html4css1_css}" type="text/css" /> @@ -223,7 +221,7 @@ def test_math_output_mathjax_no_math(self): # There should be no math script when text does not contain math - head = core.publish_parts('No math.', writer='html4css1')['head'] + head = core.publish_parts('No math.', writer=html4css1.Writer())['head'] self.assertNotIn('MathJax', head) Modified: trunk/docutils/test/test_writers/test_html4css1_parts.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1_parts.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_html4css1_parts.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -24,8 +24,8 @@ import docutils import docutils.core from docutils.parsers.rst.directives.images import PIL +from docutils.writers import html4css1 - ROOT_PREFIX = (Path(__file__).parent.parent/'functional'/'input').as_posix() if PIL: SCALING_OUTPUT = 'style="width: 32.0px; height: 32.0px;" ' @@ -41,17 +41,16 @@ maxDiff = None def test_publish(self): - writer = 'html4' for name, (settings_overrides, cases) in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): parts = docutils.core.publish_parts( source=case_input, - writer=writer, + writer=html4css1.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, - 'stylesheet': '', + 'stylesheet_path': '', **settings_overrides, } ) @@ -110,8 +109,7 @@ totest = {} -totest['title_promotion'] = ({'stylesheet_path': '', - 'embed_stylesheet': False}, [ +totest['title_promotion'] = ({}, [ ["""\ Simple String """, @@ -252,9 +250,7 @@ }] ]) -totest['no_title_promotion'] = ({'doctitle_xform': False, - 'stylesheet_path': '', - 'embed_stylesheet': False}, [ +totest['no_title_promotion'] = ({'doctitle_xform': False}, [ ["""\ Simple String """, @@ -416,9 +412,7 @@ ], ]) -totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX, - 'stylesheet_path': '', - 'embed_stylesheet': False}, [ +totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX}, [ ["""\ .. image:: /data/blue%20square.png Modified: trunk/docutils/test/test_writers/test_html4css1_template.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1_template.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_html4css1_template.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -21,6 +21,7 @@ import docutils from docutils.core import publish_string +from docutils.writers import html4css1 # TEST_ROOT is ./test/ from the docutils root TEST_ROOT = Path(__file__).parents[1] @@ -29,7 +30,6 @@ class WriterPublishTestCase(unittest.TestCase): # maxDiff = None def test_publish(self): - writer = 'html4' template_path = TEST_ROOT / 'data/full-template.txt' for name, cases in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): @@ -36,7 +36,7 @@ with self.subTest(id=f'totest[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=html4css1.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -23,6 +23,7 @@ import docutils.core from docutils.parsers.rst.directives.images import PIL from docutils.utils.code_analyzer import with_pygments +from docutils.writers import html5_polyglot if with_pygments: import pygments @@ -71,13 +72,12 @@ def test_publish(self): if not with_pygments: del totest['syntax_highlight'] - writer = 'html5' for name, (settings_overrides, cases) in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): parts = docutils.core.publish_parts( source=case_input, - writer=writer, + writer=html5_polyglot.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -19,6 +19,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from docutils import core +from docutils.writers import html5_polyglot # TEST_ROOT is ./test/ from the docutils root TEST_ROOT = Path(__file__).parents[1] @@ -39,7 +40,7 @@ 'stylesheet_path': '', '_disable_config': True} result = core.publish_string( - 'EUR = \u20ac', writer='html5_polyglot', + 'EUR = \u20ac', writer=html5_polyglot.Writer(), settings_overrides=settings_overrides) # Encoding a euro sign with latin1 doesn't work, so the # xmlcharrefreplace handler is used. @@ -64,7 +65,7 @@ second term: second def """ - result = core.publish_string(data, writer='html5_polyglot', + result = core.publish_string(data, writer=html5_polyglot.Writer(), settings_overrides=self.mys).decode() self.assertIn('<dt class="for the second item">second term:</dt>', result) @@ -81,7 +82,7 @@ second term: second def """ - result = core.publish_string(data, writer='html5_polyglot', + result = core.publish_string(data, writer=html5_polyglot.Writer(), settings_overrides=self.mys).decode() self.assertIn('<dt id="second-item">second term:</dt>', result) @@ -96,7 +97,7 @@ def test_default_stylesheet(self): # default style sheet, embedded mys = {'_disable_config': True} - styles = core.publish_parts(self.data, writer='html5_polyglot', + styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('Minimal style sheet for the HTML output of Docutils.', styles) @@ -105,7 +106,7 @@ # default style sheet, linked mys = {'_disable_config': True, 'embed_stylesheet': False} - styles = core.publish_parts(self.data, writer='html5_polyglot', + styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles) @@ -114,7 +115,7 @@ mys = {'_disable_config': True, 'embed_stylesheet': False, 'stylesheet_path': 'minimal.css, math.css'} - styles = core.publish_parts(self.data, writer='html5_polyglot', + styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles) self.assertIn('docutils/writers/html5_polyglot/math.css', styles) @@ -125,7 +126,7 @@ 'embed_stylesheet': False, 'stylesheet_path': 'minimal.css, ' 'data/ham.css'} - styles = core.publish_parts(self.data, writer='html5_polyglot', + styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles) self.assertIn('href="data/ham.css"', styles) @@ -137,7 +138,7 @@ TEST_ROOT / '../docutils/writers/html5_polyglot/', DATA_ROOT), 'stylesheet_path': 'minimal.css, ham.css'} - styles = core.publish_parts(self.data, writer='html5_polyglot', + styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['stylesheet'] if (TEST_ROOT / '../docutils/writers/html5_polyglot/').is_dir(): self.assertIn('docutils/writers/html5_polyglot/minimal.css', @@ -151,7 +152,7 @@ TEST_ROOT / '../docutils/writers/html5_polyglot/', DATA_ROOT), 'stylesheet_path': 'ham.css'} - styles = core.publish_parts(self.data, writer='html5_polyglot', + styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['stylesheet'] self.assertIn('dl.docutils dd {\n margin-bottom: 0.5em }', styles) @@ -163,7 +164,8 @@ } with self.assertWarnsRegex(FutureWarning, '"embed_images"\n will be removed'): - core.publish_string('warnings test', writer='html5', + core.publish_string('warnings test', + writer=html5_polyglot.Writer(), settings_overrides=my_settings) @@ -186,7 +188,7 @@ def test_math_output_default(self): # default math output is MathML (since 0.22) mys = {'_disable_config': True} - fragment = core.publish_parts(self.data, writer='html5_polyglot', + fragment = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['fragment'] self.assertIn('<mn>42</mn>', fragment) @@ -196,7 +198,7 @@ mys = {'_disable_config': True, 'report_level': 3, 'math_output': 'MathJax'} - head = core.publish_parts(self.data, writer='html5_polyglot', + head = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['head'] self.assertIn(self.mathjax_script % self.default_mathjax_url, head) @@ -205,7 +207,7 @@ mys = {'_disable_config': True, 'math_output': 'mathjax %s' % self.custom_mathjax_url} - head = core.publish_parts(self.data, writer='html5_polyglot', + head = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['head'] self.assertIn(self.mathjax_script % self.custom_mathjax_url, head) @@ -212,7 +214,7 @@ def test_math_output_html(self): mys = {'_disable_config': True, 'math_output': 'HTML'} - head = core.publish_parts(self.data, writer='html5_polyglot', + head = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['head'] # There should be no MathJax script when math_output is not MathJax self.assertNotIn('MathJax.js', head) @@ -224,7 +226,7 @@ TEST_ROOT, TEST_ROOT / 'functional/input/data'), 'embed_stylesheet': False} - styles = core.publish_parts(self.data, writer='html5_polyglot', + styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(), settings_overrides=mys)['stylesheet'] self.assertEqual(f"""\ <link rel="stylesheet" href="{minimal_css}" type="text/css" /> @@ -235,7 +237,7 @@ def test_math_output_mathjax_no_math(self): # There should be no math script when text does not contain math - head = core.publish_parts('No math.', writer='html5_polyglot')['head'] + head = core.publish_parts('No math.', writer=html5_polyglot.Writer())['head'] self.assertNotIn('MathJax', head) Modified: trunk/docutils/test/test_writers/test_latex2e.py =================================================================== --- trunk/docutils/test/test_writers/test_latex2e.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_latex2e.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -19,6 +19,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from docutils.core import publish_string +from docutils.writers import latex2e # DATA_ROOT is ./test/data from the docutils root DATA_ROOT = Path(__file__).resolve().parents[1] / 'data' @@ -35,7 +36,6 @@ class WriterPublishTestCase(unittest.TestCase): maxDiff = None - writer = 'latex' settings = { '_disable_config': True, 'strict_visitor': True, @@ -49,7 +49,7 @@ for casenum, (rst_input, expected) in enumerate(cases): with self.subTest(id=f'samples_default[{name!r}][{casenum}]'): output = publish_string(source=rst_input, - writer=self.writer, + writer=latex2e.Writer(), settings_overrides=settings) output = output.decode() self.assertEqual(expected, output) Modified: trunk/docutils/test/test_writers/test_latex2e_misc.py =================================================================== --- trunk/docutils/test/test_writers/test_latex2e_misc.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_latex2e_misc.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -27,6 +27,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from docutils import core +from docutils.writers import latex2e # TEST_ROOT is ./test/ from the docutils root TEST_ROOT = Path(__file__).parents[1] @@ -88,7 +89,7 @@ doctree = core.publish_doctree(sample_toc, settings_overrides=settings) result = core.publish_from_doctree(doctree, - writer='latex', + writer=latex2e.Writer(), settings_overrides=settings) self.assertNotIn(r'\item \hyperref[foo]{foo}', result) self.assertIn(r'\tableofcontents', result) @@ -97,7 +98,7 @@ """Check for the presence of documented parts. """ parts = core.publish_parts(sample_multiterm, - writer='latex', + writer=latex2e.Writer(), settings_overrides=self.settings) documented_parts = [ 'abstract', @@ -135,11 +136,11 @@ } with self.assertWarnsRegex(FutureWarning, '"legacy_column_widths" will change'): - core.publish_string('warnings test', writer='latex', + core.publish_string('warnings test', writer=latex2e.Writer(), settings_overrides=settings) with self.assertWarnsRegex(FutureWarning, '"use_latex_citations" will change'): - core.publish_string('warnings test', writer='latex', + core.publish_string('warnings test', writer=latex2e.Writer(), settings_overrides=settings) Modified: trunk/docutils/test/test_writers/test_manpage.py =================================================================== --- trunk/docutils/test/test_writers/test_manpage.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_manpage.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -17,7 +17,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from docutils.core import publish_string -from docutils.writers.manpage import insert_URI_breakpoints +from docutils.writers import manpage URI_tests = ( ("///abc.de", r"///\:abc.de"), @@ -35,7 +35,7 @@ def test_insert(self): for t in URI_tests: - got = insert_URI_breakpoints(t[0]) + got = manpage.insert_URI_breakpoints(t[0]) self.assertEqual(t[1], got) @@ -44,13 +44,12 @@ maxDiff = None def test_publish(self): - writer = 'manpage' for name, cases in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=manpage.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, @@ -58,13 +57,12 @@ self.assertEqual(case_expected, output) def test_reference_macros(self): - writer = 'manpage' for name, cases in totest_refs.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest_refs[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=manpage.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, @@ -117,7 +115,7 @@ document_start + indend_macros + """.TH "" "" "" "" .SH Name \\- \n\ -External hyperlinks, like +External hyperlinks, like \n\ .UR https://www.python.org/ Python .UE Modified: trunk/docutils/test/test_writers/test_null.py =================================================================== --- trunk/docutils/test/test_writers/test_null.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_null.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -18,17 +18,17 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from docutils.core import publish_string +from docutils.writers import null class WriterPublishTestCase(unittest.TestCase): def test_publish(self): - writer = 'null' for name, cases in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=null.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, Modified: trunk/docutils/test/test_writers/test_odt.py =================================================================== --- trunk/docutils/test/test_writers/test_odt.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_odt.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -45,6 +45,7 @@ import docutils import docutils.core +from docutils.writers import odf_odt # FUNCTIONAL_ROOT is ./test/functional/ from the docutils root FUNCTIONAL_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', 'functional')) @@ -75,11 +76,10 @@ settings_overrides['language_code'] = 'en-US' result = docutils.core.publish_string( - source=source, - source_path=input_path, - reader='standalone', - writer='odf_odt', - settings_overrides=settings_overrides) + source=source, + source_path=input_path, + writer=odf_odt.Writer(), + settings_overrides=settings_overrides) # msg = 'file length not equal: expected length: %d actual length: %d' % ( # len(expected), len(result), ) # self.assertEqual(str(len(result)), str(len(expected))) Modified: trunk/docutils/test/test_writers/test_pseudoxml.py =================================================================== --- trunk/docutils/test/test_writers/test_pseudoxml.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_pseudoxml.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -18,6 +18,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from docutils.core import publish_string +from docutils.writers import pseudoxml class WriterPublishTestCase(unittest.TestCase): @@ -24,14 +25,12 @@ maxDiff = None def test_publish(self): - writer = 'pseudoxml' - for name, cases in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=pseudoxml.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, @@ -43,7 +42,7 @@ with self.subTest(id=f'totest_detailed[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=pseudoxml.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, Modified: trunk/docutils/test/test_writers/test_s5.py =================================================================== --- trunk/docutils/test/test_writers/test_s5.py 2024-08-21 13:44:48 UTC (rev 9913) +++ trunk/docutils/test/test_writers/test_s5.py 2024-08-21 13:45:08 UTC (rev 9914) @@ -21,11 +21,11 @@ import docutils from docutils.core import publish_string +from docutils.writers import s5_html class WriterPublishTestCase(unittest.TestCase): def test_publish(self): - writer = 's5' settings = { '_disable_config': True, 'strict_visitor': True, @@ -38,7 +38,7 @@ with self.subTest(id=f'totest_1[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=s5_html.Writer(), settings_overrides=settings.copy() ).decode() self.assertEqual(case_expected, output) @@ -50,7 +50,7 @@ with self.subTest(id=f'totest_2[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=s5_html.Writer(), settings_overrides=settings.copy() ).decode() self.assertEqual(case_expected, output) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-21 13:44:51
|
Revision: 9913 http://sourceforge.net/p/docutils/code/9913 Author: milde Date: 2024-08-21 13:44:48 +0000 (Wed, 21 Aug 2024) Log Message: ----------- Refactor HTML5 writer tests. New test script "test_html5_polyglot.py": Split basic output tests (which happen to use the "fragment" returned by `publish_parts()` to get the interesting part of the output) from other tests of `publish_parts()` Really test all returned parts in "test_html5_polyglot_parts.py". Fill in parts that are built out of other parts in a helper function instead of pruning parts. Add test cases for input that goes to special parts. Disable default style sheet ("stylesheet_path" setting) by for tests not requiring a stylesheet. Modified Paths: -------------- trunk/docutils/docs/api/publisher.rst trunk/docutils/test/test_writers/test_html5_polyglot_misc.py trunk/docutils/test/test_writers/test_html5_polyglot_parts.py Added Paths: ----------- trunk/docutils/test/test_writers/test_html5_polyglot.py Modified: trunk/docutils/docs/api/publisher.rst =================================================================== --- trunk/docutils/docs/api/publisher.rst 2024-08-21 13:44:37 UTC (rev 9912) +++ trunk/docutils/docs/api/publisher.rst 2024-08-21 13:44:48 UTC (rev 9913) @@ -603,7 +603,7 @@ Default: "restructuredtext". -_`writer` : str | docutils.parsers.Writer +_`writer` : str | docutils.writers.Writer `Writer component name`_ or instance. [#component-names]_ Default: "pseudoxml". Copied: trunk/docutils/test/test_writers/test_html5_polyglot.py (from rev 9912, trunk/docutils/test/test_writers/test_html5_polyglot_parts.py) =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot.py (rev 0) +++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2024-08-21 13:44:48 UTC (rev 9913) @@ -0,0 +1,672 @@ +#! /usr/bin/env python3 + +# $Id$ +# Author: reggie dugard <re...@us...> +# Copyright: This module has been placed in the public domain. + +"""Test HTML5 writer output ("fragment" part). + +This is the document body (not HTML <body>). +""" + +from pathlib import Path +import re +import sys +import unittest + +if __name__ == '__main__': + # prepend the "docutils root" to the Python library path + # so we import the local `docutils` package. + sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + +import docutils +import docutils.core +from docutils.parsers.rst.directives.images import PIL +from docutils.utils.code_analyzer import with_pygments + +if with_pygments: + import pygments + _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__) + if (int(_pv[1]), int(_pv[2])) >= (2, 14): + # pygments output changed in version 2.14 + with_pygments = False + +# TEST_ROOT is ./test/ from the docutils root +TEST_ROOT = Path(__file__).parents[1] +DATA_ROOT = TEST_ROOT / 'data' +ROOT_PREFIX = (TEST_ROOT / 'functional/input').as_posix() + +# Pillow/PIL is optional: +if PIL: + REQUIRES_PIL = '' + ONLY_LOCAL = 'Can only read local images.' + DUMMY_PNG_NOT_FOUND = "[Errno 2] No such file or directory: 'dummy.png'" + # Pillow reports the absolute path since version 10.3.0 (cf. [bugs: 485]) + if (tuple(int(i) for i in PIL.__version__.split('.')) >= (10, 3)): + DUMMY_PNG_NOT_FOUND = ("[Errno 2] No such file or directory: '%s'" + % Path('dummy.png').resolve()) + SCALING_OUTPUT = 'style="width: 32.0px; height: 32.0px;" ' + NO_PIL_SYSTEM_MESSAGE = '' +else: + REQUIRES_PIL = '\n Requires Python Imaging Library.' + ONLY_LOCAL = 'Requires Python Imaging Library.' + DUMMY_PNG_NOT_FOUND = 'Requires Python Imaging Library.' + SCALING_OUTPUT = '' + NO_PIL_SYSTEM_MESSAGE = ( + '<aside class="system-message">\n' + '<p class="system-message-title">System Message:' + ' WARNING/2 (<span class="docutils literal">' + '<string></span>, line 1)</p>\n' + '<p>Cannot scale image!\n' + ' Could not get size from "/data/blue%20square.png":\n' + ' Requires Python Imaging Library.</p>\n' + '</aside>\n') + + +class Html5WriterPublishPartsTestCase(unittest.TestCase): + """Test case for HTML5 writer via the publish_parts() interface.""" + + maxDiff = None + + def test_publish(self): + if not with_pygments: + del totest['syntax_highlight'] + writer = 'html5' + for name, (settings_overrides, cases) in totest.items(): + for casenum, (case_input, case_expected) in enumerate(cases): + with self.subTest(id=f'totest[{name!r}][{casenum}]'): + parts = docutils.core.publish_parts( + source=case_input, + writer=writer, + settings_overrides={ + '_disable_config': True, + 'strict_visitor': True, + 'stylesheet_path': '', + 'section_self_link': True, + **settings_overrides, + } + ) + self.assertEqual(case_expected, parts['body']) + + +totest = {} + +totest['standard'] = ({}, [ +["""\ +Simple String +""", +'<p>Simple String</p>\n', +], +["""\ +Simple String with *markup* +""", +'<p>Simple String with <em>markup</em></p>\n', +], +["""\ +Simple String with an even simpler ``inline literal`` +""", +'<p>Simple String with an even simpler <span class="docutils literal">inline literal</span></p>\n', +], +["""\ +A simple `anonymous reference`__ + +__ http://www.test.com/test_url +""", +'<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\n', +], +["""\ +One paragraph. + +Two paragraphs. +""", +"""\ +<p>One paragraph.</p> +<p>Two paragraphs.</p> +""", +], +["""\ +A simple `named reference`_ with stuff in between the +reference and the target. + +.. _`named reference`: http://www.test.com/test_url +""", +"""\ +<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the +reference and the target.</p> +""", +], +["""\ +.. [CIT2022] A citation. +""", +"""\ +<div role="list" class="citation-list"> +<div class="citation" id="cit2022" role="doc-biblioentry"> +<span class="label"><span class="fn-bracket">[</span>CIT2022<span class="fn-bracket">]</span></span> +<p>A citation.</p> +</div> +</div> +""", +], +]) + + +totest['no_title_promotion'] = ({'doctitle_xform': False}, [ +["""\ ++++++ +Title ++++++ + +Not A Subtitle +============== + +Some stuff + +Section +------- + +Some more stuff + +Another Section +............... + +And even more stuff +""", +"""\ +<section id="title"> +<h2>Title<a class="self-link" title="link to this section" href="#title"></a></h2> +<section id="not-a-subtitle"> +<h3>Not A Subtitle<a class="self-link" title="link to this section" href="#not-a-subtitle"></a></h3> +<p>Some stuff</p> +<section id="section"> +<h4>Section<a class="self-link" title="link to this section" href="#section"></a></h4> +<p>Some more stuff</p> +<section id="another-section"> +<h5>Another Section<a class="self-link" title="link to this section" href="#another-section"></a></h5> +<p>And even more stuff</p> +</section> +</section> +</section> +</section> +""", +], +["""\ +* bullet +* list +""", +"""\ +<ul class="simple"> +<li><p>bullet</p></li> +<li><p>list</p></li> +</ul> +""", +], +["""\ +.. table:: + :align: right + + +-----+-----+ + | 1 | 2 | + +-----+-----+ + | 3 | 4 | + +-----+-----+ +""", +"""\ +<table class="align-right"> +<tbody> +<tr><td><p>1</p></td> +<td><p>2</p></td> +</tr> +<tr><td><p>3</p></td> +<td><p>4</p></td> +</tr> +</tbody> +</table> +""", +], +["""\ +Not a docinfo. + +:This: .. _target: + + is +:a: +:simple: +:field: list +""", +"""\ +<p>Not a docinfo.</p> +<dl class="field-list simple"> +<dt>This<span class="colon">:</span></dt> +<dd><p id="target">is</p> +</dd> +<dt>a<span class="colon">:</span></dt> +<dd><p></p></dd> +<dt>simple<span class="colon">:</span></dt> +<dd><p></p></dd> +<dt>field<span class="colon">:</span></dt> +<dd><p>list</p> +</dd> +</dl> +""", +], +["""\ +Not a docinfo. + +:This is: a +:simple field list with loooong field: names +""", +"""\ +<p>Not a docinfo.</p> +<dl class="field-list simple"> +<dt>This is<span class="colon">:</span></dt> +<dd><p>a</p> +</dd> +<dt>simple field list with loooong field<span class="colon">:</span></dt> +<dd><p>names</p> +</dd> +</dl> +""", +], +["""\ +Not a docinfo. + +.. class:: field-indent-200 + +:This: is a +:simple: field list with custom indent. +""", +"""\ +<p>Not a docinfo.</p> +<dl class="field-list simple" style="--field-indent: 200px;"> +<dt>This<span class="colon">:</span></dt> +<dd><p>is a</p> +</dd> +<dt>simple<span class="colon">:</span></dt> +<dd><p>field list with custom indent.</p> +</dd> +</dl> +""", +], +["""\ +Not a docinfo. + +.. class:: field-indent-200uf + +:This: is a +:simple: field list without custom indent, + because the unit "uf" is invalid. +""", +"""\ +<p>Not a docinfo.</p> +<dl class="field-indent-200uf field-list simple"> +<dt>This<span class="colon">:</span></dt> +<dd><p>is a</p> +</dd> +<dt>simple<span class="colon">:</span></dt> +<dd><p>field list without custom indent, +because the unit "uf" is invalid.</p> +</dd> +</dl> +""", +], +["""\ +.. figure:: dummy.png + + The figure's caption. + + A legend. + + The legend's second paragraph. +""", +"""\ +<figure> +<img alt="dummy.png" src="dummy.png" /> +<figcaption> +<p>The figure's caption.</p> +<div class="legend"> +<p>A legend.</p> +<p>The legend's second paragraph.</p> +</div> +</figcaption> +</figure> +""", +], +["""\ +.. figure:: dummy.png + + The figure's caption, no legend. +""", +"""\ +<figure> +<img alt="dummy.png" src="dummy.png" /> +<figcaption> +<p>The figure's caption, no legend.</p> +</figcaption> +</figure> +""", +], +["""\ +.. figure:: dummy.png + + .. + + A legend without caption. +""", +"""\ +<figure> +<img alt="dummy.png" src="dummy.png" /> +<figcaption> +<div class="legend"> +<p>A legend without caption.</p> +</div> +</figcaption> +</figure> +""", +], +["""\ +.. figure:: dummy.png + +No caption nor legend. +""", +"""\ +<figure> +<img alt="dummy.png" src="dummy.png" /> +</figure> +<p>No caption nor legend.</p> +""", +], +[f"""\ +.. include:: {DATA_ROOT}/multiple-term-definition.xml + :parser: xml +""", +"""\ +<dl> +<dt>New in Docutils 0.22</dt> +<dd><p>A definition list item may contain several +terms with optional classifier(s).</p> +<p>However, there is currently no corresponding +reStructuredText syntax.</p> +</dd> +<dt>term 2a</dt> +<dt>term 2b</dt> +<dd><p>definition 2</p> +</dd> +<dt>term 3a<span class="classifier">classifier 3a</span><span class="classifier">classifier 3aa</span><dt>term 3b<span class="classifier">classifier 3b</span></dt> +<dd><p>definition 3</p> +</dd> +</dl> +""", +], +]) + + +totest['lazy_loading'] = ({'image_loading': 'lazy', + 'report_level': 4}, [ +["""\ +Lazy loading by default, overridden by :loading: option +("cannot embed" warning ignored). + +.. image:: dummy.png +.. image:: dummy.png + :loading: link +.. figure:: dummy.png +.. figure:: dummy.png + :loading: embed +""", +"""\ +<p>Lazy loading by default, overridden by :loading: option +("cannot embed" warning ignored).</p> +<img alt="dummy.png" loading="lazy" src="dummy.png" /> +<img alt="dummy.png" src="dummy.png" /> +<figure> +<img alt="dummy.png" loading="lazy" src="dummy.png" /> +</figure> +<figure> +<img alt="dummy.png" src="dummy.png" /> +</figure> +""", +], +]) + + +totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX, + 'image_loading': 'embed', + 'warning_stream': '', + }, [ +["""\ +.. image:: /data/blue%20square.png + :scale: 100% +.. figure:: /data/blue%20square.png +""", +'<img alt="/data/blue%20square.png" src="data:image/png;base64,' +'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAALElEQVR4nO3NMQ' +'EAMAjAsDFjvIhHFCbgSwU0kdXvsn96BwAAAAAAAAAAAIsNnEwBk52VRuMAAAAA' +'SUVORK5CYII="' +f' {SCALING_OUTPUT}/>\n{NO_PIL_SYSTEM_MESSAGE}' +'<figure>\n' +'<img alt="/data/blue%20square.png" src="data:image/png;base64,' +'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAALElEQVR4nO3NMQ' +'EAMAjAsDFjvIhHFCbgSwU0kdXvsn96BwAAAAAAAAAAAIsNnEwBk52VRuMAAAAA' +'SUVORK5CYII=" />\n' +'</figure>\n', +], +]) + + +totest['no_backlinks'] = ({'footnote_backlinks': False}, [ + +["""\ +Two footnotes [#f1]_ [#f2]_ and two citations [once]_ [twice]_. + +The latter are referenced a second time [#f2]_ [twice]_. + +.. [#f1] referenced once +.. [#f2] referenced twice +.. [once] citation referenced once +.. [twice] citation referenced twice +""", +"""\ +<p>Two footnotes <a class="brackets" href="#f1" id="footnote-reference-1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> <a class="brackets" href="#f2" id="footnote-reference-2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> and two citations <a class="citation-reference" href="#once" id="citation-reference-1" role="doc-biblioref">[once]</a> <a class="citation-reference" href="#twice" id="citation-reference-2" role="doc-biblioref">[twice]</a>.</p> +<p>The latter are referenced a second time <a class="brackets" href="#f2" id="footnote-reference-3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> <a class="citation-reference" href="#twice" id="citation-reference-3" role="doc-biblioref">[twice]</a>.</p> +<aside class="footnote-list brackets"> +<aside class="footnote brackets" id="f1" role="doc-footnote"> +<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span> +<p>referenced once</p> +</aside> +<aside class="footnote brackets" id="f2" role="doc-footnote"> +<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span> +<p>referenced twice</p> +</aside> +</aside> +<div role="list" class="citation-list"> +<div class="citation" id="once" role="doc-biblioentry"> +<span class="label"><span class="fn-bracket">[</span>once<span class="fn-bracket">]</span></span> +<p>citation referenced once</p> +</div> +<div class="citation" id="twice" role="doc-biblioentry"> +<span class="label"><span class="fn-bracket">[</span>twice<span class="fn-bracket">]</span></span> +<p>citation referenced twice</p> +</div> +</div> +""", +], +]) + + +totest['syntax_highlight'] = ({'syntax_highlight': 'short', + }, [ +["""\ +.. code:: shell + + cat <<EOF + Hello World + EOF +""", +"""\ +<pre class="code shell literal-block"><code>cat <span class="s"><<EOF +Hello World +EOF</span></code></pre> +""", +], +["""\ +.. role:: shell(code) + :language: shell + +:shell:`cat <<EOF Hello World EOF` +""", +"""\ +<p><code class="shell">cat <span class="s"><<EOF Hello World EOF</span></code></p> +""", +], +]) + + +totest['system_messages'] = ({'math_output': 'mathml', + 'warning_stream': '', + }, [ +["""\ +.. image:: https://dummy.png + :loading: embed +""", +"""\ +<img alt="https://dummy.png" src="https://dummy.png" /> +<aside class="system-message"> +<p class="system-message-title">System Message: ERROR/3 \ +(<span class="docutils literal"><string></span>, line 1)</p> +<p>Cannot embed image "https://dummy.png": + Can only read local images.</p> +</aside> +""", +], +[f"""\ +.. image:: {DATA_ROOT.as_uri()}/circle-broken.svg + :loading: embed +""", +f"""\ +<svg xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 10 10"> + <circle cx="5" cy="5" r="4" fill="lightblue" x/> +</svg> + +<aside class="system-message"> +<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal"><string></span>, line 1)</p> +<p>Cannot parse SVG image "{DATA_ROOT.as_uri()}/circle-broken.svg": + not well-formed (invalid token): line 3, column 48</p> +</aside> +""" +], +[r"""Broken :math:`\sin \my`. +""", +"""\ +<p>Broken <span class="math problematic">\\sin \\my</span>.</p> +<aside class="system-message"> +<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal"><string></span>, line 1)</p> +<p>Unknown LaTeX command "\\my".</p> +</aside> +"""], +]) + +totest['system_messages-PIL'] = ({'math_output': 'mathml', + 'warning_stream': '', + }, [ +["""\ +.. image:: dummy.png + :scale: 100% + :loading: embed +""", +f"""\ +<img alt="dummy.png" src="dummy.png" /> +<aside class="system-message"> +<p class="system-message-title">System Message: WARNING/2 \ +(<span class="docutils literal"><string></span>, line 1)</p> +<p>Cannot scale image! + Could not get size from "dummy.png": + {DUMMY_PNG_NOT_FOUND}</p> +</aside> +<aside class="system-message"> +<p class="system-message-title">System Message: ERROR/3 \ +(<span class="docutils literal"><string></span>, line 1)</p> +<p>Cannot embed image "dummy.png": + [Errno 2] No such file or directory: 'dummy.png'</p> +</aside> +""", +], +["""\ +.. image:: dummy.mp4 + :scale: 100% +""", +f"""\ +<video src="dummy.mp4" title="dummy.mp4"> +<a href="dummy.mp4">dummy.mp4</a> +</video> +<aside class="system-message"> +<p class="system-message-title">System Message: WARNING/2 \ +(<span class="docutils literal"><string></span>, line 1)</p> +<p>Cannot scale image! + Could not get size from "dummy.mp4":{REQUIRES_PIL} + PIL cannot read video images.</p> +</aside> +""", +], +["""\ +.. image:: https://dummy.png + :scale: 100% + :loading: embed +""", +f"""\ +<img alt="https://dummy.png" src="https://dummy.png" /> +<aside class="system-message"> +<p class="system-message-title">System Message: WARNING/2 \ +(<span class="docutils literal"><string></span>, line 1)</p> +<p>Cannot scale image! + Could not get size from "https://dummy.png": + {ONLY_LOCAL}</p> +</aside> +<aside class="system-message"> +<p class="system-message-title">System Message: ERROR/3 \ +(<span class="docutils literal"><string></span>, line 1)</p> +<p>Cannot embed image "https://dummy.png": + Can only read local images.</p> +</aside> +""", +], +]) + +totest['no_system_messages'] = ({'math_output': 'mathml', + 'report_level': 4, + 'warning_stream': '', + }, [ +["""\ +.. image:: dummy.png + :scale: 100% + :loading: embed + +.. image:: dummy.mp4 + :scale: 100% +""", +"""\ +<img alt="dummy.png" src="dummy.png" /> +<video src="dummy.mp4" title="dummy.mp4"> +<a href="dummy.mp4">dummy.mp4</a> +</video> +""", +], +[f"""\ +.. image:: {DATA_ROOT.as_uri()}/circle-broken.svg + :loading: embed +""", +"""\ +<svg xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 10 10"> + <circle cx="5" cy="5" r="4" fill="lightblue" x/> +</svg> + +"""], +[r'Broken :math:`\sin \my`.', +'<p>Broken <tt class="math">\\sin \\my</tt>.</p>\n' +], +]) + + +if __name__ == '__main__': + unittest.main() Property changes on: trunk/docutils/test/test_writers/test_html5_polyglot.py ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-08-21 13:44:37 UTC (rev 9912) +++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2024-08-21 13:44:48 UTC (rev 9913) @@ -36,7 +36,7 @@ # error handler. settings_overrides = { 'output_encoding': 'latin1', - 'stylesheet': '', + 'stylesheet_path': '', '_disable_config': True} result = core.publish_string( 'EUR = \u20ac', writer='html5_polyglot', @@ -49,7 +49,6 @@ class MovingArgsTestCase(unittest.TestCase): mys = {'stylesheet_path': '', - # 'embed_stylesheet': False, '_disable_config': True, } @@ -99,8 +98,8 @@ mys = {'_disable_config': True} styles = core.publish_parts(self.data, writer='html5_polyglot', settings_overrides=mys)['stylesheet'] - self.assertIn('Minimal style sheet ' - 'for the HTML output of Docutils.', styles) + self.assertIn('Minimal style sheet for the HTML output of Docutils.', + styles) def test_default_stylesheet_linked(self): # default style sheet, linked @@ -141,7 +140,8 @@ styles = core.publish_parts(self.data, writer='html5_polyglot', settings_overrides=mys)['stylesheet'] if (TEST_ROOT / '../docutils/writers/html5_polyglot/').is_dir(): - self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles) + self.assertIn('docutils/writers/html5_polyglot/minimal.css', + styles) self.assertIn(f'href="{ham_css}"', styles) def test_custom_stylesheet_dir_embedded(self): Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2024-08-21 13:44:37 UTC (rev 9912) +++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2024-08-21 13:44:48 UTC (rev 9913) @@ -5,15 +5,12 @@ # Copyright: This module has been placed in the public domain. """ -Test for fragment code in HTML writer. +Test `core.publish_parts()`__ with the HTML5 writer. -Note: the 'body' and 'whole' entries have been removed from the parts -dictionaries (redundant), along with 'meta' and 'stylesheet' entries with -standard values, and any entries with empty values. +__ https://docutils.sourceforge.io/docs/api/publisher.html#publish-parts """ from pathlib import Path -import re import sys import unittest @@ -24,182 +21,136 @@ import docutils import docutils.core -from docutils.parsers.rst.directives.images import PIL -from docutils.utils.code_analyzer import with_pygments +from docutils.writers import html5_polyglot -if with_pygments: - import pygments - _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__) - if (int(_pv[1]), int(_pv[2])) >= (2, 14): - # pygments output changed in version 2.14 - with_pygments = False - # TEST_ROOT is ./test/ from the docutils root TEST_ROOT = Path(__file__).parents[1] DATA_ROOT = TEST_ROOT / 'data' ROOT_PREFIX = (TEST_ROOT / 'functional/input').as_posix() -# Pillow/PIL is optional: -if PIL: - REQUIRES_PIL = '' - ONLY_LOCAL = 'Can only read local images.' - DUMMY_PNG_NOT_FOUND = "[Errno 2] No such file or directory: 'dummy.png'" - # Pillow reports the absolute path since version 10.3.0 (cf. [bugs: 485]) - if (tuple(int(i) for i in PIL.__version__.split('.')) >= (10, 3)): - DUMMY_PNG_NOT_FOUND = ("[Errno 2] No such file or directory: '%s'" - % Path('dummy.png').resolve()) - SCALING_OUTPUT = 'style="width: 32.0px; height: 32.0px;" ' - NO_PIL_SYSTEM_MESSAGE = '' -else: - REQUIRES_PIL = '\n Requires Python Imaging Library.' - ONLY_LOCAL = 'Requires Python Imaging Library.' - DUMMY_PNG_NOT_FOUND = 'Requires Python Imaging Library.' - SCALING_OUTPUT = '' - NO_PIL_SYSTEM_MESSAGE = ( - '<aside class="system-message">\n' - '<p class="system-message-title">System Message:' - ' WARNING/2 (<span class="docutils literal">' - '<string></span>, line 1)</p>\n' - '<p>Cannot scale image!\n' - ' Could not get size from "/data/blue%20square.png":\n' - ' Requires Python Imaging Library.</p>\n' - '</aside>\n') +# Parts returned by `publish_parts()` for the HTML5 writer by default: +# * empty input string +# * default configuration settings. +# See format_parts() below for the substitution of unresolved format markers. +default_parts = { + 'body': '{fragment}', + 'body_pre_docinfo': '', + 'body_prefix': '</head>\n<body>\n{header}<main>\n', + 'body_suffix': '</main>\n{footer}</body>\n</html>\n', + 'docinfo': '', + 'encoding': 'utf-8', + 'errors': 'xmlcharrefreplace', + 'footer': '', + 'fragment': '', + 'head': '{meta}<title>{metatitle}</title>\n', + 'head_prefix': + '<!DOCTYPE html>\n' + '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' + '<head>\n', + 'header': '', + 'html_body': '{header}<main>\n{fragment}</main>\n{footer}', + 'html_head': '{meta}<title>{metatitle}</title>\n', + 'html_prolog': '<!DOCTYPE html>\n', + 'html_subtitle': '', + 'html_title': '', + 'meta': '<meta charset="%s" />\n' + f'<meta name="generator" content="Docutils {docutils.__version__}: https://docutils.sourceforge.io/" />\n' + '<meta name="viewport" content="width=device-width, initial-scale=1" />\n', + 'stylesheet': '', + 'subtitle': '', + 'title': '', + 'version': f'{docutils.__version__}', + 'whole': + '{head_prefix}\n' + '{head}\n' + '{stylesheet}\n' + '{body_prefix}\n' + '{body_pre_docinfo}\n' + '{docinfo}\n' + '{body}\n' + '{body_suffix}\n', + } + +def format_parts(parts): + # fill in part values that depend on other parts + # https://docutils.sourceforge.io/docs/api/publisher.html#html4-writer + + # metadata title: either the visible title or document['source'] + metatitle = parts['title'] or '<string>' + + # "html_head" leaves the encoding unresolved, as "%s": + parts['html_head'] = parts['html_head'].format(metatitle=metatitle, + **parts) + # now resolve encoding: + try: + parts['meta'] = parts['meta'] % parts['encoding'] + except TypeError: # charset-<meta> missing if encoding is 'unicode' + pass + parts['head'] = parts['head'].format(metatitle=metatitle, **parts) + parts['body_prefix'] = parts['body_prefix'].format(**parts) + parts['body'] = parts['body'].format(**parts) + parts['body_suffix'] = parts['body_suffix'].format(**parts) + parts['html_body'] = parts['html_body'].format(**parts) + # newlines are stripped when parts are used to expand the template file + parts['whole'] = parts['whole'].format(**{k: v.rstrip('\n') + for k, v in parts.items()}) + return parts + + class Html5WriterPublishPartsTestCase(unittest.TestCase): - """Test case for HTML writer via the publish_parts interface.""" + """Test HTML5 writer `publish_parts()` interface.""" maxDiff = None - def test_publish(self): - if not with_pygments: - del totest['syntax_highlight'] - writer = 'html5' + def test_publish_parts(self): for name, (settings_overrides, cases) in totest.items(): - for casenum, (case_input, case_expected) in enumerate(cases): - with self.subTest(id=f'totest[{name!r}][{casenum}]'): - parts = docutils.core.publish_parts( - source=case_input, - writer=writer, - settings_overrides={ - '_disable_config': True, - 'strict_visitor': True, - 'stylesheet_path': '', - 'section_self_link': True, - **settings_overrides, - } - ) - # if the formatted output is a just single fragment, - # compare the text directly for a nicer diff on failure - formatted = self.format_output(parts) - if len(formatted) == 1 and 'fragment' in formatted: - fragment = formatted['fragment'] - self.assertEqual(case_expected, fragment) - else: - self.assertEqual(case_expected, formatted) + for casenum, (case_input, expected_parts) in enumerate(cases): + _stgns = {'_disable_config': True, + 'strict_visitor': True, + 'stylesheet_path': '', + 'section_self_link': True, + **settings_overrides, + } + parts = docutils.core.publish_parts(source=case_input, + writer=html5_polyglot.Writer(), + settings_overrides=_stgns, + ) + expected = format_parts(default_parts | expected_parts) + for key in parts.keys(): + with self.subTest(id=f'totest[{name!r}][{casenum}][{key}]'): + self.assertEqual(f'{expected[key]}', + f'{parts[key]}') - standard_content_type_template = '<meta charset="%s" />\n' - standard_generator_template = ( - '<meta name="generator"' - f' content="Docutils {docutils.__version__}: ' - 'https://docutils.sourceforge.io/" />\n') - standard_viewport_value = ( - '<meta name="viewport"' - ' content="width=device-width, initial-scale=1" />\n') - standard_html_meta_value = (standard_content_type_template - + standard_generator_template - + standard_viewport_value) - standard_meta_value = standard_html_meta_value % 'utf-8' - standard_html_prolog = '<!DOCTYPE html>\n' - standard_html_body_template = '<main>\n%s</main>\n' - def format_output(self, parts): - """Minimize & standardize the output.""" - # remove redundant parts & uninteresting parts: - del parts['whole'] - assert parts['body'] == parts['fragment'] - del parts['body'] - del parts['body_pre_docinfo'] - del parts['body_prefix'] - del parts['body_suffix'] - del parts['head'] - del parts['head_prefix'] - del parts['encoding'] - del parts['errors'] - del parts['version'] - # remove standard portions: - parts['meta'] = parts['meta'].replace(self.standard_meta_value, '') - parts['html_head'] = parts['html_head'].replace( - self.standard_html_meta_value, '...') - parts['html_head'] = parts['html_head'].replace( - '...<title><string></title>\n', '') - parts['html_prolog'] = parts['html_prolog'].replace( - self.standard_html_prolog, '') - parts['html_body'] = parts['html_body'].replace( - self.standard_html_body_template % parts['fragment'], '') - # remove empty keys and return - return {k: v for k, v in parts.items() if v} - - totest = {} totest['standard'] = ({}, [ -["""\ -Simple String -""", -'<p>Simple String</p>\n', -], -["""\ -Simple String with *markup* -""", -'<p>Simple String with <em>markup</em></p>\n', -], -["""\ -Simple String with an even simpler ``inline literal`` -""", -'<p>Simple String with an even simpler <span class="docutils literal">inline literal</span></p>\n', -], -["""\ -A simple `anonymous reference`__ - -__ http://www.test.com/test_url -""", -'<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\n', -], -["""\ -One paragraph. - -Two paragraphs. -""", -"""\ -<p>One paragraph.</p> -<p>Two paragraphs.</p> -""", -], -["""\ -A simple `named reference`_ with stuff in between the -reference and the target. - -.. _`named reference`: http://www.test.com/test_url -""", -"""\ -<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the -reference and the target.</p> -""", -], -["""\ -.. [CIT2022] A citation. -""", -"""\ -<div role="list" class="citation-list"> -<div class="citation" id="cit2022" role="doc-biblioentry"> -<span class="label"><span class="fn-bracket">[</span>CIT2022<span class="fn-bracket">]</span></span> -<p>A citation.</p> -</div> -</div> -""", -], -["""\ + ['', # empty input string + {} # results in default parts + ], + ['Simple String with *markup*', + {'fragment': '<p>Simple String with <em>markup</em></p>\n'} + ], + ['.. header:: custom document header\n\n' + 'A paragraph.', + {'header': '<header>\n<p>custom document header</p>\n</header>\n', + 'body_prefix': '</head>\n' + '<body>\n' + '<header>\n' + '<p>custom document header</p>\n</header>\n' + '<main>\n', + 'fragment': '<p>A paragraph.</p>\n', + } + ], + ['.. footer:: custom document footer\n\n' + 'A paragraph.', + {'footer': '<footer>\n<p>custom document footer</p>\n</footer>\n', + 'fragment': '<p>A paragraph.</p>\n', + } + ], + ["""\ +++++ Title +++++ @@ -219,7 +170,10 @@ And even more stuff """, -{'fragment': """\ + {'body_pre_docinfo': '<h1 class="title">Title</h1>\n' + '<p class="subtitle" id="subtitle">Subtitle</p>\n', + 'body_prefix': '</head>\n<body>\n<main id="title">\n', + 'fragment': """\ <p>Some stuff</p> <section id="section"> <h2>Section<a class="self-link" title="link to this section" href="#section"></a></h2> @@ -230,7 +184,7 @@ </section> </section> """, - 'html_body': """\ + 'html_body': """\ <main id="title"> <h1 class="title">Title</h1> <p class="subtitle" id="subtitle">Subtitle</p> @@ -245,13 +199,12 @@ </section> </main> """, - 'html_head': '...<title>Title</title>\n', - 'html_subtitle': '<p class="subtitle" id="subtitle">Subtitle</p>\n', - 'html_title': '<h1 class="title">Title</h1>\n', - 'subtitle': 'Subtitle', - 'title': 'Title' -}], -["""\ + 'html_subtitle': '<p class="subtitle" id="subtitle">Subtitle</p>\n', + 'html_title': '<h1 class="title">Title</h1>\n', + 'subtitle': 'Subtitle', + 'title': 'Title' + }], + ["""\ +++++ Title +++++ @@ -260,14 +213,16 @@ Some stuff """, -{'docinfo': """\ + {'body_pre_docinfo': '<h1 class="title">Title</h1>\n', + 'body_prefix': '</head>\n<body>\n<main id="title">\n', + 'docinfo': """\ <dl class="docinfo simple"> <dt class="author">Author<span class="colon">:</span></dt> <dd class="author"><p>me</p></dd> </dl> """, - 'fragment': '<p>Some stuff</p>\n', - 'html_body': """\ + 'fragment': '<p>Some stuff</p>\n', + 'html_body': """\ <main id="title"> <h1 class="title">Title</h1> <dl class="docinfo simple"> @@ -277,63 +232,14 @@ <p>Some stuff</p> </main> """, - 'html_head': """\ -...<meta name="author" content="me" /> -<title>Title</title> -""", - 'html_title': '<h1 class="title">Title</h1>\n', - 'meta': '<meta name="author" content="me" />\n', - 'title': 'Title' -}], -]) + 'html_title': '<h1 class="title">Title</h1>\n', + 'meta': default_parts['meta'] + '<meta name="author" content="me" />\n', + 'title': 'Title' + }], + ]) -totest['standard'] = ({'output_encoding': 'unicode'}, [ -["""\ -Simple String -""", -{'fragment': '<p>Simple String</p>\n', - 'meta': """\ -<meta name="generator" content="Docutils 0.22b.dev: https://docutils.sourceforge.io/" /> -<meta name="viewport" content="width=device-width, initial-scale=1" /> -""", -}], -]) - totest['no_title_promotion'] = ({'doctitle_xform': False}, [ -["""\ -Simple String -""", -'<p>Simple String</p>\n', -], -["""\ -Simple String with *markup* -""", -'<p>Simple String with <em>markup</em></p>\n', -], -["""\ -Simple String with an even simpler ``inline literal`` -""", -'<p>Simple String with an even simpler <span class="docutils literal">inline literal</span></p>\n', -], -["""\ -A simple `anonymous reference`__ - -__ http://www.test.com/test_url -""", -'<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\n', -], -["""\ -A simple `named reference`_ with stuff in between the -reference and the target. - -.. _`named reference`: http://www.test.com/test_url -""", -"""\ -<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the -reference and the target.</p> -""", -], -["""\ + ["""\ +++++ Title +++++ @@ -353,7 +259,7 @@ And even more stuff """, -"""\ + {'fragment': """\ <section id="title"> <h2>Title<a class="self-link" title="link to this section" href="#title"></a></h2> <section id="not-a-subtitle"> @@ -369,486 +275,19 @@ </section> </section> </section> -""", -], -["""\ -* bullet -* list -""", -"""\ -<ul class="simple"> -<li><p>bullet</p></li> -<li><p>list</p></li> -</ul> -""", -], -["""\ -.. table:: - :align: right +"""}, + ], + ]) - +-----+-----+ - | 1 | 2 | - +-----+-----+ - | 3 | 4 | - +-----+-----+ -""", -"""\ -<table class="align-right"> -<tbody> -<tr><td><p>1</p></td> -<td><p>2</p></td> -</tr> -<tr><td><p>3</p></td> -<td><p>4</p></td> -</tr> -</tbody> -</table> -""", -], -["""\ -Not a docinfo. +totest['unknown-encoding'] = ({'output_encoding': 'unicode'}, [ + ['Simple String\n', + {'encoding': 'unicode', + 'fragment': '<p>Simple String</p>\n', + 'html_head': f'{default_parts["meta"]}<title>{{metatitle}}</title>\n', + 'meta': default_parts['meta'].removeprefix('<meta charset="%s" />\n'), + }], + ]) -:This: .. _target: - is -:a: -:simple: -:field: list -""", -"""\ -<p>Not a docinfo.</p> -<dl class="field-list simple"> -<dt>This<span class="colon">:</span></dt> -<dd><p id="target">is</p> -</dd> -<dt>a<span class="colon">:</span></dt> -<dd><p></p></dd> -<dt>simple<span class="colon">:</span></dt> -<dd><p></p></dd> -<dt>field<span class="colon">:</span></dt> -<dd><p>list</p> -</dd> -</dl> -""", -], -["""\ -Not a docinfo. - -:This is: a -:simple field list with loooong field: names -""", -"""\ -<p>Not a docinfo.</p> -<dl class="field-list simple"> -<dt>This is<span class="colon">:</span></dt> -<dd><p>a</p> -</dd> -<dt>simple field list with loooong field<span class="colon">:</span></dt> -<dd><p>names</p> -</dd> -</dl> -""", -], -["""\ -Not a docinfo. - -.. class:: field-indent-200 - -:This: is a -:simple: field list with custom indent. -""", -"""\ -<p>Not a docinfo.</p> -<dl class="field-list simple" style="--field-indent: 200px;"> -<dt>This<span class="colon">:</span></dt> -<dd><p>is a</p> -</dd> -<dt>simple<span class="colon">:</span></dt> -<dd><p>field list with custom indent.</p> -</dd> -</dl> -""", -], -["""\ -Not a docinfo. - -.. class:: field-indent-200uf - -:This: is a -:simple: field list without custom indent, - because the unit "uf" is invalid. -""", -"""\ -<p>Not a docinfo.</p> -<dl class="field-indent-200uf field-list simple"> -<dt>This<span class="colon">:</span></dt> -<dd><p>is a</p> -</dd> -<dt>simple<span class="colon">:</span></dt> -<dd><p>field list without custom indent, -because the unit "uf" is invalid.</p> -</dd> -</dl> -""", -], -["""\ -.. figure:: dummy.png - - The figure's caption. - - A legend. - - The legend's second paragraph. -""", -"""\ -<figure> -<img alt="dummy.png" src="dummy.png" /> -<figcaption> -<p>The figure's caption.</p> -<div class="legend"> -<p>A legend.</p> -<p>The legend's second paragraph.</p> -</div> -</figcaption> -</figure> -""", -], -["""\ -.. figure:: dummy.png - - The figure's caption, no legend. -""", -"""\ -<figure> -<img alt="dummy.png" src="dummy.png" /> -<figcaption> -<p>The figure's caption, no legend.</p> -</figcaption> -</figure> -""", -], -["""\ -.. figure:: dummy.png - - .. - - A legend without caption. -""", -"""\ -<figure> -<img alt="dummy.png" src="dummy.png" /> -<figcaption> -<div class="legend"> -<p>A legend without caption.</p> -</div> -</figcaption> -</figure> -""", -], -["""\ -.. figure:: dummy.png - -No caption nor legend. -""", -"""\ -<figure> -<img alt="dummy.png" src="dummy.png" /> -</figure> -<p>No caption nor legend.</p> -""", -], -[f"""\ -.. include:: {DATA_ROOT}/multiple-term-definition.xml - :parser: xml -""", -"""\ -<dl> -<dt>New in Docutils 0.22</dt> -<dd><p>A definition list item may contain several -terms with optional classifier(s).</p> -<p>However, there is currently no corresponding -reStructuredText syntax.</p> -</dd> -<dt>term 2a</dt> -<dt>term 2b</dt> -<dd><p>definition 2</p> -</dd> -<dt>term 3a<span class="classifier">classifier 3a</span><span class="classifier">classifier 3aa</span><dt>term 3b<span class="classifier">classifier 3b</span></dt> -<dd><p>definition 3</p> -</dd> -</dl> -""", -], -]) - - -totest['lazy_loading'] = ({'image_loading': 'lazy', - 'report_level': 4}, [ -["""\ -Lazy loading by default, overridden by :loading: option -("cannot embed" warning ignored). - -.. image:: dummy.png -.. image:: dummy.png - :loading: link -.. figure:: dummy.png -.. figure:: dummy.png - :loading: embed -""", -"""\ -<p>Lazy loading by default, overridden by :loading: option -("cannot embed" warning ignored).</p> -<img alt="dummy.png" loading="lazy" src="dummy.png" /> -<img alt="dummy.png" src="dummy.png" /> -<figure> -<img alt="dummy.png" loading="lazy" src="dummy.png" /> -</figure> -<figure> -<img alt="dummy.png" src="dummy.png" /> -</figure> -""", -], -]) - - -totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX, - 'image_loading': 'embed', - 'warning_stream': '', - }, [ -["""\ -.. image:: /data/blue%20square.png - :scale: 100% -.. figure:: /data/blue%20square.png -""", -'<img alt="/data/blue%20square.png" src="data:image/png;base64,' -'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAALElEQVR4nO3NMQ' -'EAMAjAsDFjvIhHFCbgSwU0kdXvsn96BwAAAAAAAAAAAIsNnEwBk52VRuMAAAAA' -'SUVORK5CYII="' -f' {SCALING_OUTPUT}/>\n{NO_PIL_SYSTEM_MESSAGE}' -'<figure>\n' -'<img alt="/data/blue%20square.png" src="data:image/png;base64,' -'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAALElEQVR4nO3NMQ' -'EAMAjAsDFjvIhHFCbgSwU0kdXvsn96BwAAAAAAAAAAAIsNnEwBk52VRuMAAAAA' -'SUVORK5CYII=" />\n' -'</figure>\n', -], -]) - - -totest['no_backlinks'] = ({'footnote_backlinks': False}, [ - -["""\ -Two footnotes [#f1]_ [#f2]_ and two citations [once]_ [twice]_. - -The latter are referenced a second time [#f2]_ [twice]_. - -.. [#f1] referenced once -.. [#f2] referenced twice -.. [once] citation referenced once -.. [twice] citation referenced twice -""", -"""\ -<p>Two footnotes <a class="brackets" href="#f1" id="footnote-reference-1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> <a class="brackets" href="#f2" id="footnote-reference-2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> and two citations <a class="citation-reference" href="#once" id="citation-reference-1" role="doc-biblioref">[once]</a> <a class="citation-reference" href="#twice" id="citation-reference-2" role="doc-biblioref">[twice]</a>.</p> -<p>The latter are referenced a second time <a class="brackets" href="#f2" id="footnote-reference-3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> <a class="citation-reference" href="#twice" id="citation-reference-3" role="doc-biblioref">[twice]</a>.</p> -<aside class="footnote-list brackets"> -<aside class="footnote brackets" id="f1" role="doc-footnote"> -<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span> -<p>referenced once</p> -</aside> -<aside class="footnote brackets" id="f2" role="doc-footnote"> -<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span> -<p>referenced twice</p> -</aside> -</aside> -<div role="list" class="citation-list"> -<div class="citation" id="once" role="doc-biblioentry"> -<span class="label"><span class="fn-bracket">[</span>once<span class="fn-bracket">]</span></span> -<p>citation referenced once</p> -</div> -<div class="citation" id="twice" role="doc-biblioentry"> -<span class="label"><span class="fn-bracket">[</span>twice<span class="fn-bracket">]</span></span> -<p>citation referenced twice</p> -</div> -</div> -""", -], -]) - - -totest['syntax_highlight'] = ({'syntax_highlight': 'short', - }, [ -["""\ -.. code:: shell - - cat <<EOF - Hello World - EOF -""", -"""\ -<pre class="code shell literal-block"><code>cat <span class="s"><<EOF -Hello World -EOF</span></code></pre> -""", -], -["""\ -.. role:: shell(code) - :language: shell - -:shell:`cat <<EOF Hello World EOF` -""", -"""\ -<p><code class="shell">cat <span class="s"><<EOF Hello World EOF</span></code></p> -""", -], -]) - - -totest['system_messages'] = ({'math_output': 'mathml', - 'warning_stream': '', - }, [ -["""\ -.. image:: https://dummy.png - :loading: embed -""", -"""\ -<img alt="https://dummy.png" src="https://dummy.png" /> -<aside class="system-message"> -<p class="system-message-title">System Message: ERROR/3 \ -(<span class="docutils literal"><string></span>, line 1)</p> -<p>Cannot embed image "https://dummy.png": - Can only read local images.</p> -</aside> -""", -], -[f"""\ -.. image:: {DATA_ROOT.as_uri()}/circle-broken.svg - :loading: embed -""", -f"""\ -<svg xmlns="http://www.w3.org/2000/svg" - viewBox="0 0 10 10"> - <circle cx="5" cy="5" r="4" fill="lightblue" x/> -</svg> - -<aside class="system-message"> -<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal"><string></span>, line 1)</p> -<p>Cannot parse SVG image "{DATA_ROOT.as_uri()}/circle-broken.svg": - not well-formed (invalid token): line 3, column 48</p> -</aside> -""" -], -[r"""Broken :math:`\sin \my`. -""", -"""\ -<p>Broken <span class="math problematic">\\sin \\my</span>.</p> -<aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal"><string></span>, line 1)</p> -<p>Unknown LaTeX command "\\my".</p> -</aside> -"""], -]) - -totest['system_messages-PIL'] = ({'math_output': 'mathml', - 'warning_stream': '', - }, [ -["""\ -.. image:: dummy.png - :scale: 100% - :loading: embed -""", -f"""\ -<img alt="dummy.png" src="dummy.png" /> -<aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 \ -(<span class="docutils literal"><string></span>, line 1)</p> -<p>Cannot scale image! - Could not get size from "dummy.png": - {DUMMY_PNG_NOT_FOUND}</p> -</aside> -<aside class="system-message"> -<p class="system-message-title">System Message: ERROR/3 \ -(<span class="docutils literal"><string></span>, line 1)</p> -<p>Cannot embed image "dummy.png": - [Errno 2] No such file or directory: 'dummy.png'</p> -</aside> -""", -], -["""\ -.. image:: dummy.mp4 - :scale: 100% -""", -f"""\ -<video src="dummy.mp4" title="dummy.mp4"> -<a href="dummy.mp4">dummy.mp4</a> -</video> -<aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 \ -(<span class="docutils literal"><string></span>, line 1)</p> -<p>Cannot scale image! - Could not get size from "dummy.mp4":{REQUIRES_PIL} - PIL cannot read video images.</p> -</aside> -""", -], -["""\ -.. image:: https://dummy.png - :scale: 100% - :loading: embed -""", -f"""\ -<img alt="https://dummy.png" src="https://dummy.png" /> -<aside class="system-message"> -<p class="system-message-title">System Message: WARNING/2 \ -(<span class="docutils literal"><string></span>, line 1)</p> -<p>Cannot scale image! - Could not get size from "https://dummy.png": - {ONLY_LOCAL}</p> -</aside> -<aside class="system-message"> -<p class="system-message-title">System Message: ERROR/3 \ -(<span class="docutils literal"><string></span>, line 1)</p> -<p>Cannot embed image "https://dummy.png": - Can only read local images.</p> -</aside> -""", -], -]) - -totest['no_system_messages'] = ({'math_output': 'mathml', - 'report_level': 4, - 'warning_stream': '', - }, [ -["""\ -.. image:: dummy.png - :scale: 100% - :loading: embed - -.. image:: dummy.mp4 - :scale: 100% -""", -"""\ -<img alt="dummy.png" src="dummy.png" /> -<video src="dummy.mp4" title="dummy.mp4"> -<a href="dummy.mp4">dummy.mp4</a> -</video> -""", -], -[f"""\ -.. image:: {DATA_ROOT.as_uri()}/circle-broken.svg - :loading: embed -""", -"""\ -<svg xmlns="http://www.w3.org/2000/svg" - viewBox="0 0 10 10"> - <circle cx="5" cy="5" r="4" fill="lightblue" x/> -</svg> - -"""], -[r'Broken :math:`\sin \my`.', -'<p>Broken <tt class="math">\\sin \\my</tt>.</p>\n' -], -]) - - if __name__ == '__main__': unittest.main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-21 13:44:40
|
Revision: 9912 http://sourceforge.net/p/docutils/code/9912 Author: milde Date: 2024-08-21 13:44:37 +0000 (Wed, 21 Aug 2024) Log Message: ----------- HTML writer: Fix part "html_head" if "output_encoding" setting is 'unicode'. If the output encoding is not determined, part "head" does not contain a "charset" `<meta>` element. So we must not drop the first element from "head" when completing "html_head". Fixup for [r9240]. Modified Paths: -------------- trunk/docutils/docutils/writers/_html_base.py trunk/docutils/test/test_writers/test_html5_polyglot_parts.py Modified: trunk/docutils/docutils/writers/_html_base.py =================================================================== --- trunk/docutils/docutils/writers/_html_base.py 2024-08-21 08:05:47 UTC (rev 9911) +++ trunk/docutils/docutils/writers/_html_base.py 2024-08-21 13:44:37 UTC (rev 9912) @@ -963,8 +963,12 @@ self.head.extend(self.math_header) else: self.stylesheet.extend(self.math_header) - # skip content-type meta tag with interpolated charset value: - self.html_head.extend(self.head[1:]) + if (self.settings.output_encoding # may be None + and self.settings.output_encoding.lower() != 'unicode'): + # skip content-type meta tag with interpolated charset value: + self.html_head.extend(self.head[1:]) + else: + self.html_head.extend(self.head) self.body_prefix.append(self.starttag(node, **self.documenttag_args)) self.body_suffix.insert(0, f'</{self.documenttag_args["tagname"]}>\n') self.fragment.extend(self.body) # self.fragment is the "naked" body Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2024-08-21 08:05:47 UTC (rev 9911) +++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2024-08-21 13:44:37 UTC (rev 9912) @@ -84,7 +84,7 @@ settings_overrides={ '_disable_config': True, 'strict_visitor': True, - 'stylesheet': '', + 'stylesheet_path': '', 'section_self_link': True, **settings_overrides, } @@ -143,8 +143,7 @@ totest = {} -totest['standard'] = ({'stylesheet_path': '', - 'embed_stylesheet': False}, [ +totest['standard'] = ({}, [ ["""\ Simple String """, @@ -288,12 +287,22 @@ }], ]) -totest['no_title_promotion'] = ({'doctitle_xform': False, - 'stylesheet_path': '', - 'embed_stylesheet': False}, [ +totest['standard'] = ({'output_encoding': 'unicode'}, [ ["""\ Simple String """, +{'fragment': '<p>Simple String</p>\n', + 'meta': """\ +<meta name="generator" content="Docutils 0.22b.dev: https://docutils.sourceforge.io/" /> +<meta name="viewport" content="width=device-width, initial-scale=1" /> +""", +}], +]) + +totest['no_title_promotion'] = ({'doctitle_xform': False}, [ +["""\ +Simple String +""", '<p>Simple String</p>\n', ], ["""\ @@ -574,8 +583,6 @@ totest['lazy_loading'] = ({'image_loading': 'lazy', - 'stylesheet_path': '', - 'embed_stylesheet': False, 'report_level': 4}, [ ["""\ Lazy loading by default, overridden by :loading: option @@ -606,9 +613,7 @@ totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX, 'image_loading': 'embed', - 'stylesheet_path': '', 'warning_stream': '', - 'embed_stylesheet': False }, [ ["""\ .. image:: /data/blue%20square.png @@ -630,9 +635,7 @@ ]) -totest['no_backlinks'] = ({'footnote_backlinks': False, - 'stylesheet_path': '', - 'embed_stylesheet': False}, [ +totest['no_backlinks'] = ({'footnote_backlinks': False}, [ ["""\ Two footnotes [#f1]_ [#f2]_ and two citations [once]_ [twice]_. @@ -673,7 +676,6 @@ totest['syntax_highlight'] = ({'syntax_highlight': 'short', - 'stylesheet_path': '', }, [ ["""\ .. code:: shell @@ -701,9 +703,7 @@ ]) -totest['system_messages'] = ({'stylesheet_path': '', - 'embed_stylesheet': False, - 'math_output': 'mathml', +totest['system_messages'] = ({'math_output': 'mathml', 'warning_stream': '', }, [ ["""\ @@ -748,9 +748,7 @@ """], ]) -totest['system_messages-PIL'] = ({'stylesheet_path': '', - 'embed_stylesheet': False, - 'math_output': 'mathml', +totest['system_messages-PIL'] = ({'math_output': 'mathml', 'warning_stream': '', }, [ ["""\ @@ -816,9 +814,7 @@ ], ]) -totest['no_system_messages'] = ({'stylesheet_path': '', - 'embed_stylesheet': False, - 'math_output': 'mathml', +totest['no_system_messages'] = ({'math_output': 'mathml', 'report_level': 4, 'warning_stream': '', }, [ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-21 08:05:49
|
Revision: 9911 http://sourceforge.net/p/docutils/code/9911 Author: milde Date: 2024-08-21 08:05:47 +0000 (Wed, 21 Aug 2024) Log Message: ----------- Revert test template file extension from "rst" to "txt". A test sample of a custom HTML template files got accidentially renamed to "full-template.rst". However, it is not reStructuredText. Fixup for [r9906]. Modified Paths: -------------- trunk/docutils/test/test_writers/test_html4css1_template.py trunk/docutils/test/test_writers/test_html5_template.py Added Paths: ----------- trunk/docutils/test/data/full-template.txt Removed Paths: ------------- trunk/docutils/test/data/full-template.rst Deleted: trunk/docutils/test/data/full-template.rst =================================================================== --- trunk/docutils/test/data/full-template.rst 2024-08-18 14:56:56 UTC (rev 9910) +++ trunk/docutils/test/data/full-template.rst 2024-08-21 08:05:47 UTC (rev 9911) @@ -1,106 +0,0 @@ -head_prefix = """\ -%(head_prefix)s""" - - -head = """\ -%(head)s""" - - -stylesheet = """\ -%(stylesheet)s""" - - -body_prefix = """\ -%(body_prefix)s""" - - -body_pre_docinfo = """\ -%(body_pre_docinfo)s""" - - -docinfo = """\ -%(docinfo)s""" - - -body = """\ -%(body)s""" - - -body_suffix = """\ -%(body_suffix)s""" - - -head_prefix = """\ -%(head_prefix)s""" - - -head = """\ -%(head)s""" - - -stylesheet = """\ -%(stylesheet)s""" - - -body_prefix = """\ -%(body_prefix)s""" - - -body_pre_docinfo = """\ -%(body_pre_docinfo)s""" - - -docinfo = """\ -%(docinfo)s""" - - -body = """\ -%(body)s""" - - -body_suffix = """\ -%(body_suffix)s""" - - -title = """\ -%(title)s""" - - -subtitle = """\ -%(subtitle)s""" - - -header = """\ -%(header)s""" - - -footer = """\ -%(footer)s""" - - -meta = """\ -%(meta)s""" - - -fragment = """\ -%(fragment)s""" - - -html_prolog = """\ -%(html_prolog)s""" - - -html_head = """\ -%(html_head)s""" - - -html_title = """\ -%(html_title)s""" - - -html_subtitle = """\ -%(html_subtitle)s""" - - -html_body = """\ -%(html_body)s""" Copied: trunk/docutils/test/data/full-template.txt (from rev 9910, trunk/docutils/test/data/full-template.rst) =================================================================== --- trunk/docutils/test/data/full-template.txt (rev 0) +++ trunk/docutils/test/data/full-template.txt 2024-08-21 08:05:47 UTC (rev 9911) @@ -0,0 +1,106 @@ +head_prefix = """\ +%(head_prefix)s""" + + +head = """\ +%(head)s""" + + +stylesheet = """\ +%(stylesheet)s""" + + +body_prefix = """\ +%(body_prefix)s""" + + +body_pre_docinfo = """\ +%(body_pre_docinfo)s""" + + +docinfo = """\ +%(docinfo)s""" + + +body = """\ +%(body)s""" + + +body_suffix = """\ +%(body_suffix)s""" + + +head_prefix = """\ +%(head_prefix)s""" + + +head = """\ +%(head)s""" + + +stylesheet = """\ +%(stylesheet)s""" + + +body_prefix = """\ +%(body_prefix)s""" + + +body_pre_docinfo = """\ +%(body_pre_docinfo)s""" + + +docinfo = """\ +%(docinfo)s""" + + +body = """\ +%(body)s""" + + +body_suffix = """\ +%(body_suffix)s""" + + +title = """\ +%(title)s""" + + +subtitle = """\ +%(subtitle)s""" + + +header = """\ +%(header)s""" + + +footer = """\ +%(footer)s""" + + +meta = """\ +%(meta)s""" + + +fragment = """\ +%(fragment)s""" + + +html_prolog = """\ +%(html_prolog)s""" + + +html_head = """\ +%(html_head)s""" + + +html_title = """\ +%(html_title)s""" + + +html_subtitle = """\ +%(html_subtitle)s""" + + +html_body = """\ +%(html_body)s""" Modified: trunk/docutils/test/test_writers/test_html4css1_template.py =================================================================== --- trunk/docutils/test/test_writers/test_html4css1_template.py 2024-08-18 14:56:56 UTC (rev 9910) +++ trunk/docutils/test/test_writers/test_html4css1_template.py 2024-08-21 08:05:47 UTC (rev 9911) @@ -30,7 +30,7 @@ # maxDiff = None def test_publish(self): writer = 'html4' - template_path = TEST_ROOT / 'data/full-template.rst' + template_path = TEST_ROOT / 'data/full-template.txt' for name, cases in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): Modified: trunk/docutils/test/test_writers/test_html5_template.py =================================================================== --- trunk/docutils/test/test_writers/test_html5_template.py 2024-08-18 14:56:56 UTC (rev 9910) +++ trunk/docutils/test/test_writers/test_html5_template.py 2024-08-21 08:05:47 UTC (rev 9911) @@ -21,6 +21,7 @@ import docutils from docutils.core import publish_string +from docutils.writers import html5_polyglot # TEST_ROOT is ./test/ from the docutils root TEST_ROOT = Path(__file__).parents[1] @@ -29,14 +30,13 @@ class WriterPublishTestCase(unittest.TestCase): # maxDiff = None def test_publish(self): - writer = 'html5' - template_path = TEST_ROOT / 'data/full-template.rst' + template_path = TEST_ROOT / 'data/full-template.txt' for name, cases in totest.items(): for casenum, (case_input, case_expected) in enumerate(cases): with self.subTest(id=f'totest[{name!r}][{casenum}]'): output = publish_string( source=case_input, - writer=writer, + writer=html5_polyglot.Writer(), settings_overrides={ '_disable_config': True, 'strict_visitor': True, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-18 14:56:58
|
Revision: 9910 http://sourceforge.net/p/docutils/code/9910 Author: milde Date: 2024-08-18 14:56:56 +0000 (Sun, 18 Aug 2024) Log Message: ----------- Review "docutils.utils" after type hint addition. Use the same alias name for `str | os.PathLike[str]` also in parsers.rst.directives.misc. Formatting: more concise function defs, blank line after summary in multi-line docstrings. Simplify initialization of utils.DependencyList. Modified Paths: -------------- trunk/docutils/docutils/parsers/rst/directives/misc.py trunk/docutils/docutils/utils/__init__.py Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py =================================================================== --- trunk/docutils/docutils/parsers/rst/directives/misc.py 2024-08-15 16:35:34 UTC (rev 9909) +++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2024-08-18 14:56:56 UTC (rev 9910) @@ -31,13 +31,10 @@ from docutils.nodes import Node - PathString: TypeAlias = str | os.PathLike[str] - """File system path.""" + StrPath: TypeAlias = str | os.PathLike[str] + """File system path. No bytes!""" - SourceString: TypeAlias = str | os.PathLike[str] - """Path to or informal description of a Docutils input source.""" - def adapt_path(path: str, source='', root_prefix='/') -> str: # Adapt path to files to include or embed. # `root_prefix` is prepended to absolute paths (cf. root_prefix setting), @@ -121,7 +118,7 @@ self.insert_into_input_lines(inputstring) return [] - def read_file(self, path: PathString) -> str: + def read_file(self, path: StrPath) -> str: """Read text file at `path`. Clip and return content. Provisional. Modified: trunk/docutils/docutils/utils/__init__.py =================================================================== --- trunk/docutils/docutils/utils/__init__.py 2024-08-15 16:35:34 UTC (rev 9909) +++ trunk/docutils/docutils/utils/__init__.py 2024-08-18 14:56:56 UTC (rev 9910) @@ -36,15 +36,14 @@ from docutils.nodes import Node from docutils.frontend import Values - _StrPath: TypeAlias = str | os.PathLike[str] + StrPath: TypeAlias = str | os.PathLike[str] _ObserverFunc: TypeAlias = Callable[[nodes.system_message], None] class SystemMessage(ApplicationError): - def __init__( - self, system_message: nodes.system_message, level: int, - ) -> None: + def __init__(self, system_message: nodes.system_message, level: int, + ) -> None: Exception.__init__(self, system_message.astext()) self.level = level @@ -85,17 +84,10 @@ """ # Reporter.get_source_and_line is patched in by ``RSTState.runtime_init`` - get_source_and_line: Callable[ - [int | None], tuple[_StrPath | None, int | None] - ] + get_source_and_line: Callable[[int|None], tuple[StrPath|None, int|None]] levels: Final[Sequence[str]] = ( - 'DEBUG', - 'INFO', - 'WARNING', - 'ERROR', - 'SEVERE', - ) + 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'SEVERE') """List of names for system message levels, indexed by level.""" # system message level constants: @@ -106,16 +98,17 @@ SEVERE_LEVEL: Final = 4 def __init__( - self, - source: _StrPath, - report_level: int, - halt_level: int, - stream: io.ErrorOutput | TextIO | str | Literal[False] | None = None, - debug: bool = False, - encoding: str | None = None, - error_handler: str = 'backslashreplace', - ) -> None: - """ + self, + source: StrPath, + report_level: int, + halt_level: int, + stream: io.ErrorOutput|TextIO|str|Literal[False]|None = None, + debug: bool = False, + encoding: str|None = None, + error_handler: str = 'backslashreplace', + ) -> None: + """Low level instantiating. See also `new_reporter().`. + :Parameters: - `source`: The path to or description of the source data. - `report_level`: The level at or above which warning output will @@ -230,51 +223,47 @@ self.max_level = max(level, self.max_level) return msg - def debug( - self, *args: Node, **kwargs: Any - ) -> nodes.system_message: + def debug(self, *args: Node, **kwargs: Any) -> nodes.system_message: """ - Level-0, "DEBUG": an internal reporting issue. Typically, there is no - effect on the processing. Level-0 system messages are handled - separately from the others. + Level-0, "DEBUG": an internal reporting issue. + + Typically, there is no effect on the processing. Level-0 system + messages are handled separately from the others. """ if self.debug_flag: return self.system_message(self.DEBUG_LEVEL, *args, **kwargs) - def info( - self, *args: Node, **kwargs: Any - ) -> nodes.system_message: + def info(self, *args: Node, **kwargs: Any) -> nodes.system_message: """ - Level-1, "INFO": a minor issue that can be ignored. Typically there is - no effect on processing, and level-1 system messages are not reported. + Level-1, "INFO": a minor issue that can be ignored. + + Typically, there is no effect on processing and level-1 system + messages are not reported. """ return self.system_message(self.INFO_LEVEL, *args, **kwargs) - def warning( - self, *args: Node, **kwargs: Any - ) -> nodes.system_message: + def warning(self, *args: Node, **kwargs: Any) -> nodes.system_message: """ - Level-2, "WARNING": an issue that should be addressed. If ignored, - there may be unpredictable problems with the output. + Level-2, "WARNING": an issue that should be addressed. + + If ignored, there may be unpredictable problems with the output. """ return self.system_message(self.WARNING_LEVEL, *args, **kwargs) - def error( - self, *args: Node, **kwargs: Any - ) -> nodes.system_message: + def error(self, *args: Node, **kwargs: Any) -> nodes.system_message: """ - Level-3, "ERROR": an error that should be addressed. If ignored, the - output will contain errors. + Level-3, "ERROR": an error that should be addressed. + + If ignored, the output will contain errors. """ return self.system_message(self.ERROR_LEVEL, *args, **kwargs) - def severe( - self, *args: Node, **kwargs: Any - ) -> nodes.system_message: + def severe(self, *args: Node, **kwargs: Any) -> nodes.system_message: """ - Level-4, "SEVERE": a severe error that must be addressed. If ignored, - the output will contain severe errors. Typically level-4 system - messages are turned into exceptions which halt processing. + Level-4, "SEVERE": a severe error that must be addressed. + + If ignored, the output will contain severe errors. Typically level-4 + system messages are turned into exceptions which halt processing. """ return self.system_message(self.SEVERE_LEVEL, *args, **kwargs) @@ -312,9 +301,8 @@ return assemble_option_dict(option_list, options_spec) -def extract_options( - field_list: nodes.field_list -) -> list[tuple[str, str | None]]: +def extract_options(field_list: nodes.field_list + ) -> list[tuple[str, str|None]]: """ Return a list of option (name, value) pairs from field names & bodies. @@ -349,7 +337,7 @@ return option_list -def assemble_option_dict(option_list: list[tuple[str, str | None]], +def assemble_option_dict(option_list: list[tuple[str, str|None]], options_spec: dict[str, Callable[object], Any], ) -> dict[str, Any]: """ @@ -387,11 +375,13 @@ class NameValueError(DataError): pass -def decode_path(path: str | None | bytes) -> str: +def decode_path(path: str|bytes|None) -> str: """ Ensure `path` is Unicode. Return `str` instance. Decode file/path string in a failsafe manner if not already done. + + Deprecated. """ # TODO: is this still required with Python 3? if isinstance(path, str): @@ -400,7 +390,7 @@ return '' try: path = path.decode(sys.getfilesystemencoding(), 'strict') - except AttributeError: # default value None has no decode method + except AttributeError: raise ValueError('`path` value must be a String or ``None``, ' f'not {path!r}') except UnicodeDecodeError: @@ -456,7 +446,7 @@ return attlist -def new_reporter(source_path: _StrPath, settings: Values) -> Reporter: +def new_reporter(source_path: StrPath, settings: Values) -> Reporter: """ Return a new Reporter object. @@ -474,8 +464,7 @@ return reporter -def new_document(source_path: _StrPath, - settings: Values | None = None +def new_document(source_path: StrPath, settings: Values|None = None ) -> nodes.document: """ Return a new empty document object. @@ -514,9 +503,9 @@ def clean_rcs_keywords( - paragraph: nodes.paragraph, - keyword_substitutions: Sequence[tuple[re.Pattern[[str], str]]], -) -> None: + paragraph: nodes.paragraph, + keyword_substitutions: Sequence[tuple[re.Pattern[[str], str]]], + ) -> None: if len(paragraph) == 1 and isinstance(paragraph[0], nodes.Text): textnode = paragraph[0] for pattern, substitution in keyword_substitutions: @@ -526,7 +515,7 @@ return -def relative_path(source: _StrPath | None, target: _StrPath) -> str: +def relative_path(source: StrPath|None, target: StrPath) -> str: """ Build and return a path to `target`, relative to `source` (both files). @@ -582,7 +571,7 @@ def get_stylesheet_reference(settings: Values, - relative_to: _StrPath | None = None + relative_to: StrPath|None = None ) -> str: """ Retrieve a stylesheet reference from the settings object. @@ -616,9 +605,7 @@ # (if required, use ``utils.relative_path(source, target)`` # in the calling script) def get_stylesheet_list(settings: Values) -> list[str]: - """ - Retrieve list of stylesheet references from the settings object. - """ + """Retrieve list of stylesheet references from the settings object.""" assert not (settings.stylesheet and settings.stylesheet_path), ( 'stylesheet and stylesheet_path are mutually exclusive.') stylesheets = settings.stylesheet_path or settings.stylesheet or [] @@ -632,7 +619,7 @@ return stylesheets -def find_file_in_dirs(path: _StrPath, dirs: Iterable[_StrPath]) -> str: +def find_file_in_dirs(path: StrPath, dirs: Iterable[StrPath]) -> str: """ Search for `path` in the list of directories `dirs`. @@ -663,7 +650,7 @@ return settings.trim_footnote_reference_space -def get_source_line(node: Node) -> tuple[_StrPath | None, int | None]: +def get_source_line(node: Node) -> tuple[StrPath|None, int|None]: """ Return the "source" and "line" attributes from the `node` given or from its closest ancestor. @@ -789,7 +776,7 @@ return taglist -def xml_declaration(encoding: str | Literal['unicode'] | None = None) -> str: +def xml_declaration(encoding: str|Literal['unicode']|None = None) -> str: """Return an XML text declaration. Include an encoding declaration, if `encoding` @@ -812,8 +799,8 @@ """ def __init__(self, - output_file: Literal['-'] | _StrPath | None = None, - dependencies: Iterable[_StrPath] = () + output_file: Literal['-'] | StrPath | None = None, + dependencies: Iterable[StrPath] = () ) -> None: """ Initialize the dependency list, automatically setting the @@ -822,28 +809,28 @@ If output_file is None, no file output is done when calling add(). """ - self.list = [] - self.file: TextIO | None = None - if output_file: - self.set_output(output_file) + self.set_output(output_file) self.add(*dependencies) - def set_output(self, output_file: Literal['-'] | _StrPath) -> None: + def set_output(self, output_file: Literal['-']|StrPath|None) -> None: """ Set the output file and clear the list of already added dependencies. - `output_file` must be a string. The specified file is - immediately overwritten. + The specified file is immediately overwritten. - If output_file is '-', the output will be written to stdout. + If `output_file` is '-', the output will be written to stdout. + The empty string or None stop output. """ if output_file == '-': self.file = sys.stdout elif output_file: self.file = open(output_file, 'w', encoding='utf-8') + else: + self.file = None + self.list = [] - def add(self, *paths: _StrPath) -> None: + def add(self, *paths: StrPath) -> None: """ Append `path` to `self.list` unless it is already there. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2024-08-15 16:35:37
|
Revision: 9909 http://sourceforge.net/p/docutils/code/9909 Author: milde Date: 2024-08-15 16:35:34 +0000 (Thu, 15 Aug 2024) Log Message: ----------- Refactor "Include" directive class. Disentangle actions and simplify interface of auxiliary methods. `Include.run()` sets up instance attributes and calls helper functions to read the file content and process it according to the options. (Helper methods depend on setup in `run()`.) Input sanity checks (too long lines and circular inclusions) are only required when when inserting the file content into the "input_lines" of the calling parser (which did these checks on the other "input_lines" before starting to parsing it). Adapt formatting. Adapt tests. Use shorter URL to the "include" directive documentation. Modified Paths: -------------- trunk/docutils/docutils/parsers/rst/directives/misc.py trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py =================================================================== --- trunk/docutils/docutils/parsers/rst/directives/misc.py 2024-08-15 14:14:24 UTC (rev 9908) +++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2024-08-15 16:35:34 UTC (rev 9909) @@ -9,6 +9,7 @@ __docformat__ = 'reStructuredText' import re +import sys import time from pathlib import Path from typing import TYPE_CHECKING @@ -23,11 +24,21 @@ if TYPE_CHECKING: import os + if sys.version_info[:2] >= (3, 12): + from typing import TypeAlias + else: + from typing_extensions import TypeAlias from docutils.nodes import Node + PathString: TypeAlias = str | os.PathLike[str] + """File system path.""" -def adapt_path(path, source='', root_prefix='/'): + SourceString: TypeAlias = str | os.PathLike[str] + """Path to or informal description of a Docutils input source.""" + + +def adapt_path(path: str, source='', root_prefix='/') -> str: # Adapt path to files to include or embed. # `root_prefix` is prepended to absolute paths (cf. root_prefix setting), # `source` is the `current_source` of the including directive (which may @@ -52,7 +63,7 @@ start and end line or text to match before and/or after the text to be used. - https://docutils.sourceforge.io/docs/ref/rst/directives.html#including-an-external-document-fragment + https://docutils.sourceforge.io/docs/ref/rst/directives.html#include """ required_arguments = 1 @@ -68,7 +79,7 @@ 'start-after': directives.unchanged_required, 'end-before': directives.unchanged_required, # ignored except for 'literal' or 'code': - 'number-lines': directives.unchanged, # integer or None + 'number-lines': directives.value_or((None,), int), 'class': directives.class_option, 'name': directives.unchanged} @@ -77,14 +88,17 @@ def run(self) -> list[Node]: """Include a file as part of the content of this reST file. - Depending on the options, the file (or a clipping) is + Depending on the options, the file content (or a clipping) is converted to nodes and returned or inserted into the input stream. """ - settings = self.state.document.settings + self.settings = settings = self.state.document.settings if not settings.file_insertion_enabled: raise self.warning('"%s" directive disabled.' % self.name) - tab_width = self.options.get('tab-width', settings.tab_width) - current_source = self.state.document.current_source + self.tab_width = self.options.get('tab-width', settings.tab_width) + self.clip_options = (self.options.get('start-line', None), + self.options.get('end-line', None), + self.options.get('start-after', ''), + self.options.get('end-before', '')) path = directives.path(self.arguments[0]) if path.startswith('<') and path.endswith('>'): path = '/' + path[1:-1] @@ -91,152 +105,92 @@ root_prefix = self.standard_include_path else: root_prefix = settings.root_prefix - path = adapt_path(path, current_source, root_prefix) - rawtext, clip_options = self._read_source(path) - include_lines = statemachine.string2lines(rawtext, tab_width, - convert_whitespace=True) - for i, line in enumerate(include_lines): - if len(line) > settings.line_length_limit: - raise self.warning('"%s": line %d exceeds the' - ' line-length-limit.' % (path, i+1)) + path = adapt_path(path, + self.state.document.current_source, + root_prefix) + self.options['source'] = path + inputstring = self.read_file(path) + if 'literal' in self.options: - return self.include_literal_block( - source=path, - rawtext=rawtext, - tab_width=tab_width, - include_lines=include_lines, - ) - + return self.as_literal_block(inputstring) if 'code' in self.options: - return self.include_code_block( - source=path, - rawtext=rawtext, - tab_width=tab_width, - include_lines=include_lines, - ) - - # Prevent circular inclusion: - include_log = self.state.document.include_log - # log entries are tuples (<source>, <clip-options>) - if not include_log: # new document, initialize with document source - include_log.append((utils.relative_path(None, current_source), - (None, None, None, None))) - if (path, clip_options) in include_log: - master_paths = (pth for (pth, opt) in reversed(include_log)) - inclusion_chain = '\n> '.join((path, *master_paths)) - raise self.warning('circular inclusion in "%s" directive:\n%s' - % (self.name, inclusion_chain)) - + return self.as_code_block(inputstring) if 'parser' in self.options: - return self.include_parsed( - source=path, - include_lines=include_lines, - clip_options=clip_options, - ) - - # Include as rST source: - self.include_text( - rawtext, - source=path, - tab_width=tab_width, - include_lines=include_lines, - ) - # update include-log - include_log.append((path, clip_options)) + return self.custom_parse(inputstring) + self.insert_into_input_lines(inputstring) return [] - def _read_source( - self, source: str | os.PathLike[str], /, - ) -> tuple[str, tuple[int | None, int | None, str | None, str | None]]: - """Read and clip the content of *source*.""" - settings = self.state.document.settings - encoding = self.options.get('encoding', settings.input_encoding) - error_handler = settings.input_encoding_error_handler + def read_file(self, path: PathString) -> str: + """Read text file at `path`. Clip and return content. + + Provisional. + """ + encoding = self.options.get('encoding', self.settings.input_encoding) + error_handler = self.settings.input_encoding_error_handler try: - include_file = io.FileInput( - source_path=source, - encoding=encoding, - error_handler=error_handler, - ) + include_file = io.FileInput(source_path=path, + encoding=encoding, + error_handler=error_handler) except UnicodeEncodeError: raise self.severe(f'Problems with "{self.name}" directive path:\n' - f'Cannot encode input file path "{source}" ' + f'Cannot encode input file path "{path}" ' '(wrong locale?).') except OSError as error: - raise self.severe(f'Problems with "{self.name}" directive ' - f'path:\n{io.error_string(error)}.') + raise self.severe(f'Problems with "{self.name}" directive path:\n' + f'{io.error_string(error)}.') else: - settings.record_dependencies.add(source) - - # Get to-be-included content - startline = self.options.get('start-line', None) - endline = self.options.get('end-line', None) + self.settings.record_dependencies.add(path) try: - if startline or (endline is not None): - lines = include_file.readlines() - rawtext = ''.join(lines[startline:endline]) - else: - rawtext = include_file.read() + text = include_file.read() except UnicodeError as error: raise self.severe(f'Problem with "{self.name}" directive:\n' + io.error_string(error)) + # Clip to-be-included content + startline, endline, starttext, endtext = self.clip_options + if startline or (endline is not None): + lines = text.splitlines() + text = '\n'.join(lines[startline:endline]) # start-after/end-before: no restrictions on newlines in match-text, # and no restrictions on matching inside lines vs. line boundaries - after_text = self.options.get('start-after', None) - if after_text: - # skip content in rawtext before *and incl.* a matching text - after_index = rawtext.find(after_text) + if starttext: + # skip content in text before *and incl.* a matching text + after_index = text.find(starttext) if after_index < 0: - raise self.severe('Problem with "start-after" option of "%s" ' - 'directive:\nText not found.' % self.name) - rawtext = rawtext[after_index + len(after_text):] - before_text = self.options.get('end-before', None) - if before_text: - # skip content in rawtext after *and incl.* a matching text - before_index = rawtext.find(before_text) + raise self.severe('Problem with "start-after" option of ' + f'"{self.name}" directive:\nText not found.') + text = text[after_index + len(starttext):] + if endtext: + # skip content in text after *and incl.* a matching text + before_index = text.find(endtext) if before_index < 0: - raise self.severe('Problem with "end-before" option of "%s" ' - 'directive:\nText not found.' % self.name) - rawtext = rawtext[:before_index] + raise self.severe('Problem with "end-before" option of ' + f'"{self.name}" directive:\nText not found.') + text = text[:before_index] + return text - clip_options = (startline, endline, before_text, after_text) - return rawtext, clip_options + def as_literal_block(self, text: str) -> list[nodes.literal_block]: + """Return list with literal_block containing `text`. - def include_literal_block( - self, - *, - source: str | os.PathLike[str], - rawtext: str, - include_lines: list[str], - tab_width: int, - ) -> list[nodes.literal_block]: - """Return the content from *source* as a literal block.""" - # Don't convert tabs to spaces, if `tab_width` is negative. - if tab_width >= 0: - text = rawtext.expandtabs(tab_width) - else: - text = rawtext + Provisional + """ + source = self.options['source'] + # Convert tabs to spaces unless `tab_width` is negative. + if self.tab_width >= 0: + text = text.expandtabs(self.tab_width) literal_block = nodes.literal_block( - rawtext, source=source, - classes=self.options.get('class', [])) - literal_block.line = 1 + '', source=source, classes=self.options.get('class', [])) + literal_block.source = source + literal_block.line = self.options.get('start-line', 0) + 1 self.add_name(literal_block) if 'number-lines' in self.options: - try: - startline = int(self.options['number-lines'] or 1) - except ValueError: - msg = ':number-lines: with non-integer start value' - raise self.error(msg) - endline = startline + len(include_lines) - if text.endswith('\n'): - text = text[:-1] - tokens = NumberLines([([], text)], startline, endline) + firstline = self.options['number-lines'] or 1 + text = text.removesuffix('\n') + lastline = firstline + len(text.splitlines()) + tokens = NumberLines([([], text)], firstline, lastline) for classes, value in tokens: if classes: - literal_block += nodes.inline( - value, value, classes=classes, - ) + literal_block += nodes.inline('', value, classes=classes) else: literal_block += nodes.Text(value) else: @@ -243,50 +197,41 @@ literal_block += nodes.Text(text) return [literal_block] - def include_code_block( - self, - *, - source: str | os.PathLike[str], - rawtext: str, - include_lines: list[str], - tab_width: int, - ) -> list[nodes.literal_block]: - """Return the content from *source* as a code block.""" - self.options['source'] = source - # Don't convert tabs to spaces, if `tab_width` is negative: - if tab_width < 0: - include_lines = rawtext.splitlines() - codeblock = CodeBlock( - self.name, - [self.options.pop('code')], # arguments - self.options, - include_lines, # content - self.lineno, - self.content_offset, - self.block_text, - self.state, - self.state_machine, - ) + def as_code_block(self, text: str) -> list[nodes.literal_block]: + """Pass `text` to the `CodeBlock` directive class. + + Provisional. + """ + # convert tabs to spaces unless `tab_width` is negative: + if self.tab_width >= 0: + text = text.expandtabs(self.tab_width) + codeblock = CodeBlock(self.name, + [self.options.pop('code')], # pass as argument + self.options, + [text.removesuffix('\n')], # content + self.lineno, + self.content_offset, + self.block_text, + self.state, + self.state_machine, + ) return codeblock.run() - def include_parsed( - self, - *, - source: str | os.PathLike[str], - include_lines: list[str], - clip_options: tuple[int | str, int | str, str, str], - ) -> list[Node]: - """Return content from *source* after parsing with the given parser.""" - settings = self.state.document.settings - include_log = self.state.document.include_log + def custom_parse(self, text: str) -> list[Node]: + """Parse with custom parser. - # parse into a dummy document and return created nodes - _settings = settings.copy() - _settings._source = source - document = utils.new_document(source, _settings) - document.include_log = include_log + [(source, clip_options)] + Parse with ``self.options['parser']`` into a new (dummy) document, + apply the parser's default transforms, + return child elements. + + Provisional. + """ + settings = self.settings.copy() + settings._source = self.options['source'] + document = utils.new_document(settings._source, settings) + document.include_log = self.state.document.include_log parser = self.options['parser']() - parser.parse('\n'.join(include_lines), document) + parser.parse(text, document) self.state.document.parse_messages.extend(document.parse_messages) # clean up doctree and complete parsing document.transformer.populate_from_components((parser,)) @@ -295,26 +240,42 @@ document.transform_messages) return document.children - def include_text( - self, - text: str, - *, - source: str | os.PathLike[str], - tab_width: int, - include_lines: list[str] | None = None, - ) -> None: - """Insert *text* into the input stream.""" - # *text* is passed for use in subclasses, but if we have already - # split the lines and nothing is changing, reuse those lines. - if include_lines is not None: - include_lines = statemachine.string2lines( - text, tab_width, convert_whitespace=True, - ) - # Mark end (cf. parsers.rst.states.Body.comment()) - include_lines += ['', '.. end of inclusion from "%s"' % source] - self.state_machine.insert_input(include_lines, source) + def insert_into_input_lines(self, text: str) -> None: + """Insert file content into the rST input of the calling parser. + Returns an empty list to comply with the API of `Directive.run()`. + Provisional. + """ + source = self.options['source'] + textlines = statemachine.string2lines(text, self.tab_width, + convert_whitespace=True) + # Sanity checks: + # excessively long lines + for i, line in enumerate(textlines): + if len(line) > self.settings.line_length_limit: + line_no = i + 1 + self.options.get('start-line', 0) + raise self.warning(f'"{source}": line {line_no} exceeds the' + ' line-length-limit.') + # circular inclusion + include_log = self.state.document.include_log + if not include_log: # new document, initialize with document source + current_source = utils.relative_path( + None, self.state.document.current_source) + include_log.append((current_source, (None, None, '', ''))) + if (source, self.clip_options) in include_log: + source_chain = (pth for (pth, opt) in reversed(include_log)) + inclusion_chain = '\n> '.join((source, *source_chain)) + raise self.warning(f'circular inclusion in "{self.name}"' + f' directive:\n{inclusion_chain}') + include_log.append((source, self.clip_options)) + # marker for removing log entry (cf. parsers.rst.states.Body.comment()) + textlines += ['', f'.. end of inclusion from "{source}"'] + + self.state_machine.insert_input(textlines, source) + # TODO: if startline != 0, line numbers are wrong. + + class Raw(Directive): """ Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py =================================================================== --- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2024-08-15 14:14:24 UTC (rev 9908) +++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2024-08-15 16:35:34 UTC (rev 9909) @@ -1457,7 +1457,6 @@ {include15} > {include16} > {include15} - > test data <literal_block xml:space="preserve"> .. include:: include15.rst <paragraph> Modified: trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py =================================================================== --- trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py 2024-08-15 14:14:24 UTC (rev 9908) +++ trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py 2024-08-15 16:35:34 UTC (rev 9909) @@ -35,6 +35,8 @@ class ParserTestCase(unittest.TestCase): + maxDiff = None + def test_parser(self): parser = Parser() settings = get_default_settings(Parser) @@ -77,7 +79,6 @@ ============ .. include:: {docutils_conf} - :literal: A paragraph. """, @@ -91,10 +92,30 @@ "{docutils_conf}": line 5 exceeds the line-length-limit. <literal_block xml:space="preserve"> .. include:: {docutils_conf} - :literal: <paragraph> A paragraph. """], +[f"""\ +Include Test 2 + +.. include:: {docutils_conf} + :start-line: 3 + +A paragraph. +""", +f"""\ +<document source="test data"> + <paragraph> + Include Test 2 + <system_message level="2" line="3" source="test data" type="WARNING"> + <paragraph> + "{docutils_conf}": line 5 exceeds the line-length-limit. + <literal_block xml:space="preserve"> + .. include:: {docutils_conf} + :start-line: 3 + <paragraph> + A paragraph. +"""], ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gr...@us...> - 2024-08-15 14:14:45
|
Revision: 9908 http://sourceforge.net/p/docutils/code/9908 Author: grubert Date: 2024-08-15 14:14:24 +0000 (Thu, 15 Aug 2024) Log Message: ----------- Fix file corruption on rename to rst Modified Paths: -------------- trunk/docutils/test/data/utf-16-le-sig.rst Modified: trunk/docutils/test/data/utf-16-le-sig.rst =================================================================== --- trunk/docutils/test/data/utf-16-le-sig.rst 2024-08-15 09:02:52 UTC (rev 9907) +++ trunk/docutils/test/data/utf-16-le-sig.rst 2024-08-15 14:14:24 UTC (rev 9908) @@ -1 +1 @@ -\xFF\xFEG +\xFF\xFEG\ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gr...@us...> - 2024-08-15 09:02:54
|
Revision: 9907 http://sourceforge.net/p/docutils/code/9907 Author: grubert Date: 2024-08-15 09:02:52 +0000 (Thu, 15 Aug 2024) Log Message: ----------- rename README.txt to rst Added Paths: ----------- trunk/docutils/docutils/parsers/rst/include/README.rst Removed Paths: ------------- trunk/docutils/docutils/parsers/rst/include/README.txt Copied: trunk/docutils/docutils/parsers/rst/include/README.rst (from rev 9906, trunk/docutils/docutils/parsers/rst/include/README.txt) =================================================================== --- trunk/docutils/docutils/parsers/rst/include/README.rst (rev 0) +++ trunk/docutils/docutils/parsers/rst/include/README.rst 2024-08-15 09:02:52 UTC (rev 9907) @@ -0,0 +1,17 @@ +============================================ + ``docutils/parsers/rst/include`` Directory +============================================ + +This directory contains standard data files intended for inclusion in +reStructuredText documents. To access these files, use the "include" +directive with the special syntax for standard "include" data files, +angle brackets around the file name:: + + .. include:: <isonum.txt> + +See the documentation for the `"include" directive`__ and +`reStructuredText Standard Definition Files`__ for +details. + +__ https://docutils.sourceforge.io/docs/ref/rst/directives.html#include +__ https://docutils.sourceforge.io/docs/ref/rst/definitions.html Deleted: trunk/docutils/docutils/parsers/rst/include/README.txt =================================================================== --- trunk/docutils/docutils/parsers/rst/include/README.txt 2024-08-15 08:43:38 UTC (rev 9906) +++ trunk/docutils/docutils/parsers/rst/include/README.txt 2024-08-15 09:02:52 UTC (rev 9907) @@ -1,17 +0,0 @@ -============================================ - ``docutils/parsers/rst/include`` Directory -============================================ - -This directory contains standard data files intended for inclusion in -reStructuredText documents. To access these files, use the "include" -directive with the special syntax for standard "include" data files, -angle brackets around the file name:: - - .. include:: <isonum.txt> - -See the documentation for the `"include" directive`__ and -`reStructuredText Standard Definition Files`__ for -details. - -__ https://docutils.sourceforge.io/docs/ref/rst/directives.html#include -__ https://docutils.sourceforge.io/docs/ref/rst/definitions.html This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |