|
From: <mi...@us...> - 2021-06-17 14:33:28
|
Revision: 8767
http://sourceforge.net/p/docutils/code/8767
Author: milde
Date: 2021-06-17 14:33:28 +0000 (Thu, 17 Jun 2021)
Log Message:
-----------
Insert "meta" nodes at begin of document.
Modified Paths:
--------------
trunk/docutils/docs/ref/docutils.dtd
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
Modified: trunk/docutils/docs/ref/docutils.dtd
===================================================================
--- trunk/docutils/docs/ref/docutils.dtd 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/docs/ref/docutils.dtd 2021-06-17 14:33:28 UTC (rev 8767)
@@ -253,8 +253,8 @@
<!-- Optional elements may be generated by internal processing. -->
<!ELEMENT document
( (title, subtitle?)?,
+ meta?,
decoration?,
- meta?,
(docinfo, transition?)?,
%structure.model; )>
<!ATTLIST document
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/docutils/nodes.py 2021-06-17 14:33:28 UTC (rev 8767)
@@ -1572,7 +1572,7 @@
def get_decoration(self):
if not self.decoration:
self.decoration = decoration()
- index = self.first_child_not_matching_class(Titular)
+ index = self.first_child_not_matching_class((Titular, meta))
if index is None:
self.append(self.decoration)
else:
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2021-06-17 14:33:28 UTC (rev 8767)
@@ -544,7 +544,6 @@
'Error parsing meta tag attribute "%s": %s.'
% (token, detail), nodes.literal_block(line, line))
return msg, blank_finish
- # self.document.note_pending(pending)
return node, blank_finish
@@ -568,7 +567,11 @@
nodes.literal_block(self.block_text, self.block_text),
line=self.lineno)
node += error
- return node.children
+ # insert at begin of document
+ index = self.state.document.first_child_not_matching_class(
+ (nodes.Titular, nodes.meta)) or 0
+ self.state.document[index:index] = node.children
+ return []
class Date(Directive):
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2021-06-17 14:33:28 UTC (rev 8767)
@@ -393,7 +393,7 @@
candidate = document[index]
if isinstance(candidate, nodes.field_list):
biblioindex = document.first_child_not_matching_class(
- (nodes.Titular, nodes.Decorative))
+ (nodes.Titular, nodes.Decorative, nodes.meta))
nodelist = self.extract_bibliographic(candidate)
del document[index] # untransformed field list (candidate)
document[biblioindex:biblioindex] = nodelist
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2021-06-17 14:33:28 UTC (rev 8767)
@@ -4,6 +4,10 @@
<document ids="restructuredtext-test-document doctitle" names="restructuredtext\ test\ document doctitle" source="functional/input/standalone_rst_docutils_xml.txt" title="reStructuredText Test Document">
<title>reStructuredText Test Document</title>
<subtitle ids="examples-of-syntax-constructs subtitle" names="examples\ of\ syntax\ constructs subtitle">Examples of Syntax Constructs</subtitle>
+ <meta content="reStructuredText, test, parser" name="keywords">
+ </meta>
+ <meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description">
+ </meta>
<decoration>
<header>
<paragraph>Document header</paragraph>
@@ -1365,10 +1369,6 @@
<title auto="1" refid="toc-entry-53"><generated classes="sectnum">2.14.11 </generated>Meta</title>
<paragraph>The <reference anonymous="1" name="“meta” directive" refuri="https://docutils.sourceforge.io/docs/ref/rst/directives.html#metadata">“meta” directive</reference> <footnote_reference auto="1" ids="footnote-reference-17" refid="footnote-10">9</footnote_reference> is used to specify metadata to be stored in,
e.g., HTML META tags or ODT file properties.</paragraph>
- <meta content="reStructuredText, test, parser" name="keywords">
- </meta>
- <meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description">
- </meta>
<target anonymous="1" ids="target-6" refuri="https://docutils.sourceforge.io/docs/ref/rst/directives.html#metadata"></target>
</section>
</section>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2021-06-17 14:33:28 UTC (rev 8767)
@@ -5,13 +5,13 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.18b.dev: http://docutils.sourceforge.net/" />
<title>reStructuredText Test Document</title>
+<meta content="reStructuredText, test, parser" name="keywords" />
+<meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description" />
<meta name="author" content="David Goodger" />
<meta name="authors" content="Me Myself I" />
<meta name="organization" content="humankind" />
<meta name="date" content="Now, or yesterday. Or maybe even before yesterday." />
<meta name="copyright" content="This document has been placed in the public domain. You may do with it as you wish. You may copy, modify, redistribute, reattribute, sell, buy, rent, lease, destroy, or improve it, quote it at length, excerpt, incorporate, collate, fold, staple, or mutilate it, or do anything else to it that your or anyone else's heart desires." />
-<meta content="reStructuredText, test, parser" name="keywords" />
-<meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description" />
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
<link rel="stylesheet" href="../input/data/math.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2021-06-17 14:33:28 UTC (rev 8767)
@@ -5,6 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Docutils 0.18b.dev: http://docutils.sourceforge.net/" />
<title>reStructuredText Test Document</title>
+<meta content="reStructuredText, test, parser" name="keywords" />
+<meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description" xml:lang="en" />
<meta name="author" content="David Goodger" />
<meta name="author" content="Me" />
<meta name="author" content="Myself" />
@@ -11,8 +13,6 @@
<meta name="author" content="I" />
<meta name="dcterms.date" content="Now, or yesterday. Or maybe even before yesterday." />
<meta name="dcterms.rights" content="This document has been placed in the public domain. You may do with it as you wish. You may copy, modify, redistribute, reattribute, sell, buy, rent, lease, destroy, or improve it, quote it at length, excerpt, incorporate, collate, fold, staple, or mutilate it, or do anything else to it that your or anyone else's heart desires." />
-<meta content="reStructuredText, test, parser" name="keywords" />
-<meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description" xml:lang="en" />
<link rel="schema.dcterms" href="http://purl.org/dc/terms/"/>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/plain.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2021-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2021-06-17 14:33:28 UTC (rev 8767)
@@ -3,6 +3,8 @@
reStructuredText Test Document
<subtitle ids="examples-of-syntax-constructs subtitle" names="examples\ of\ syntax\ constructs subtitle">
Examples of Syntax Constructs
+ <meta content="reStructuredText, test, parser" name="keywords">
+ <meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description">
<decoration>
<header>
<paragraph>
@@ -1995,8 +1997,6 @@
9
is used to specify metadata to be stored in,
e.g., HTML META tags or ODT file properties.
- <meta content="reStructuredText, test, parser" name="keywords">
- <meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description">
<target anonymous="1" ids="target-6" refuri="https://docutils.sourceforge.io/docs/ref/rst/directives.html#metadata">
<section ids="substitution-definitions" names="substitution\ definitions">
<title auto="1" refid="toc-entry-34">
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-06-17 14:33:09 UTC (rev 8766)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2021-06-17 14:33:28 UTC (rev 8767)
@@ -67,9 +67,9 @@
""",
"""\
<document source="test data">
+ <meta content="content" name="name">
<paragraph>
Paragraph
- <meta content="content" name="name">
"""],
["""\
.. meta::
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|