Re: Class parameter is not effective in code directive (rst2latex)
Guenter Milde <[email protected]>
| Newsgroups | gmane.text.docutils.user |
|---|---|
| Message-ID | <[email protected]> |
On 2017-04-19, Sébastien Dailly wrote:
> Hello,
> I'm stuck with rst2latex : I want to customize the code-block rendering
> with a dark background. rst2latex translate this directive to a quote
> environnment which I can't override because it is already used elsewhere
> in the document.
> I've tried to add a class parameter to the directive
>> .. code-block:: C
>> :class: darkBackground
>> // Comment
> But this does not seems to work (the class parameter is discarded)
Yes, up to Docutils 0.13.1, class values for (almost all) block-level
elements are ignored by the latex writer.
In the development version (and upcoming release 0.14) the latex writer
will support class values for most block level elements:
- Handle class arguments for block-level elements by wrapping them
in a "DUclass" environment. This replaces the special handling for
"epigraph" and "topic" elements.
your example input will then be converted to::
\begin{DUclass}{code}
\begin{DUclass}{C}
\begin{DUclass}{darkbackground}
\begin{quote}
{\ttfamily \raggedright \noindent
\DUrole{comment}{\DUrole{single}{//~Comment}}
}
\end{quote}
\end{DUclass}
\end{DUclass}
\end{DUclass}
Customization is done by defining matching macros or environments.
For details, see the latex writer documention docs/usre/latex.txt
in the SVN repo.
> I've also tried to wrap the code directive inside a class one :
>> .. class:: darkBackground
>> .. code-block:: C
>> // Comment
> But this does not give the expected result.
Yes, this is converted to the same doctree (check with rst2xml or
rst2pseudoxml).
> Is this a known bug ?
It is a known limitation (per specification, Docutils writers are free to
ingore class values).
It is solved in the development version.
http://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/
Günter
PS: Please don't cross-post, both lists are read by the developers.
------------------------------------------------------------------------------
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.