From ba3ef64508062fc0fa45a3606674e77026efbfdf Mon Sep 17 00:00:00 2001 From: milde Date: Thu, 30 Jan 2020 00:44:15 +0000 Subject: [PATCH] html5: Use semantic tags
,
,
,

reStructuredText Test Document

@@ -164,32 +162,32 @@ They are transformed from section titles after parsing. -->
  • 5 Error Handling

  • -
    +

    1 Structural Elements

    -
    +

    1.1 Section Title

    Section Subtitle

    Lone subsections are converted to a section subtitle by a transform activated with the --section-subtitles command line option or the sectsubtitle-xform configuration value.

    -
    -
    +
    +

    1.2 Empty Section

    -
    -
    + +

    1.3 Transitions

    Here's a transition:


    It divides the section. Transitions may also occur between sections:

    -
    - + +
    -
    +

    2 Body Elements

    -
    +

    2.1 Paragraphs

    A paragraph.

    -
    +

    2.1.1 Inline Markup

    Paragraphs contain text and may contain inline markup: emphasis, strong emphasis, inline literals, standalone hyperlinks @@ -216,9 +214,9 @@ a superscript and explicit roles for Docutils' This is an example of --inline-literal --text, --including some-- strangely--hyphenated-words. Adjust-the-width-of-your-browser-window to see how the text is wrapped. -- ---- -------- Now note the spacing between the words of this sentence (words should be grouped in pairs).

    If the --pep-references option was supplied, there should be a live link to PEP 258 here.

    -
    -
    -
    +
    + +

    2.2 Bullet Lists

    • A bullet list

      @@ -244,8 +242,8 @@ live link to PEP 258 here.

    -
    -
    + +

    2.3 Enumerated Lists

    1. Arabic numerals.

      @@ -280,8 +278,8 @@ live link to PEP 258 here.

    -
    -
    + +

    2.4 Definition Lists

    Term
    @@ -298,8 +296,8 @@ live link to PEP 258 here.

    Definition

    -
    -
    + +

    2.5 Field Lists

    what
    @@ -318,8 +316,8 @@ about credits but just for ensuring that the class attribute doesn't get stripped away.)

    -
    -
    + +

    2.6 Option Lists

    For listing command-line options:

    @@ -357,8 +355,8 @@ regardless of where it starts.

    There must be at least two spaces between the option and the description.

    -
    -
    + +

    2.7 Literal Blocks

    Literal blocks are indicated with a double-colon ("::") at the end of the preceding paragraph (over there -->). They can be indented:

    @@ -370,8 +368,8 @@ the preceding paragraph (over there >> Great idea! > > Why didn't I think of that? -
    -
    + +

    2.8 Line Blocks

    This section tests line blocks. Line blocks are body elements which consist of lines and other line blocks. Nested line blocks cause @@ -444,8 +442,8 @@ also be centre-aligned:

    w.

    - -
    + +

    2.9 Block Quotes

    Block quotes consist of indented body elements:

    @@ -463,16 +461,16 @@ a class attribute:

    ReStructuredText est un langage de balisage léger utilisé notamment dans la documentation du langage Python.

    -
    -
    + +

    2.10 Doctest Blocks

    >>> print 'Python-specific usage examples; begun with ">>>"'
     Python-specific usage examples; begun with ">>>"
     >>> print '(cut and pasted from interactive Python sessions)'
     (cut and pasted from interactive Python sessions)
     
    -
    -
    + +

    2.11 Footnotes

    1(1,2,3)
    @@ -504,8 +502,8 @@ Here's a reference to the next footnote: [5]_.

    -
    -
    + +

    2.12 Citations

    CIT2002(1,2)
    @@ -515,8 +513,8 @@ rendered separately and differently from footnotes.

    Here's a reference to the above, [CIT2002], and a [nonexistent]_ citation.

    -
    -
    + +

    2.13 Targets

    This paragraph is pointed to by the explicit "example" target. A reference can be found under Inline Markup, above. Inline @@ -529,20 +527,20 @@ hyperlink targets are also possible.

    refer to the Targets section.

    Here's a `hyperlink reference without a target`_, which generates an error.

    -
    +

    2.13.1 Duplicate Target Names

    Duplicate names in section headers or other implicit targets will generate "info" (level-1) system messages. Duplicate names in explicit targets will generate "warning" (level-2) system messages.

    -
    -
    +
    +

    2.13.2 Duplicate Target Names

    Since there are two "Duplicate Target Names" section headers, we cannot uniquely refer to either of them by name. If we try to (like this: `Duplicate Target Names`_), an error is generated.

    -
    - -
    + + +

    2.14 Directives

    +

    2.14.2 Images and Figures

    An image directive (also clickable -- a hyperlink reference):

    ../../../docs/user/rst/images/title.png @@ -747,8 +745,8 @@ writer/backend).

    -
    -
    + +

    2.14.3 Admonitions

    Attention!

    @@ -796,11 +794,11 @@ Reader discretion is strongly advised.

    And, by the way...

    You can make up your own admonition too.

    -
    -
    + +

    2.14.4 Topics, Sidebars, and Rubrics

    Sidebars are like miniature, parallel documents.

    - +

    A topic is like a block quote with a title, or a self-contained section with no subsections.

    @@ -820,8 +818,8 @@ document's structure. It is typically highlighted in red (hence the name).

    This is a rubric

    Topics and rubrics can be used at places where a section title is not allowed (e.g. inside a directive).

    -
    -
    +
    +

    2.14.5 Target Footnotes

    7(1,2,3,4)
    @@ -849,12 +847,12 @@ allowed (e.g. inside a directive).

    https://html.spec.whatwg.org/multipage/edits.html

    -
    -
    + +

    2.14.6 Replacement Text

    I recommend you try Python, the best language around 7.

    -
    -
    + +

    2.14.7 Compound Paragraph

    The compound directive is used to create a "compound paragraph", which is a single logical paragraph containing multiple physical body @@ -964,8 +962,8 @@ by

    and the final paragraph of the compound 7.

    - -
    + +

    2.14.8 Parsed Literal Blocks

    This is a parsed literal block.
         This line is indented.  The next line is blank.
    @@ -974,8 +972,8 @@ Inline markup is supported, e.g. emphasis, strong, , sub- and superscripts,
     inline formulas: A = 2πr2,
     footnotes 1, hyperlink targets, and references.
    -
    -
    + +

    2.14.9 Code

    Blocks of source code can be set with the code directive. If the code language is specified, the content is parsed and tagged by the Pygments 8 @@ -999,15 +997,15 @@ paragraph.

    as a code block, here the rst file header_footer.txt with line numbers:

    1 .. header:: Document header
     2 .. footer:: Document footer
    -
    - -
    + + +

    2.15 Substitution Definitions

    An inline image (EXAMPLE) example:

    A Unicode example:

    (Substitution definitions are not visible in the HTML source.)

    -
    -
    + +

    2.16 Comments

    Here's one:

    (View the HTML source to see the comment.)

    -
    -
    + +

    2.17 Raw text

    This does not necessarily look nice, because there may be missing white space.

    It's just there to freeze the behavior.

    A test.Second test.
    Another test with myclass set.

    This is the fourth test with myrawroleclass set.

    -Fifth test in HTML.
    Line two.
    -
    +Fifth test in HTML.
    Line two. +

    2.18 Container

    paragraph 1

    paragraph 2

    -
    -
    + +

    2.19 Colspanning tables

    This table has a cell spanning two columns:

    @@ -1069,8 +1067,8 @@ Fifth test in HTML.
    Line two.
    -
    -
    + +

    2.20 Rowspanning tables

    Here's a table with cells spanning several rows:

    @@ -1102,8 +1100,8 @@ cell.

    -
    -
    + +

    2.21 Complex tables

    Here's a complex table, which should test all features.

    @@ -1151,8 +1149,8 @@ empty: -->

    -
    -
    + +

    2.22 List Tables

    Here's a list table exercising all features:

    @@ -1198,8 +1196,8 @@ crunchy, now would it?

    -
    -
    + +

    2.23 Custom Roles

    • A role based on an existing role.

      @@ -1226,11 +1224,11 @@ crunchy, now would it?

      British colourful text in small-caps.

    -
    - -
    + + +

    3 HTML specific

    -
    +

    3.1 SVG Images

    ../../../docs/user/rst/images/biohazard.svg

    Scalable vector graphics (SVG) images are the only standards-compliable way @@ -1314,8 +1312,8 @@ tags.

    Figure: SVG image in a figure.

    -
    -
    + +

    3.2 SWF Images

    Shockwave Flash is an image/movie format that most modern web browsers support via a plugin. It is sometimes blocked due to privacy/security @@ -1326,8 +1324,8 @@ For complete control over display options use raw HTML.

    [biohazard.swf]

    An SWF image in a 4 cm x 2 em box, left aligned.

    An inline SWF image inline-swf scaled to 0.8 em x 0.8 em.

    -
    -
    + +

    3.3 Text-level semantics

    HTML 5 tags for representation of text-level semantics 13 and their reStructuredText equivalents.

    @@ -1531,8 +1529,8 @@ a substitution.

    -
    -
    + +

    3.4 Indicating Edits

    HTML tags for representation of edits to the document 14 and their reStructuredText equivalents.

    @@ -1566,9 +1564,9 @@ to inline roles. See +
    + +

    4 Changes to the html4css1 writer

    • Use only meta keywords recognized by HTML 5.

    • @@ -1579,7 +1577,7 @@ roles to make sense.

      space.

    • Put subtitles in <p> elements.

    -
    +

    4.1 Field list handling

    The following list demonstrates the problems with the html4css1 approach: the field-name-limit setting is given in "number of @@ -1622,12 +1620,12 @@ example:

    must not lead to misalignment of the following content.

    -
    -
    +
    +

    4.2 Styling with class arguments

    The plain.css style sheet comes with some pre-defined style variants that can be choosen via a class argument.

    -
    +

    4.2.1 Description lists

    Definition lists with the "description" class argument:

    @@ -1642,8 +1640,8 @@ encyclopedias etc. (as well as the LaTeX description environment).<

    Starts on the same line and has a hanging indent.

    -
    -
    +
    +

    4.2.2 Field list variants

    For field lists, the "compact/open", "narrow" and "run-in" styles are defined in the style sheet plain.css.

    @@ -1709,8 +1707,8 @@ body is wrapped and aligns with other fields.

    -
    -
    + +

    4.2.3 Table variants

    The following styles can be applied to individual tables via a class argument or as document wide setting with the table-style 10 configuration @@ -1789,17 +1787,17 @@ from the +

    + + +

    5 Error Handling

    Any errors caught during processing will generate system messages.

    There should be five messages in the following, auto-generated section, "Docutils System Messages":

    -
    -
    + +

    Docutils System Messages

    System Message: ERROR/3 (functional/input/data/standard.txt, line 104); backlink

    @@ -1821,13 +1819,12 @@ section, "Docutils System Messages":

    System Message: ERROR/3 (functional/input/data/standard.txt, line 441); backlink

    Duplicate target name, cannot be used as a unique reference: "duplicate target names".

    +
    - - + diff --git a/docutils/test/test_writers/test_html5_polyglot_parts.py b/docutils/test/test_writers/test_html5_polyglot_parts.py index efef182c7..f3bf17ee5 100644 --- a/docutils/test/test_writers/test_html5_polyglot_parts.py +++ b/docutils/test/test_writers/test_html5_polyglot_parts.py @@ -13,7 +13,9 @@ standard values, and any entries with empty values. """ from __future__ import absolute_import -from . import DocutilsTestSupport +if __name__ == '__main__': + import __init__ +from test_transforms import DocutilsTestSupport # must be imported before docutils from DocutilsTestSupport import (HtmlWriterPublishPartsTestCase, HtmlPublishPartsTestSuite) from docutils import core, __version__ @@ -140,26 +142,26 @@ And even more stuff """, """\ {'fragment': '''

    Some stuff

    -
    +

    Section

    Some more stuff

    -
    +

    Another Section

    And even more stuff

    -
    -
    \\n''', + +\\n''', 'html_body': '''

    Title

    Subtitle

    Some stuff

    -
    +

    Section

    Some more stuff

    -
    +

    Another Section

    And even more stuff

    -
    -
    + +
    \\n''', 'html_head': '''...Title\\n''', 'html_subtitle': '''

    Subtitle

    \\n''', @@ -279,37 +281,37 @@ Another Section And even more stuff """, """\ -{'fragment': '''
    +{'fragment': '''

    Title

    -
    +

    Not A Subtitle

    Some stuff

    -
    +

    Section

    Some more stuff

    -
    +

    Another Section

    And even more stuff

    -
    -
    -
    -
    \\n''', + + + +\\n''', 'html_body': '''
    -
    +

    Title

    -
    +

    Not A Subtitle

    Some stuff

    -
    +

    Section

    Some more stuff

    -
    +

    Another Section

    And even more stuff

    -
    -
    -
    -
    + + + +
    \\n''', 'html_head': '''...<string>\\n'''} """], -- 2.11.4.GIT