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.
* Now sphinx_rtd_theme become optional. Please install it manually.
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

View File

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

View File

@ -1886,7 +1886,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append(r'\underline{')
self.context.append('}')
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('}')
else:
self.context.append('')