|
From: <mi...@us...> - 2021-01-08 15:24:40
|
Revision: 8603
http://sourceforge.net/p/docutils/code/8603
Author: milde
Date: 2021-01-08 15:24:32 +0000 (Fri, 08 Jan 2021)
Log Message:
-----------
Make "meta" elements available for "latex" and "odt".
Basic "odt" support exists, "latex" support is planned.
In future, the `meta directive`__ may insert <meta> instead of
pending nodes, `making transforms/components.Filter` obsolete
(solves bug #241).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/transforms/components.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/HISTORY.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -62,6 +62,11 @@
- Make the sidebar's "title" argument optional (feature request #69).
+* docutils/parsers/rst/directives/html.py
+
+ - Make "meta" elements available for "latex" and "odt".
+ (Basic "odt" support exists, "latex" support is planned.)
+
* docutils/parsers/rst/directives/misc.py
- Prevent infinite inclusion loops.
@@ -74,6 +79,10 @@
- Fix bug #383: Smart quotes around opening and separator characters.
+* docutils/transforms/components.py
+
+ - Allow a comma-separated list of formats for the Filter transform.
+
* docutils/writers/html*
- Implement feature request #40 `Option to embed images as data URI`.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/RELEASE-NOTES.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -35,6 +35,17 @@
Remove the IE PNG Fix by Angus Turnbull. IE has native PNG
support since version 7.
+* Make <meta> a standard Docutils doctree node.
+
+ The `meta directive`__ will insert <meta> instead of pending nodes.
+ Writers may ignore some or all <meta> elements if they are not
+ supported by the output format.
+
+ The ``transforms/components.Filter`` class will become obsolete by
+ this change and may be removed in future.
+
+ __ docs/ref/rst/directives.html#meta
+
* ``Node.traverse()`` will return an iterator instead of a list.
* Remove ``utils.unique_combinations``
@@ -70,7 +81,7 @@
.. _auto_id_prefix: docs/user/config.html#auto-id-prefix
.. _rst2html.py: docs/user/tools.html#rst2html-py
.. _reference name: docs/ref/rst/restructuredtext.html#reference-names
-.. _identifier normalization: directives.html#identifier-normalization
+.. _identifier normalization: docs/ref/rst/directives.html#identifier-normalization
Release 0.17
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docs/ref/rst/directives.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -1224,62 +1224,6 @@
HTML-Specific
---------------
-Meta
-====
-
-:Directive Type: "meta"
-:Doctree Element: meta (non-standard)
-:Directive Arguments: None.
-:Directive Options: None.
-:Directive Content: Must contain a flat field list.
-
-The "meta" directive is used to specify HTML metadata stored in HTML
-META tags. "Metadata" is data about data, in this case data about web
-pages. Metadata is used to describe and classify web pages in the
-World Wide Web, in a form that is easy for search engines to extract
-and collate.
-
-Within the directive block, a flat field list provides the syntax for
-metadata. The field name becomes the contents of the "name" attribute
-of the META tag, and the field body (interpreted as a single string
-without inline markup) becomes the contents of the "content"
-attribute. For example::
-
- .. meta::
- :description: The reStructuredText plaintext markup language
- :keywords: plaintext, markup language
-
-This would be converted to the following HTML::
-
- <meta name="description"
- content="The reStructuredText plaintext markup language">
- <meta name="keywords" content="plaintext, markup language">
-
-Support for other META attributes ("http-equiv", "scheme", "lang",
-"dir") are provided through field arguments, which must be of the form
-"attr=value"::
-
- .. meta::
- :description lang=en: An amusing story
- :description lang=fr: Une histoire amusante
-
-And their HTML equivalents::
-
- <meta name="description" lang="en" content="An amusing story">
- <meta name="description" lang="fr" content="Une histoire amusante">
-
-Some META tags use an "http-equiv" attribute instead of the "name"
-attribute. To specify "http-equiv" META tags, simply omit the name::
-
- .. meta::
- :http-equiv=Content-Type: text/html; charset=ISO-8859-1
-
-HTML equivalent::
-
- <meta http-equiv="Content-Type"
- content="text/html; charset=ISO-8859-1">
-
-
Imagemap
========
@@ -1914,6 +1858,76 @@
parser is "title-reference".
+Metadata
+========
+
+:Directive Type: "meta"
+:Doctree Element: pending_, meta (non-standard)
+:Directive Arguments: None.
+:Directive Options: None.
+:Directive Content: Must contain a flat field list.
+
+The "meta" directive is used to specify metadata\ [#]_ to be stored
+in, e.g., HTML META tags or as ODT file properties. If the output
+format does not support "invisible" metadata, it is silently
+dropped by the writer.
+
+.. note:: Data from some `bibliographic fields`_ is automatically
+ extracted and stored in META tags, too. However, Bibliographic
+ Fields are also visible in the document's screen rendering or
+ printout.
+
+ For an "invisible" *document title*, see the `metadata document
+ title`_ directive below.
+
+Within the directive block, a flat field list provides the syntax for
+metadata. The field name becomes the contents of the "name" attribute
+of the META tag, and the field body (interpreted as a single string
+without inline markup) becomes the contents of the "content"
+attribute. For example::
+
+ .. meta::
+ :description: The reStructuredText plaintext markup language
+ :keywords: plaintext, markup language
+
+This would be converted to the following HTML::
+
+ <meta name="description"
+ content="The reStructuredText plaintext markup language">
+ <meta name="keywords" content="plaintext, markup language">
+
+Support for other META attributes ("http-equiv", "scheme", "lang",
+"dir") are provided through field arguments, which must be of the form
+"attr=value"::
+
+ .. meta::
+ :description lang=en: An amusing story
+ :description lang=fr: Une histoire amusante
+
+And their HTML equivalents::
+
+ <meta name="description" lang="en" content="An amusing story">
+ <meta name="description" lang="fr" content="Une histoire amusante">
+
+Some META tags use an "http-equiv" attribute instead of the "name"
+attribute. To specify "http-equiv" META tags, simply omit the name::
+
+ .. meta::
+ :http-equiv=Content-Type: text/html; charset=ISO-8859-1
+
+HTML equivalent::
+
+ <meta http-equiv="Content-Type"
+ content="text/html; charset=ISO-8859-1">
+
+.. [#] "Metadata" is data about data, in this case data about the
+ document. Metadata is, e.g., used to describe and classify web
+ pages in the World Wide Web, in a form that is easy for search
+ engines to extract and collate.
+
+.. _bibliographic fields: restructuredtext.html#bibliographic-fields
+
+
Metadata Document Title
=======================
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -3117,7 +3117,7 @@
http://www.w3.org/TR/WCAG10-HTML-TECHS/#link-text
.. _image: directives.html#image
.. _replace: directives.html#replace
-.. _meta: directives.html#meta
+.. _meta: directives.html#metadata
.. _figure: directives.html#figure
.. _admonition: directives.html#admonitions
.. _role: directives.html#custom-interpreted-text-roles
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -35,7 +35,7 @@
node = self.meta()
pending = nodes.pending(components.Filter,
{'component': 'writer',
- 'format': 'html',
+ 'format': 'html,latex,odt',
'nodes': [node]})
node['content'] = utils.unescape(utils.escape2null(
' '.join(indented)))
Modified: trunk/docutils/docutils/transforms/components.py
===================================================================
--- trunk/docutils/docutils/transforms/components.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/transforms/components.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -35,7 +35,8 @@
For example, the reStructuredText "meta" directive creates a "pending"
element containing a "meta" element (in ``pending.details['nodes']``).
Only writers (``pending.details['component'] == 'writer'``) supporting the
- "html" format (``pending.details['format'] == 'html'``) will include the
+ "html", latex, or "odf" formats
+ (``pending.details['format'] == 'html,latex,odf'``) will include the
"meta" element; it will be deleted from the output of all other writers.
"""
@@ -44,9 +45,11 @@
def apply(self):
pending = self.startnode
component_type = pending.details['component'] # 'reader' or 'writer'
- format = pending.details['format']
+ formats = (pending.details['format']).split(',')
component = self.document.transformer.components[component_type]
- if component.supports(format):
- pending.replace_self(pending.details['nodes'])
+ for format in formats:
+ if component.supports(format):
+ pending.replace_self(pending.details['nodes'])
+ break
else:
pending.parent.remove(pending)
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -2541,21 +2541,12 @@
self.out.append(self.context.pop())
self.duclass_close(node)
- ## def visit_meta(self, node):
- ## self.out.append('[visit_meta]\n')
- # TODO: set keywords for pdf?
- # But:
- # The reStructuredText "meta" directive creates a "pending" node,
- # which contains knowledge that the embedded "meta" node can only
- # be handled by HTML-compatible writers. The "pending" node is
- # resolved by the docutils.transforms.components.Filter transform,
- # which checks that the calling writer supports HTML; if it doesn't,
- # the "pending" node (and enclosed "meta" node) is removed from the
- # document.
- # --- docutils/docs/peps/pep-0258.html#transformer
+ def visit_meta(self, node):
+ # TODO: set keywords for pdf or write info for dropped content?
+ pass
- ## def depart_meta(self, node):
- ## self.out.append('[depart_meta]\n')
+ def depart_meta(self, node):
+ pass
def visit_math(self, node, math_env='$'):
"""math role"""
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/writers/manpage.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -860,11 +860,12 @@
def depart_math_block(self, node):
self.depart_literal_block(node)
- def visit_meta(self, node):
- raise NotImplementedError(node.astext())
+ # <meta> shall become an optional standard node:
+ # def visit_meta(self, node):
+ # raise NotImplementedError(node.astext())
- def depart_meta(self, node):
- pass
+ # def depart_meta(self, node):
+ # pass
def visit_note(self, node):
self.visit_admonition(node, 'note')
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -34,7 +34,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="The reStructuredText plaintext markup language" name="description">
<pending>
@@ -42,7 +42,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="plaintext,markup language" name="keywords">
"""],
@@ -58,7 +58,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="An amusing story" lang="en" name="description">
<pending>
@@ -66,7 +66,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="Un histoire amusant" lang="fr" name="description">
"""],
@@ -81,7 +81,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
"""],
@@ -97,7 +97,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content over multiple lines" name="name">
"""],
@@ -116,7 +116,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
"""],
@@ -169,7 +169,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
<system_message level="3" line="1" source="test data" type="ERROR">
@@ -194,7 +194,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
<pending>
@@ -202,7 +202,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
<system_message level="3" line="1" source="test data" type="ERROR">
@@ -239,7 +239,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="escaped linebreak" name="name:with:colons">
<pending>
@@ -246,8 +246,8 @@
.. internal attributes:
.transform: docutils.transforms.components.Filter
.details:
- component: \'writer\'
- format: \'html\'
+ component: 'writer'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="unescaped:embedded:colons">
"""],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|