|
From: <mi...@us...> - 2021-01-11 11:07:34
|
Revision: 8606
http://sourceforge.net/p/docutils/code/8606
Author: milde
Date: 2021-01-11 11:07:31 +0000 (Mon, 11 Jan 2021)
Log Message:
-----------
Support the "meta" directive in LaTeX.
Set PDF document properties from "meta" directive content
using "hyperref" options.
Also set "pdflang" if the document language is not "en".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/dev/todo.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/cyrillic.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/xetex-cyrillic.tex
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/HISTORY.txt 2021-01-11 11:07:31 UTC (rev 8606)
@@ -149,6 +149,8 @@
- Do not write Docutils-generated ToC, when ``use_latex_toc``
is True. (This did happen when publishing from a doctree.)
+
+ - Set PDF document properties from "meta" directive content.
* docutils/writers/manpage.py
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/docs/dev/todo.txt 2021-01-11 11:07:31 UTC (rev 8606)
@@ -210,7 +210,23 @@
* Perhaps the ``Component.supports`` method should deal with
individual features ("meta" etc.) instead of formats ("html" etc.)?
+ Currently, only the `<meta> node`_ requires the framework.
+
+ Do we need it at all? Or rather let the writers just ignore some
+ nodes (like we already do for "class" values)?
+
+ The current implementation of the framework also leads to bug
+ `bug #241`__ "doctree-based publishing != publish_string".
+ The "components.Filter" transform is run by publish_doctree(). When
+ filtering based on the output format, it should be run by
+ publish_from_doctree() instead because only then the writer is
+ known.
+
+ So we need to either remove or fix the framework.
+
+ __ https://sourceforge.net/p/docutils/bugs/241/
+
* Think about _`large documents` made up of multiple subdocument
files. Issues: continuity (`persistent sequences`_ above),
cross-references (`name-to-id mapping file`_ above and `targets in
@@ -608,7 +624,19 @@
<http://www.loria.fr/~rougier/coding/article/rst2html.py>`__
by Nicolas Rougier for a sample implementation.
+<meta> node
+-----------
+Up to 0.17, <meta> nodes are non-standard (not part of the Docutils
+document tree specification).
+
+The "Filter" transform removes "meta" nodes from the doctree unless the
+output format is "html" (rsp. "html", "latex", or "odt" since 0.17).
+
+Suggestion:
+ Make "meta" a generic directive and <meta> nodes standard nodes that
+ are kept in the doctree. Allow writers to ignore <meta> nodes.
+
Documentation
=============
@@ -2692,14 +2720,6 @@
a figure in LaTeX is 100 % of the text width, setting the 'align'
argument has currently no effect on the LaTeX output.
-
-* Let `meta` directive insert PDF-keywords into header?
-
- See https://tex.stackexchange.com/questions/26529/how-can-i-generate-pdf-metadata-from-latex#26530
- https://tex.stackexchange.com/questions/161094/adding-custom-metadata-values-to-a-pdf-file
-
-
-
* Multiple author entries in docinfo (same thing as in html).
* Consider supporting the "compact" option and class argument (from
@@ -2834,7 +2854,12 @@
* What about if we don't know which Reader and/or Writer we are
going to use? If the Reader/Writer is specified on the
- command-line? (Will this ever happen?)
+ command-line?
+
+ The dynamic_ front end ``tools/docutils-cli.py`` (new in 0.17) is an
+ implementation of concept d) below. It uses 2-stage argument parsing
+ via the `argparse` module's `partial parsing`_. It still needs some
+ polishing.
Perhaps have different types of front ends:
@@ -2856,7 +2881,7 @@
probably only useful for testing purposes.
d) _`Dynamic`: Reader and/or Writer are specified by options, with
- defaults if unspecified (e.g. ``publish --writer pdf
+ defaults if unspecified (e.g. ``publish --writer manpage
[options]``).
Allow common options before subcommands, as in CVS? Or group all
@@ -2876,11 +2901,6 @@
directive should override the ``--no-section-numbering`` command
line option then.
-The dynamic_ front end ``tools/docutils-frontend.py`` (new in 0.17) is an
-implementation of concept c). It uses 2-stage argument parsing
-via the "new" `argparse` module supports `partial parsing`_.
-It still needs some polishing and a better name.
-
.. _partial parsing:
https://docs.python.org/3/library/argparse.html#partial-parsing
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-11 11:07:31 UTC (rev 8606)
@@ -1190,9 +1190,10 @@
self.date = []
# PDF properties: pdftitle, pdfauthor
- # TODO?: pdfcreator, pdfproducer, pdfsubject, pdfkeywords
+ self.pdfauthor = []
self.pdfinfo = []
- self.pdfauthor = []
+ if settings.language_code != 'en':
+ self.pdfinfo.append(' pdflang={%s},'%settings.language_code)
# Stack of section counters so that we don't have to use_latex_toc.
# This will grow and shrink as processing occurs.
@@ -2542,8 +2543,18 @@
self.duclass_close(node)
def visit_meta(self, node):
- # TODO: set keywords for pdf or write info for dropped content?
- pass
+ name = node.attributes.get('name')
+ content = node.attributes.get('content')
+ if not name or not content:
+ return
+ if name in ('author', 'creator', 'keywords', 'subject', 'title'):
+ # fields with dedicated hyperref options:
+ self.pdfinfo.append(' pdf%s={%s},'%(name, content))
+ elif name == 'producer':
+ self.pdfinfo.append(' addtopdfproducer={%s},'%content)
+ else:
+ # generic interface (case sensitive!)
+ self.pdfinfo.append(' pdfinfo={%s={%s}},'%(name, content))
def depart_meta(self, node):
pass
Modified: trunk/docutils/test/functional/expected/cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/cyrillic.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/cyrillic.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -27,6 +27,9 @@
\usepackage{bookmark}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
+\hypersetup{
+ pdflang={ru},
+}
%%% Body
\begin{document}
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -186,6 +186,8 @@
}{}
\hypersetup{
pdftitle={reStructuredText Test Document},
+ pdfkeywords={reStructuredText, test, parser},
+ pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
pdfauthor={David Goodger;Me;Myself;I}
}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -187,6 +187,8 @@
}{}
\hypersetup{
pdftitle={reStructuredText Test Document},
+ pdfkeywords={reStructuredText, test, parser},
+ pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
pdfauthor={David Goodger;Me;Myself;I}
}
Modified: trunk/docutils/test/functional/expected/xetex-cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -32,6 +32,9 @@
\usepackage{bookmark}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
+\hypersetup{
+ pdflang={ru},
+}
%%% Body
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|