Fix #2231: Use DUrole instead of DUspan for custom roles in LaTeX writer

This commit is contained in:
Takeshi KOMIYA 2016-01-16 02:12:17 +09:00
parent 3432377669
commit 6b36b31984
3 changed files with 14 additions and 9 deletions

View File

@ -8,6 +8,8 @@ Incompatible changes
to accelerate stemming. to accelerate stemming.
* Now sphinx_rtd_theme become optional. Please install it manually. * Now sphinx_rtd_theme become optional. Please install it manually.
Refs #2087, #2086, #1845 and #2097. Thanks to Victor Zverovich. Refs #2087, #2086, #1845 and #2097. Thanks to Victor Zverovich.
* #2231: Use DUrole instead of DUspan for custom roles in LaTeX writer. It enables to take
title of roles as an argument of custom macros.
Features added Features added

View File

@ -444,15 +444,18 @@
\RequirePackage{hypcap} \RequirePackage{hypcap}
% From docutils.writers.latex2e % From docutils.writers.latex2e
\providecommand{\DUspan}[2]{% % inline markup (custom roles)
{% group ("span") to limit the scope of styling commands % \DUrole{#1}{#2} tries \DUrole#1{#2}
\@for\node@class@name:=#1\do{% \providecommand*{\DUrole}[2]{%
\ifcsname docutilsrole\node@class@name\endcsname% \ifcsname DUrole#1\endcsname%
\csname docutilsrole\node@class@name\endcsname% \csname DUrole#1\endcsname{#2}%
\else% backwards compatibility: try \docutilsrole#1{#2}
\ifcsname docutilsrole#1\endcsname%
\csname docutilsrole#1\endcsname{#2}%
\else%
#2%
\fi% \fi%
}% \fi%
{#2}% node content
}% close "span"
} }
\providecommand*{\DUprovidelength}[2]{ \providecommand*{\DUprovidelength}[2]{

View File

@ -1886,7 +1886,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append(r'\underline{') self.body.append(r'\underline{')
self.context.append('}') self.context.append('}')
elif classes and not self.in_title: elif classes and not self.in_title:
self.body.append(r'\DUspan{%s}{' % ','.join(classes)) self.body.append(r'\DUrole{%s}{' % ','.join(classes))
self.context.append('}') self.context.append('}')
else: else:
self.context.append('') self.context.append('')