Post by Alan G. IsaacPost by MatÄj Cepl\begin{quote}
\DUrole{epigraph}{
Co je nejvyšším cílem člověka?
Nejvyšším cílem člověka je oslavovat Boha a věčně se z Něj
radovat.
\nopagebreak
\raggedleft —Westminsterský katechismus, 1647
}
\end{quote}
Is this another abuse of the ``quote`` environment
to accomplish indentation?
No. See the description of the "epigraph" directive.
Docutils converts it to
<block_quote classes="epigraph">
and currently handling of block-quotes and some other environments with
classes is broken.
This will be fixed soon.
Post by Alan G. IsaacIf so, this again compromises the ability to separately style quotes
and other content (in this case, epigraphs).
Not if the class arguments are handled correctly.
Post by Alan G. IsaacNote that the ``changepage`` package provides ``adjustwidth``.
E.g., one could define
\newenvironment{DUepigraph}%
{\begin{adjustwidth}{2cm}{}}%
{\end{adjustwidth}}
Other default formatting could be added as desired.
This approach would allow authors to readily modify
the ``epigraph`` environment (with ``renewenvironment``)
without interfering with other environments.
The ``quote`` environment is for (one paragraph) quotes.
It is not a general indentation facility.
https://en.wikibooks.org/wiki/LaTeX/Paragraph_Formatting#Quoting_text
Both "quote" and "quotation" provide for multiple paragraphs.
(Just try it.)
The error originates in the \DUrole definition with \providecommand*,
the star makes this check for paragraph breaks in the argument.
Patch attached.
Günter
Dir: docutils-svn/docutils/docutils/writers/latex2e/
Index: __init__.py
===================================================================
--- __init__.py (Revision 8020)
+++ __init__.py (Arbeitskopie)
@@ -494,6 +494,7 @@
PreambleCmds.align_center = r"""
\makeatletter
\@namedef{DUrolealign-center}{\centering}
+\@namedef{DUclassalign-center}{\centering}
\makeatother
"""
@@ -512,6 +513,15 @@
% dedication topic
\providecommand{\DUtopicdedication}[1]{\begin{center}#1\end{center}}"""
+PreambleCmds.DUclass = r"""
+% class handling for environments (block-level elements)
+% \DUclass{#1} tries \DUrole#1
+\providecommand{\DUclass}[1]{%
+ \ifcsname DUclass#1\endcsname%
+ \csname DUclass#1\endcsname%
+ \fi%
+}"""
+
PreambleCmds.error = r"""
% error admonition title
\providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}"""
@@ -1568,6 +1578,19 @@
labels.insert(0, '\\phantomsection')
return labels
+ def insert_DUclass_macros(self, node):
+ for cls in node['classes']:
+ if cls == 'align-center':
+ self.fallbacks['align-center'] = PreambleCmds.align_center
+ if cls.startswith('language-'):
+ language = self.babel.language_name(cls[9:])
+ if language:
+ self.babel.otherlanguages[language] = True
+ self.out.append('\\selectlanguage{%s}%\n' % language)
+ else:
+ self.fallbacks['DUclass'] = PreambleCmds.DUclass
+ self.out.append('\\DUclass{%s}%%\n' % cls)
+
def push_output_collector(self, new_out):
self.out_stack.append(self.out)
self.out = new_out
@@ -1631,12 +1654,9 @@
def visit_block_quote(self, node):
self.out.append( '%\n\\begin{quote}\n')
- if node['classes']:
- self.visit_inline(node)
+ self.insert_DUclass_macros(node)
def depart_block_quote(self, node):
- if node['classes']:
- self.depart_inline(node)
self.out.append( '\n\\end{quote}\n')
def visit_bullet_list(self, node):
@@ -1644,12 +1664,9 @@
self.out.append( '%\n\\begin{list}{}{}\n' )
else:
self.out.append( '%\n\\begin{itemize}\n' )
- # if node['classes']:
- # self.visit_inline(node)
+ self.insert_DUclass_macros(node)
def depart_bullet_list(self, node):
- # if node['classes']:
- # self.depart_inline(node)
if self.is_toc_list:
self.out.append( '\n\\end{list}\n' )
else:
@@ -1813,6 +1830,7 @@
def visit_definition_list(self, node):
self.out.append( '%\n\\begin{description}\n' )
+ self.insert_DUclass_macros(node)
def depart_definition_list(self, node):
self.out.append( '\\end{description}\n' )
@@ -2093,11 +2111,11 @@
if 'start' in node:
self.out.append('\\setcounter{%s}{%d}\n' %
(counter_name,node['start']-1))
+ self.insert_DUclass_macros(node)
# ## set rightmargin equal to leftmargin
# self.out.append('\\setlength{\\rightmargin}{\\leftmargin}\n')
-
def depart_enumerated_list(self, node):
if len(self._enumeration_counters) <= 4:
self.out.append('\\end{enumerate}\n')
@@ -2130,6 +2148,7 @@
if self.out is not self.docinfo:
self.fallbacks['fieldlist'] = PreambleCmds.fieldlist
self.out.append('%\n\\begin{DUfieldlist}\n')
+ self.insert_DUclass_macros(node)
def depart_field_list(self, node):
if self.out is not self.docinfo:
@@ -2163,6 +2182,7 @@
self.out.append('\n\\begin{figure}\n')
if node.get('ids'):
self.out += self.ids_to_labels(node) + ['\n']
+ self.insert_DUclass_macros(node)
def depart_figure(self, node):
self.out.append('\\end{figure}\n')
@@ -2391,14 +2411,9 @@
'\\begin{DUlineblock}{\\DUlineblockindent}\n')
else:
self.out.append('\n\\begin{DUlineblock}{0em}\n')
- if node['classes']:
- self.visit_inline(node)
- self.out.append('\n')
+ self.insert_DUclass_macros(node)
def depart_line_block(self, node):
- if node['classes']:
- self.depart_inline(node)
- self.out.append('\n')
self.out.append('\\end{DUlineblock}\n')
def visit_list_item(self, node):
@@ -2576,6 +2591,7 @@
self.fallbacks['_providelength'] = PreambleCmds.providelength
self.fallbacks['optionlist'] = PreambleCmds.optionlist
self.out.append('%\n\\begin{DUoptionlist}\n')
+ self.insert_DUclass_macros(node)
def depart_option_list(self, node):
self.out.append('\n\\end{DUoptionlist}\n')
@@ -2731,6 +2747,7 @@
self.requirements['color'] = PreambleCmds.color
self.fallbacks['sidebar'] = PreambleCmds.sidebar
self.out.append('\n\\DUsidebar{\n')
+ self.insert_DUclass_macros(node)
def depart_sidebar(self, node):
self.out.append('}\n')
------------------------------------------------------------------------------
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
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users
Pleas