diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-05-07 09:42:22 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-05-07 09:42:22 +0000 |
| commit | b2ce085324ff8e88ff664a274e4fb3738e686381 (patch) | |
| tree | acde77f6fb0974aae81f684223923d185193d81a | |
| parent | a7e51bd80609eceec4a54ef9ca312a047334e6ee (diff) | |
| download | docutils-b2ce085324ff8e88ff664a274e4fb3738e686381.tar.gz | |
latex writer: Render inline markup in document title and subtitle
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@6322 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
| -rw-r--r-- | docutils/HISTORY.txt | 1 | ||||
| -rw-r--r-- | docutils/docs/dev/todo.txt | 24 | ||||
| -rw-r--r-- | docutils/docutils/writers/latex2e/__init__.py | 23 | ||||
| -rwxr-xr-x | docutils/test/test_writers/test_latex2e.py | 44 |
4 files changed, 67 insertions, 25 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 30b05feba..77ecf6260 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -57,6 +57,7 @@ Changes Since 0.6 - Apply [ 2961991 ] Call hyperref with unicode option. - Drop the special `output_encoding`_ default ("latin-1"). The Docutils wide default (usually "UTF-8") is used instead. + - Render inline markup in document title and subtitle __ docs/ref/restructuredtext.html#inline-literals __ docs/user/config.html#docutils-footnotes diff --git a/docutils/docs/dev/todo.txt b/docutils/docs/dev/todo.txt index de58bca9a..ad8c8bc1b 100644 --- a/docutils/docs/dev/todo.txt +++ b/docutils/docs/dev/todo.txt @@ -1084,7 +1084,7 @@ __ rst/alternatives.html#or-not-to-do .. _itex: http://pear.math.pitt.edu/mathzilla/itex2mmlItex.html .. _ASCIIMathML: http://www1.chapman.edu/~jipsen/mathml/asciimath.html .. _Unicode Nearly Plain Text Encoding of Mathematics: - http://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v3.pdf + http://www.unicode.org/notes/tn28/ @@ -2334,6 +2334,14 @@ Image and figure directives Use `wrapfig` (or other recommended) package. +* support more graphic formats (especially SVG, the only standard + vector format for HTML) + + There is a `SWF package`_ at CTAN. + +.. _SWF package: + http://dante.ctan.org/tex-archive/macros/latex/contrib/flashmovie + Missing features ---------------- @@ -2362,20 +2370,6 @@ Missing features Put in place of the to-be-implemented "citations" directive (see `Footnote & Citation Gathering`_). -* The latex writer ignores any inline markup in document titles and - subtitles (but it respects it in section titles):: - - This is the *Title* - =================== - - This is the *Subtitle* - ---------------------- - - This is a *section title* - ~~~~~~~~~~~~~~~~~~~~~~~~~ - - This is the document. - Unicode to LaTeX ```````````````` diff --git a/docutils/docutils/writers/latex2e/__init__.py b/docutils/docutils/writers/latex2e/__init__.py index ab9569715..3c7c9062e 100644 --- a/docutils/docutils/writers/latex2e/__init__.py +++ b/docutils/docutils/writers/latex2e/__init__.py @@ -1733,10 +1733,10 @@ class LaTeXTranslator(nodes.NodeVisitor): if self.title or self.author_stack or self.date: authors = ['\\\\\n'.join(author_entry) for author_entry in self.author_stack] - title = self.title + self.title_labels + title = [''.join(self.title)] + self.title_labels if self.subtitle: title += [r'\\ % subtitle', - r'\large{%s}' % self.subtitle[0] + r'\large{%s}' % ''.join(self.subtitle) ] + self.subtitle_labels self.body_pre_docinfo.append(PreambleCmds.documenttitle % ( '%\n '.join(title), @@ -2484,9 +2484,8 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_subtitle(self, node): if isinstance(node.parent, nodes.document): - self.subtitle += [self.encode(node.astext())] + self.push_output_collector(self.subtitle) self.subtitle_labels += self.ids_to_labels(node, set_anchor=False) - raise nodes.SkipNode # section subtitle: "starred" (no number, not in ToC) elif isinstance(node.parent, nodes.section): self.out.append(r'\%s*{' % @@ -2496,7 +2495,10 @@ class LaTeXTranslator(nodes.NodeVisitor): self.out.append('\n\\DUsubtitle[%s]{' % node.parent.tagname) def depart_subtitle(self, node): - self.out.append('}\n') + if isinstance(node.parent, nodes.document): + self.pop_output_collector() + else: + self.out.append('}\n') def visit_system_message(self, node): self.requirements['color'] = PreambleCmds.color @@ -2631,10 +2633,10 @@ class LaTeXTranslator(nodes.NodeVisitor): """Append section and other titles.""" # Document title if node.parent.tagname == 'document': - title = self.encode(node.astext()) - self.title.append(title) - self.pdfinfo.append(' pdftitle={%s},' % title) - raise nodes.SkipNode + self.push_output_collector(self.title) + self.context.append('') + self.pdfinfo.append(' pdftitle={%s},' % + self.encode(node.astext())) # Topic titles (topic, admonition, sidebar) elif (isinstance(node.parent, nodes.topic) or isinstance(node.parent, nodes.admonition) or @@ -2674,7 +2676,8 @@ class LaTeXTranslator(nodes.NodeVisitor): def depart_title(self, node): self.out.append(self.context.pop()) - if isinstance(node.parent, nodes.table): + if (isinstance(node.parent, nodes.table) or + node.parent.tagname == 'document'): self.pop_output_collector() def minitoc(self, node, title, depth): diff --git a/docutils/test/test_writers/test_latex2e.py b/docutils/test/test_writers/test_latex2e.py index cc2302bd3..9b8063e75 100755 --- a/docutils/test/test_writers/test_latex2e.py +++ b/docutils/test/test_writers/test_latex2e.py @@ -579,6 +579,50 @@ same paragraph. """], ] +totest['title_with_inline_markup'] = [ +["""\ +This is the *Title* +=================== + +This is the *Subtitle* +---------------------- + +This is a *section title* +~~~~~~~~~~~~~~~~~~~~~~~~~ + +This is the *document*. +""", +head_template.substitute( + dict(parts, pdfsetup = parts['pdfsetup'] + r"""\hypersetup{ + pdftitle={This is the Title}, +} +""")) + r""" +% Document title +\title{This is the \emph{Title}% + \phantomsection% + \label{this-is-the-title}% + \\ % subtitle% + \large{This is the \emph{Subtitle}}% + \label{this-is-the-subtitle}} +\author{} +\date{} +\maketitle + + +%___________________________________________________________________________ + +\section*{This is a \emph{section title}% + \phantomsection% + \addcontentsline{toc}{section}{This is a section title}% + \label{this-is-a-section-title}% +} + +This is the \emph{document}. + +\end{document} +"""], +] + totest_stylesheet['two-styles'] = [ # input ["""two stylesheet links in the header""", |
