Re: Difference in custom roles between 0.13 and 0.14?
Guenter Milde via Docutils-users <[email protected]>
| Newsgroups | gmane.text.docutils.user |
|---|---|
| Message-ID | <[email protected]> |
Dear Tim,
thank you for reporting the problem with the Docutils LaTeX writer.
On 2018-06-02, Tim Landscheidt wrote:
> Hi,
> I'm investigating a build failure in Fedora for Pymacs
> (https://github.com/pinard/Pymacs) that occurs with (Fedora 28's)
> Docutils 0.14, but not with (Fedora 27's) Docutils 0.13.1
> (https://bugzilla.redhat.com/show_bug.cgi?id=1555730).
> The .rst file in question
...
> starts with defining custom roles as "aliases":
>| .. role:: code(strong)
>| .. role:: file(literal)
>| .. role:: var(emphasis)
> Docutils 0.13.1 is fine with this, Docutils 0.14 causes a
> TeX error
> (https://bugzilla.redhat.com/attachment.cgi?id=1443162):
>| […]
>| ! Undefined control sequence.
>| <write> ...re your \protect \texttt {\DUrolefile
>| {.emacs}} file}{\thepage }...
...
> The .tex files differ (inter alia) by:
>| --- /tmp/f27.tex 2018-06-02 10:10:17.035844460 +0000
>| +++ /tmp/f28.tex 2018-06-02 10:10:02.937009242 +0000
>| @@ -1,6 +1,5 @@
>| \documentclass[a4paper]{article}
>| % generated by Docutils <http://docutils.sourceforge.net/>
>| -\usepackage{fixltx2e} % LaTeX patches, \textsubscript
>| \usepackage{cmap} % fix search and cut-and-paste in Acrobat
>| \usepackage{ifthen}
>| \usepackage[T1]{fontenc}
>| @@ -37,14 +36,11 @@
>| % inline markup (custom roles)
>| % \DUrole{#1}{#2} tries \DUrole#1{#2}
>| \providecommand*{\DUrole}[2]{%
>| - \ifcsname DUrole#1\endcsname%
>| + % backwards compatibility: try \docutilsrole#1{#2}
>| + \ifcsname docutilsrole#1\endcsname%
>| + \csname docutilsrole#1\endcsname{#2}%
>| + \else
>| \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%
>| }
...
> Is this a bug in Docutils, or does Pymacs need to add dummy
> "\newcommand{\DUrolefile}{}"s as raw LaTex?
You actually found a bug. I simplified the definition of the ``\DUrole``
macro, this worked fine in the standard tests but it turns out to be failing
in cases where roles have defaults and with roles in section headings.
Restoring the old definition helps (patch below). Dummy definitions in
the document preamble or in raw LaTeX should help as a stop-gap measure,
too.
Thanks again,
Günter
diff --git a/trunk/docutils/docutils/writers/latex2e/__init__.py b/trunk/docutils/docutils/writers/latex2e/__init__.py
index a11a98f3c..0463e3504 100644
--- a/trunk/docutils/docutils/writers/latex2e/__init__.py
+++ b/trunk/docutils/docutils/writers/latex2e/__init__.py
@@ -565,11 +565,15 @@ PreambleCmds.inline = r"""
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
- % backwards compatibility: try \docutilsrole#1{#2}
- \ifcsname docutilsrole#1\endcsname%
- \csname docutilsrole#1\endcsname{#2}%
- \else
+ \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%
\fi%
}"""
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users
Please use "Reply All" to reply to the list.