From 98b3ef27bf9e97120ce93aeb2a032811be821581 Mon Sep 17 00:00:00 2001 From: milde Date: Sat, 21 Feb 2015 16:59:18 +0000 Subject: [PATCH] New HTML writer generating `XHTML1.1`_ styled with CSS2. Moved to the docutils core from sandbox/html4strict. .. _XHTML1.1: http://www.w3.org/TR/xhtml11/ git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7798 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/HISTORY.txt | 20 +- docutils/RELEASE-NOTES.txt | 7 +- docutils/docutils/writers/html4css1/__init__.py | 6 +- .../docutils/writers/xhtml11}/__init__.py | 44 +- .../docutils/writers/xhtml11/xhtml11.css | 0 docutils/setup.py | 2 +- .../expected/standalone_rst_xhtml11.xhtml | 1076 ++++---------------- .../test/functional/input/data/xhtml11.css | 0 .../functional/input/standalone_rst_xhtml11.txt | 4 +- .../functional/tests/standalone_rst_xhtml11.py | 18 + .../tools/rst2xhtml11.py | 7 +- sandbox/html4strict/README.txt | 63 +- 12 files changed, 311 insertions(+), 936 deletions(-) rename {sandbox/html4strict/html4strict => docutils/docutils/writers/xhtml11}/__init__.py (92%) copy sandbox/html4strict/html4strict/html4css2.css => docutils/docutils/writers/xhtml11/xhtml11.css (100%) rename sandbox/html4strict/data/standalone_rst_html4strict.xhtml => docutils/test/functional/expected/standalone_rst_xhtml11.xhtml (69%) rename sandbox/html4strict/html4strict/html4css2.css => docutils/test/functional/input/data/xhtml11.css (100%) rename sandbox/html4strict/data/standalone_rst_html4strict.txt => docutils/test/functional/input/standalone_rst_xhtml11.txt (98%) create mode 100644 docutils/test/functional/tests/standalone_rst_xhtml11.py rename sandbox/html4strict/tools/rst2html_strict.py => docutils/tools/rst2xhtml11.py (86%) diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index a71b08cb6..879cd6455 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -26,24 +26,32 @@ Changes Since 0.12 * docutils/parsers/rst/directives/tables.py - - patch [ 120 ] tables accept option widths: list of relative widths, 'auto' + - patch [ 120 ] tables accept option widths: list of relative widths, 'auto' or 'grid'. * docutils/utils/math/math2html.py - add ``\colon`` macro, fix spacing around colons. Fixes [ 246 ]. - -* docutils/writers/html4css1/__init__.py + +* docutils/writers/html4css1/__init__.py - Add "docutils" to class values for "container" object to address [ 267 ]. - Apply patch [ 119 ] by Anatoly Techtonik: use absolute paths for ``default_stylesheet_path`` and ``default_template_path``. -* docutils/writers/latex2e/__init__.py +* docutils/writers/xhtml11/ + + - New HTML writer generating `XHTML1.1`_ styled with CSS2. + + Moved to the docutils core from sandbox/html4strict. + + .. _XHTML1.1: http://www.w3.org/TR/xhtml11/ + +* docutils/writers/latex2e/__init__.py - use absolute path for ``default_template_path``. -* docutils/writers/odf_odt/__init__.py +* docutils/writers/odf_odt/__init__.py - remove decode.encode of filename stored in zip. @@ -62,7 +70,7 @@ Release 0.12 (2014-07-06) * docutils/parsers/rst/directives/images.py - Fix [ 258 ] figwidth="image" generates unitless width value. - + * docutils/parsers/rst/states.py - Improve error report when a non-ASCII character is specified as diff --git a/docutils/RELEASE-NOTES.txt b/docutils/RELEASE-NOTES.txt index e351d73af..1a0270f68 100644 --- a/docutils/RELEASE-NOTES.txt +++ b/docutils/RELEASE-NOTES.txt @@ -22,6 +22,11 @@ Future changes * remove the `handle_io_errors` option from io.FileInput/Output. +* remove deprecated options from the latex2e writer: + + --use-latex-footnotes Alias for --docutils-footnotes (deprecated) + --figure-footnotes Use figure floats for footnote text (deprecated) + * »Prune« the doctree (no change to the reST input syntax): - "doctest" element -> literal block with class argument, @@ -29,7 +34,7 @@ Future changes element with class attribute and auto-generated title. * Move to single source for Python 2 and Python 3, slowly. - See `Porting Python 2 Code to Python 3`_ and + See `Porting Python 2 Code to Python 3`_ and `future: clean single-source support for Python 2/3`_ - Drop support for python 2.4 probably after 0.12 release. diff --git a/docutils/docutils/writers/html4css1/__init__.py b/docutils/docutils/writers/html4css1/__init__.py index c28dacb23..6cc10cab4 100644 --- a/docutils/docutils/writers/html4css1/__init__.py +++ b/docutils/docutils/writers/html4css1/__init__.py @@ -42,7 +42,7 @@ class Writer(writers.Writer): supported = ('html', 'html4css1', 'xhtml') """Formats this writer supports.""" - default_stylesheet = 'html4css1.css' + default_stylesheets = ['html4css1.css'] default_stylesheet_dirs = ['.', os.path.abspath(os.path.dirname(__file__))] default_template = 'template.txt' @@ -65,11 +65,11 @@ class Writer(writers.Writer): 'Relative paths are expanded if a matching file is found in ' 'the --stylesheet-dirs. With --link-stylesheet, ' 'the path is rewritten relative to the output HTML file. ' - 'Default: "%s"' % default_stylesheet, + 'Default: "%s"' % ','.join(default_stylesheets), ['--stylesheet-path'], {'metavar': '', 'overrides': 'stylesheet', 'validator': frontend.validate_comma_separated_list, - 'default': [default_stylesheet]}), + 'default': default_stylesheets}), ('Embed the stylesheet(s) in the output HTML file. The stylesheet ' 'files must be accessible during processing. This is the default.', ['--embed-stylesheet'], diff --git a/sandbox/html4strict/html4strict/__init__.py b/docutils/docutils/writers/xhtml11/__init__.py similarity index 92% rename from sandbox/html4strict/html4strict/__init__.py rename to docutils/docutils/writers/xhtml11/__init__.py index a4f2418ac..259e726ac 100644 --- a/sandbox/html4strict/html4strict/__init__.py +++ b/docutils/docutils/writers/xhtml11/__init__.py @@ -37,29 +37,41 @@ class Writer(html4css1.Writer): supported = ('html', 'xhtml', 'xhtml1', 'html4strict', 'xhtml1strict', - 'html4css2', 'xhtml1css2') + 'xhtml11', 'xhtml1css2') """Formats this writer supports.""" - default_stylesheets = ['html4css1.css', 'html4css2.css'] + default_stylesheets = ['html4css1.css', 'xhtml11.css'] + default_stylesheet_dirs = ['.', + os.path.abspath(os.path.dirname(__file__)), + os.path.abspath(os.path.join( + os.path.dirname(os.path.dirname(__file__)), 'html4css1')) + ] - default_stylesheet_path = ','.join( - [os.path.join(os.path.dirname(__file__), stylesheet) - for stylesheet in default_stylesheets]) - - config_section = 'html4strict writer' + config_section = 'xhtml11 writer' config_section_dependencies = ('writers', 'html4css1 writer') settings_spec = frontend.filter_settings_spec( html4css1.Writer.settings_spec, - 'field_name_limit', 'option_limit', + 'field_name_limit', 'option_limit', # removed options stylesheet_path = ( - 'Specify comma separated list of stylesheet paths. ' - 'With --link-stylesheet, ' - 'the path is rewritten relative to the output HTML file. ' - 'Default: "%s"' % default_stylesheet_path, - ['--stylesheet-path'], - {'metavar': '', 'overrides': 'stylesheet', - 'default': default_stylesheet_path}), + 'Comma separated list of stylesheet paths. ' + 'Relative paths are expanded if a matching file is found in ' + 'the --stylesheet-dirs. With --link-stylesheet, ' + 'the path is rewritten relative to the output HTML file. ' + 'Default: "%s"' % ','.join(default_stylesheets), + ['--stylesheet-path'], + {'metavar': '', 'overrides': 'stylesheet', + 'validator': frontend.validate_comma_separated_list, + 'default': default_stylesheets}), + + stylesheet_dirs = ( + 'Comma-separated list of directories where stylesheets are found. ' + 'Used by --stylesheet-path when expanding relative path arguments. ' + 'Default: "%s"' % default_stylesheet_dirs, + ['--stylesheet-dirs'], + {'metavar': '', + 'validator': frontend.validate_comma_separated_list, + 'default': default_stylesheet_dirs}), math_output = ('Math output format, one of "MathML", "HTML", ' '"MathJax" or "LaTeX". Default: "MathML"', ['--math-output'], @@ -73,7 +85,7 @@ class Writer(html4css1.Writer): class HTMLTranslator(html4css1.HTMLTranslator): """ This writer generates XHTML 1.1 - without formatting hints that interfere with a CSS stylesheet. + without formatting that interferes with a CSS stylesheet. """ doctype = ('\n') diff --git a/sandbox/html4strict/html4strict/html4css2.css b/docutils/docutils/writers/xhtml11/xhtml11.css similarity index 100% copy from sandbox/html4strict/html4strict/html4css2.css copy to docutils/docutils/writers/xhtml11/xhtml11.css diff --git a/docutils/setup.py b/docutils/setup.py index 51b5dadd0..5a5e0492a 100755 --- a/docutils/setup.py +++ b/docutils/setup.py @@ -135,7 +135,7 @@ what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60 'docutils.utils.math', 'docutils.writers', 'docutils.writers.html4css1', - # 'docutils.writers.html4strict', # in the sandbox! + 'docutils.writers.xhtml11', 'docutils.writers.pep_html', 'docutils.writers.s5_html', 'docutils.writers.latex2e', diff --git a/sandbox/html4strict/data/standalone_rst_html4strict.xhtml b/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml similarity index 69% rename from sandbox/html4strict/data/standalone_rst_html4strict.xhtml rename to docutils/test/functional/expected/standalone_rst_xhtml11.xhtml index f3e755a2c..88d1984e7 100644 --- a/sandbox/html4strict/data/standalone_rst_html4strict.xhtml +++ b/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml @@ -3,7 +3,7 @@ - + reStructuredText Test Document @@ -12,672 +12,8 @@ - - + +
@@ -694,7 +30,7 @@ div.hint, div.important, div.note, div.tip, div.warning {
Author
David Goodger
Address
-
+
 123 Example Street
 Example, EX  Canada
 A1B 2C3
@@ -749,96 +85,93 @@ They are transformed from section titles after parsing. -->
 

Table of Contents

-

1 Structural Elements

+

1 Structural Elements

-

1.1 Section Title

+

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.3 Transitions

+

1.3 Transitions

Here's a transition:


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

@@ -846,29 +179,31 @@ activated with the --section-subtitles
-

2 Body Elements

+

2 Body Elements

-

2.1 Paragraphs

+

2.1 Paragraphs

A paragraph.

-

2.1.1 Inline Markup

+

2.1.1 Inline Markup

Paragraphs contain text and may contain inline markup: emphasis, strong emphasis, inline literals, standalone hyperlinks -(http://www.python.org), external hyperlinks (Python5), internal +(http://www.python.org), external hyperlinks (Python [5]), internal cross-references (example), external hyperlinks with embedded URIs (Python web site), anonymous hyperlink -references5 (a second reference8), footnote references (manually -numbered1, anonymous auto-numbered3, labeled auto-numbered2, or symbolic*), citation references ([CIT2002]), +references [5] (a second reference [9]), footnote references (manually +numbered [1], anonymous auto-numbered [3], labeled auto-numbered +[2], or symbolic [*]), citation references ([CIT2002]), substitution references (EXAMPLE), and inline hyperlink targets (see Targets below for a reference back to here). Character-level -inline markup is also possible (although exceedingly ugly!) in reStructuredText. Problems are indicated by |problematic| text +inline markup is also possible (although exceedingly ugly!) in reStructuredText. Problems are indicated by |problematic| text (generated by processing errors; this one is intentional). Here is a reference to the doctitle and the subtitle.

The default role for interpreted text is Title Reference. Here are some explicit interpreted text roles: a PEP reference (PEP 287); an -RFC reference (RFC 2822); a subscript; a superscript; -and explicit roles for standard inline -markup.

+RFC reference (RFC 2822); an abbreviation (abb.), an acronym +(reST), code (print "hello world"); a subscript; +a superscript and explicit roles for Docutils' +standard inline markup.

Let's test wrapping and whitespace significance in inline literals: 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).

@@ -877,7 +212,7 @@ live link to PEP 258 here.

-

2.2 Bullet Lists

+

2.2 Bullet Lists

  • A bullet list

      @@ -904,7 +239,7 @@ live link to PEP 258 here.

-

2.3 Enumerated Lists

+

2.3 Enumerated Lists

  1. Arabic numerals.

      @@ -940,7 +275,7 @@ live link to PEP 258 here.

-

2.4 Definition Lists

+

2.4 Definition Lists

Term

Definition

@@ -958,7 +293,7 @@ live link to PEP 258 here.

-

2.5 Field Lists

+

2.5 Field Lists

what

Field lists map field names to field bodies, like database @@ -978,7 +313,7 @@ doesn't get stripped away.)

-

2.6 Option Lists

+

2.6 Option Lists

For listing command-line options:

-a
@@ -1017,24 +352,22 @@ regardless of where it starts.

description.

-

2.7 Literal Blocks

+

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:

-
-if literal_block:
+
if literal_block:
     text = 'is left as-is'
     spaces_and_linebreaks = 'are preserved'
     markup_processing = None
 

Or they can be quoted without indentation:

-
->> Great idea!
+
>> Great idea!
 >
 > Why didn't I think of that?
 
-

2.8 Line Blocks

+

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 indentation.

@@ -1108,7 +441,7 @@ also be centre-aligned:

-

2.9 Block Quotes

+

2.9 Block Quotes

Block quotes consist of indented body elements:

My theory by A. Elk. Brackets Miss, brackets. This theory goes @@ -1127,114 +460,114 @@ notamment dans la documentation du langage Python.

-

2.10 Doctest Blocks

-
->>> print 'Python-specific usage examples; begun with ">>>"'
+

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
+

2.11 Footnotes

+
[1]
(1, 2, 3)

A footnote contains body elements, consistently indented by at least 3 spaces.

This is the footnote's second paragraph.

-
2
+
[2]
-(1, 2)

Footnotes may be numbered, either manually (as in1) or +(1, 2)

Footnotes may be numbered, either manually (as in [1]) or automatically using a "#"-prefixed label. This footnote has a label so it can be referred to from multiple places, both as a -footnote reference (2) and as a hyperlink reference.

+footnote reference ([2]) and as a hyperlink reference.

-
3
+
[3]

This footnote is numbered automatically and anonymously using a label of "#" only.

This is the second paragraph.

And this is the third paragraph.

-
*
+
[*]

Footnotes may also use symbols, specified with a "*" label. -Here's a reference to the next footnote:.

+Here's a reference to the next footnote: [†].

-
+
[†]

This footnote shows the next symbol in the sequence.

-
4
+
[4]

Here's an unreferenced footnote, with a reference to a -nonexistent footnote:[5]_.

+nonexistent footnote: [5]_.

-

2.12 Citations

+

2.12 Citations

[CIT2002]
(1, 2)

Citations are text-labeled footnotes. They may be rendered separately and differently from footnotes.

-

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

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

-

2.13 Targets

+

2.13 Targets

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

Section headers are implicit targets, referred to by name. See Targets, which is a subsection of Body Elements.

Explicit external targets are interpolated into references such as -"Python5".

+"Python [5]".

Targets may be indirect and anonymous. Thus this phrase may also refer to the Targets section.

-

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

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

-

2.13.1 Duplicate Target Names

+

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

+

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.

+this: `Duplicate Target Names`_), an error is generated.

-

2.14 Directives

+

2.14 Directives

These are just a sample of the many reStructuredText Directives. For others, please see http://docutils.sourceforge.net/docs/ref/rst/directives.html.

-

2.14.1 Document Parts

+

2.14.1 Document Parts

An example of the "contents" directive can be seen above this section (a local, untitled table of contents) and at the beginning of the document (a document-wide table of contents).

-

2.14.2 Images and Figures

+

2.14.2 Images and Figures

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

../../../docs/user/rst/images/title.png

Image with multiple IDs:

@@ -1273,7 +606,7 @@ layout.

- +

re

Revised, revisited, based on 're' module.

@@ -1325,7 +658,7 @@ rendering software used.

upon the style sheet and the browser or rendering software used.

-

2.14.3 Admonitions

+

2.14.3 Admonitions

Attention!

Directives at large.

@@ -1374,7 +707,7 @@ Reader discretion is strongly advised.

-

2.14.4 Topics, Sidebars, and Rubrics

+

2.14.4 Topics, Sidebars, and Rubrics

Sidebars are like miniature, parallel documents.

-

2.14.7 Compound Paragraph

+

2.14.7 Compound Paragraph

Compound 1, paragraph 1.

Compound 1, paragraph 2.

@@ -1434,8 +771,7 @@ allowed (e.g. inside a directive).

Another compound statement:

Compound 2, a literal block:

-
-Compound 2, literal.
+
Compound 2, literal.
 

Compound 2, this is a test.

@@ -1443,8 +779,7 @@ Compound 2, literal.

Compound 3, only consisting of one paragraph.

-
-Compound 4.
+
Compound 4.
 This one starts with a literal block.
 

Compound 4, a paragraph.

@@ -1468,7 +803,7 @@ meaningful.

- +

Left cell, first paragraph.

Left cell, second @@ -1490,23 +825,51 @@ paragraph.

-

2.14.8 Parsed Literal Blocks

-
-This is a parsed literal block.
+

2.14.8 Parsed Literal Blocks

+
This is a parsed literal block.
     This line is indented.  The next line is blank.
 
 Inline markup is supported, e.g. emphasis, strong, literal
-text, footnotes1, hyperlink targets, and references.
+text, 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 [6] +syntax highlighter and can be formatted with a style sheet. (Code parsing +is turned off using the syntax-highlight config setting in the test +conversions in order to get identical results with/without installed +Pygments highlighter.)

+
print 'This is Python code.'
+
+

The :number-lines: option (with optional start value) generates line +numbers:

+
 8 # print integers from 0 to 9:
+ 9 for i in range(10):
+10     print i
+
+

For inline code snippets, there is the code role, which can be used +directly (the code will not be parsed/tagged, as the language is not known) +or as base for special code roles, e.g. the LaTeX code in the next +paragraph.

+

Docutils uses LaTeX syntax for math directives and roles: +\alpha = f(x) prints +α=f(x).

+

The :code: option of the include directive sets the included content +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

+

2.15 Substitution Definitions

An inline image (EXAMPLE) example:

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

-

2.16 Comments

+

2.16 Comments

Here's one:

(View the HTML source to see the comment.)

-

2.17 Raw text

+

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.
-

2.18 Container

-
+

2.18 Container

+

paragraph 1

paragraph 2

-

2.19 Colspanning tables

+

2.19 Colspanning tables

This table has a cell spanning two columns:

@@ -1548,7 +911,7 @@ Fifth test in HTML.
Line two. - + @@ -1569,7 +932,7 @@ Fifth test in HTML.
Line two.

A or B

False

False

False

-

2.20 Rowspanning tables

+

2.20 Rowspanning tables

Here's a table with cells spanning several rows:

@@ -1584,7 +947,7 @@ Fifth test in HTML.
Line two. - + @@ -1602,7 +965,7 @@ cell.

Header 3

body row 1, column 1

column 2

column 3

-

2.21 Complex tables

+

2.21 Complex tables

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

@@ -1619,7 +982,7 @@ cell.

- + @@ -1651,7 +1014,7 @@ empty: -->

Header 4

body row 1, column 1

column 2

column 3

-

2.22 List Tables

+

2.22 List Tables

Here's a list table exercising all features:

@@ -1666,7 +1029,7 @@ empty: -->

- + @@ -1684,7 +1047,7 @@ crunchy, now would it?

list table with integral header

Description

Albatross

2.99

On a stick!

-

2.23 Custom Roles

+

2.23 Custom Roles

  • A role based on an existing role.

    one two three

    @@ -1701,8 +1064,7 @@ crunchy, now would it?

  • A role with multiple class attributes, styled with raw directives:

    The following works in most browsers but does not validate (<style> is only allowed in the document head):

    -
    -.. raw:: html
    +
    .. raw:: html
     
       <style type="text/css"><!--
        .green {color: green;}
    @@ -1714,7 +1076,7 @@ crunchy, now would it?

-

2.24 SVG Images

+

2.24 SVG Images

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

Scalable vector graphics (SVG) images are not supported by all backends. @@ -1750,7 +1112,7 @@ reStructuredText, the markup syntax

-

2.25 SWF Images

+

2.25 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 concerns.

@@ -1759,13 +1121,13 @@ 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 8.0 em x 0.8 em.

+

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

-
-

3 Additional html4_strict features

+
+

3 Additional html4css2 features

-

3.1 Enumerated lists with nested counters

+

3.1 Enumerated lists with nested counters

  1. first point

      @@ -1792,7 +1154,7 @@ wrapping in this kind of lists.

-

3.2 Description list

+

3.2 Description list

Definition lists are styled like in most dictionaries, encyclopedias etc. (as well as the LaTeX description environment) if given the description class argument:

@@ -1807,7 +1169,7 @@ hanging indent.

-

3.3 Field list handling

+

3.3 Field list handling

The following list demonstrates the problems with the html4css1 approach: the field-name-limit setting is given in "number of characters" but the field name uses a proportional font.

@@ -1829,7 +1191,7 @@ with the default setting of field-name-limit: 14.

previous one but regarded "short" by html4css1.

-

With html4strict, the field list is typeset as CSS-styled definition +

With html4css2, the field list is typeset as CSS-styled definition list. The default layout is similar to the look with html4css1:

A long field name
@@ -1842,13 +1204,12 @@ suppress this behaviour with the ru

of the field name width is possible with CSS instead of the field-name-limit configuration setting, for example:

-
-dl.field-list > dd { margin-left: 6em; }
+
dl.field-list > dd { margin-left: 6em; }
 
-

3.3.1 Styling with class arguments

+

3.3.1 Styling with class arguments

The default style sheet html4css2.css supports the following class arguments for alternative styles:

@@ -1939,9 +1300,9 @@ prevented by a dummy dd:after element in the CSS. -->
-
-

3.4 Tables

-

Numbered tables can be achieved with the "formal" class option

+
+

3.4 Table styling with class arguments

+

Numbered tables can be achieved with the numbered class option

@@ -1955,7 +1316,7 @@ prevented by a dummy dd:after element in the CSS. --> - + @@ -1974,18 +1335,16 @@ prevented by a dummy dd:after element in the CSS. -->
truth values

A or B

False

False

False

-
-

3.4.1 Styling with class arguments

-

In addition to the "borderless" table-style6, the style sheet also +

In addition to the "borderless" table-style [7], the style sheet also defines "booktabs", that will be rendered similar to the style from -the booktabs7 LaTeX package.

+the booktabs [8] LaTeX package.

- + @@ -2018,7 +1377,7 @@ the headers:

- + @@ -2054,7 +1413,7 @@ the headers:

- + @@ -2074,16 +1433,16 @@ the headers:

False

False

False

A or B

False

False

False

A or B

False

False

False

-
-

3.5 Math

+

3.5 Math

The W3C consortium provides a DTD for XHTML 1.1 plus MathML 2.0, so -that documentd embedding formulas as MathML can be validated.

+that documents embedding formulas as MathML can be validated.

The linear mapping f: N N with

+
@@ -2097,6 +1456,7 @@ with

-2πi nk N
+

for all a N is called discrete Fourier @@ -2104,7 +1464,7 @@ transformation (DFT).

-

4 Error Handling

+

4 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":

@@ -2112,24 +1472,24 @@ section, "Docutils System Messages":

Docutils System Messages

-
-

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

+
+

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

Undefined substitution referenced: "problematic".

-
-

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

+
+

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

Unknown target name: "5".

-
-

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

+
+

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

Unknown target name: "nonexistent".

-
-

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

+
+

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

Unknown target name: "hyperlink reference without a target".

-
-

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

+
+

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

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

diff --git a/sandbox/html4strict/html4strict/html4css2.css b/docutils/test/functional/input/data/xhtml11.css similarity index 100% rename from sandbox/html4strict/html4strict/html4css2.css rename to docutils/test/functional/input/data/xhtml11.css diff --git a/sandbox/html4strict/data/standalone_rst_html4strict.txt b/docutils/test/functional/input/standalone_rst_xhtml11.txt similarity index 98% rename from sandbox/html4strict/data/standalone_rst_html4strict.txt rename to docutils/test/functional/input/standalone_rst_xhtml11.txt index a814125d0..693324284 100644 --- a/sandbox/html4strict/data/standalone_rst_html4strict.txt +++ b/docutils/test/functional/input/standalone_rst_xhtml11.txt @@ -8,7 +8,7 @@ .. include:: data/svg_images.txt .. include:: data/swf_images.txt -Additional html4_strict features +Additional html4css2 features ================================ Enumerated lists with nested counters @@ -72,7 +72,7 @@ characters" but the field name uses a proportional font. :MMMMMMMMMMMMMM: a field name that is actually longer than the previous one but regarded "short" by html4css1. -With `html4strict`, the field list is typeset as CSS-styled `definition +With `html4css2`, the field list is typeset as CSS-styled `definition list`. The default layout is similar to the look with `html4css1`: .. class:: open diff --git a/docutils/test/functional/tests/standalone_rst_xhtml11.py b/docutils/test/functional/tests/standalone_rst_xhtml11.py new file mode 100644 index 000000000..b51fc8ab9 --- /dev/null +++ b/docutils/test/functional/tests/standalone_rst_xhtml11.py @@ -0,0 +1,18 @@ +# Test the xhtml11 writer: + +# common reader/parser/transform defaults for standalone tests +exec(open('functional/tests/_standalone_rst_defaults.py').read()) + +# Source and destination file names. +test_source = "standalone_rst_xhtml11.txt" +test_destination = "standalone_rst_xhtml11.xhtml" + +# Keyword parameters passed to publish_file. +writer_name = "xhtml11" + +# Settings +# local copy of default stylesheet: +# (test runs in ``docutils/test/``, we need relative path from there.) +settings_overrides['stylesheet_path'] = ( + 'functional/input/data/html4css1.css,' + 'functional/input/data/xhtml11.css') diff --git a/sandbox/html4strict/tools/rst2html_strict.py b/docutils/tools/rst2xhtml11.py similarity index 86% rename from sandbox/html4strict/tools/rst2html_strict.py rename to docutils/tools/rst2xhtml11.py index fe9fad023..8349032eb 100755 --- a/sandbox/html4strict/tools/rst2html_strict.py +++ b/docutils/tools/rst2xhtml11.py @@ -25,13 +25,10 @@ except locale.Error: from docutils.core import publish_cmdline, default_description -# Import the html4strict writer from either the canonical place for a +# Import the xhtml11 writer from either the canonical place for a # Docutils writer or anywhere in the PYTHONPATH:: -try: - from docutils.writers.html4strict import Writer -except ImportError: - from html4strict import Writer +from docutils.writers.xhtml11 import Writer description = ('Generates CSS2-styled HTML documents from standalone ' 'reStructuredText! sources that conform to the XHTML 1.1 DTD ' diff --git a/sandbox/html4strict/README.txt b/sandbox/html4strict/README.txt index 04e62798c..984a8f653 100644 --- a/sandbox/html4strict/README.txt +++ b/sandbox/html4strict/README.txt @@ -2,7 +2,7 @@ .. sectnum:: ===================================================== - The Strict HTML Writer + The XHTML 1.1 Writer ===================================================== :Author: Günter Milde @@ -10,6 +10,11 @@ :Abstract: A HTML writer, generating `XHTML 1.1` for styling with CSS 2.1. +.. note:: The HTML4Strict writer moved to the Docutils core on 2015-02-20. + It is called xhtml11 there + (as the output conforms to http://www.w3.org/TR/xhtml11/). + + .. contents:: Introduction @@ -24,12 +29,12 @@ State of the art *Almost*, as it contains some deprecated constructs and "a minimum of formatting information" in order to ensure correct display with deficient -but widespread browsers. +but (at the time of creation) widespread browsers (mainly IE6). Objective ---------- -Goals of the `strict html writer`: +Goals of the `xhtml11 writer`: * Strict standards compliance. @@ -70,53 +75,23 @@ This writer is for you, if you * want extended CSS configurability. -Manifest --------- - -* ``_ - - * ``_: writer module - * ``_: additional CSS style sheet - -* ``_ - - * ``_: front end - -* ``_ - - * ``_, - * ``_: reStructuredText Test Document - * ``_, - * ``_: test the list compactation algorithm. - -Installation -============ - -1. Copy/Link/Move the ``_ directory (including its - contents) either into - - * the ``docutils/writers/`` directory (alongside the standard - writers), or - * Python's `Module Search Path`_. - -2. Copy/Link the standard style sheet ``html4css1.css`` into this this - directory. - -3. Copy/Link/Move ``_ into the binary PATH. - -.. _Module Search Path: - http://docs.python.org/tutorial/modules.html#the-module-search-path Usage ===== -Command line use:: +For an example of programmatic use, see the `minimal front end to the +Docutils Publisher, producing valid XHTML 1.1` +<../../docutils/tools/rst2xhtml11.py>`_. + +This wrapper can called from the command line (when it is installed in the +BINARY PATH): + +Comman line use:: - rst2html_strict.py [options] [ []] + rst2xhtml11.py [options] [ []] The full usage text can be obtained with the ``--help`` option. -For an example of programmatic use, see ``_. Implementation @@ -126,8 +101,8 @@ The writer module subclasses the ``html4css1.Writer`` and ``html4css1.HTMLTranslator`` classes. Some methods are overwritten to replace deprecated HTML constructs or hard coded formatting. -The html4css2.css style sheet extends the standard layout for -CSS2-conforming Html browsers. +The xhtml11.css style sheet extends the standard layout for +CSS2-conforming HTML browsers. Changes to the html4css1 writer -- 2.11.4.GIT