|
From: <mi...@us...> - 2020-10-28 11:51:26
|
Revision: 8572
http://sourceforge.net/p/docutils/code/8572
Author: milde
Date: 2020-10-28 11:51:24 +0000 (Wed, 28 Oct 2020)
Log Message:
-----------
Fix bug #408 Incorrect assert in latex writer for multiple citation references.
Thanks to Erik Hansen for the report.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-10-28 08:46:19 UTC (rev 8571)
+++ trunk/docutils/HISTORY.txt 2020-10-28 11:51:24 UTC (rev 8572)
@@ -112,6 +112,9 @@
- Apply patch #173 "Make *TeX writers convert nonstandard table
classes to DUclass environments" by John Thorvald Wodder II.
+ - Fix bug #408 "Incorrect assert in latex writer
+ for multiple citation references".
+
* docutils/writers/manpage.py
- Fix #394 fix missing new line after rubric.
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-10-28 08:46:19 UTC (rev 8571)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-10-28 11:51:24 UTC (rev 8572)
@@ -1718,9 +1718,9 @@
self.out.append(r'\cite{')
self.inside_citation_reference_label = 1
else:
- assert self.body[-1] in (' ', '\n'),\
+ assert self.out[-1] in (' ', '\n'),\
'unexpected non-whitespace while in reference label'
- del self.body[-1]
+ del self.out[-1]
else:
href = ''
if 'refid' in node:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-11-25 23:06:51
|
Revision: 8577
http://sourceforge.net/p/docutils/code/8577
Author: milde
Date: 2020-11-25 23:06:44 +0000 (Wed, 25 Nov 2020)
Log Message:
-----------
Apply patch #175 "Fix alignment of nested tables".
Thanks to John Thorvald Wodder II for the patch.
Additional fixes to table alignment.
Expand LaTeX writer test for nested tables.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_cornercases.tex
trunk/docutils/test/functional/expected/latex_literal_block.tex
trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/input/latex_cornercases.txt
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-11-25 23:06:44 UTC (rev 8577)
@@ -866,13 +866,20 @@
# horizontal lines are drawn below a row,
def get_opening(self, width=r'\linewidth'):
- align_map = {'left': 'l',
- 'center': 'c',
- 'right': 'r'}
- align = align_map.get(self.get('align') or 'center')
- opening = [r'\begin{%s}[%s]' % (self.get_latex_type(), align)]
+ align_map = {'left': '[l]',
+ 'center': '[c]',
+ 'right': '[r]',
+ None: ''}
+ align = align_map.get(self.get('align'))
+ latex_type = self.get_latex_type()
+ if align and latex_type not in ("longtable", "longtable*"):
+ opening = [r'\noindent\makebox[\linewidth]%s{%%' % (align,),
+ r'\begin{%s}' % (latex_type,),
+ ]
+ else:
+ opening = [r'\begin{%s}%s' % (latex_type, align)]
if not self.colwidths_auto:
- opening.insert(0, r'\setlength{\DUtablewidth}{%s}'%width)
+ opening.insert(-1, r'\setlength{\DUtablewidth}{%s}%%'%width)
return '\n'.join(opening)
def get_closing(self):
@@ -882,6 +889,8 @@
# elif self.borders == 'standard':
# closing.append(r'\hline')
closing.append(r'\end{%s}' % self.get_latex_type())
+ if self.get('align') and self.get_latex_type() not in ("longtable", "longtable*"):
+ closing.append('}')
return '\n'.join(closing)
def visit_colspec(self, node):
@@ -2880,6 +2889,8 @@
if self.active_table.is_open():
self.table_stack.append(self.active_table)
# nesting longtable does not work (e.g. 2007-04-18)
+ # TODO: don't use a longtable or add \noindent before
+ # the next paragraph, when in a "compound paragraph".
self.active_table = Table(self, 'tabular')
# A longtable moves before \paragraph and \subparagraph
# section titles if it immediately follows them:
Modified: trunk/docutils/test/functional/expected/latex_cornercases.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_cornercases.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/latex_cornercases.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -4,6 +4,7 @@
\usepackage{ifthen}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
+\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{multirow}
\setcounter{secnumdepth}{0}
@@ -125,8 +126,8 @@
LaTeX writer needs bookkeeping to write out the required number of extra
'\&'s.
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.075\DUtablewidth}|p{0.133\DUtablewidth}|p{0.133\DUtablewidth}|p{0.086\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.075\DUtablewidth}|p{0.133\DUtablewidth}|p{0.133\DUtablewidth}|p{0.086\DUtablewidth}|}
\hline
11
@@ -167,8 +168,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.098\DUtablewidth}|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
11
@@ -192,8 +193,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
11
@@ -213,8 +214,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
11
@@ -241,8 +242,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
\hline
11
@@ -262,8 +263,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
\hline
11
@@ -283,8 +284,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.156\DUtablewidth}|p{0.110\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.156\DUtablewidth}|p{0.110\DUtablewidth}|}
\hline
11
@@ -300,8 +301,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
\hline
\multirow{2}{0.10\DUtablewidth}{%
1/2 3
@@ -317,8 +318,8 @@
\hline
\end{longtable*}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
\multirow{2}{0.10\DUtablewidth}{%
1/2 3
@@ -346,8 +347,8 @@
TODO:
Set alignment of nested tables without creating too much vertical space.
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.493\DUtablewidth}|p{0.214\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.493\DUtablewidth}|p{0.214\DUtablewidth}|}
\hline
Lorem ipsum dolor sit amet, consectetur
@@ -356,8 +357,8 @@
\\
\hline
-\setlength{\DUtablewidth}{\linewidth}
-\begin{tabular}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{tabular}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\hline
1
@@ -371,8 +372,9 @@
\\
\hline
-\setlength{\DUtablewidth}{\linewidth}
-\begin{tabular}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\noindent\makebox[\linewidth][l]{%
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{tabular}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\hline
1
@@ -381,7 +383,59 @@
\\
\hline
\end{tabular}
+}
+ &
+cell 1, 2
+ \\
+\hline
+\noindent\makebox[\linewidth][c]{%
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{tabular}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+\end{tabular}
+}
+ &
+cell 1, 2
+ \\
+\hline
+
+\noindent\makebox[\linewidth][r]{%
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{tabular}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+\end{tabular}
+}
+ &
+cell 1, 2
+ \\
+\hline
+
+\noindent\makebox[\linewidth][r]{%
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{tabular}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+\end{tabular}
+}
+
\begin{description}
\item[{definition:}] \leavevmode
list
@@ -397,4 +451,56 @@
\hline
\end{longtable*}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{p{0.493\DUtablewidth}p{0.214\DUtablewidth}}
+\toprule
+
+Lorem ipsum dolor sit amet, consectetur
+ &
+adipisicing elit
+ \\
+
+\noindent\makebox[\linewidth][r]{%
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{tabular}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+\end{tabular}
+}
+ &
+cell 1, 2
+ \\
+
+\noindent\makebox[\linewidth][r]{%
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{tabular}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+\end{tabular}
+}
+
+\begin{description}
+\item[{definition:}] \leavevmode
+list
+
+\end{description}
+ &
+cell 2, 2
+ \\
+ &
+cell 3, 2
+ \\
+\bottomrule
+\end{longtable*}
+
\end{document}
Modified: trunk/docutils/test/functional/expected/latex_literal_block.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/latex_literal_block.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -71,8 +71,8 @@
A literal block in a table:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
test
@@ -90,7 +90,7 @@
A literal block in a table with auto-width columns:
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
test &
\ttfamily\raggedright
Modified: trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -71,8 +71,8 @@
A literal block in a table:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
test
@@ -90,7 +90,7 @@
A literal block in a table with auto-width columns:
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
test &
\ttfamily\raggedright
Modified: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -73,8 +73,8 @@
A literal block in a table:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
test
@@ -93,7 +93,7 @@
A literal block in a table with auto-width columns:
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
test &
\lstset{xleftmargin=0pt}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -70,8 +70,8 @@
A literal block in a table:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
test
@@ -89,7 +89,7 @@
A literal block in a table with auto-width columns:
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
test &
\ttfamily\raggedright
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -71,8 +71,8 @@
A literal block in a table:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
\hline
test
@@ -90,7 +90,7 @@
A literal block in a table with auto-width columns:
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
test &
\ttfamily\raggedright
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -884,8 +884,8 @@
\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}
\caption{Plaintext markup syntax and parser system.}
\begin{DUlegend}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
\hline
re
@@ -974,7 +974,7 @@
Tables may be given titles and additional arguments with the \emph{table}
directive:
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[l]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{left-aligned table}\\
\hline
@@ -1011,7 +1011,7 @@
\hline
\end{longtable}
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{center-aligned table}\\
\hline
@@ -1048,7 +1048,7 @@
\hline
\end{longtable}
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{right-aligned table}\\
\hline
@@ -1089,7 +1089,7 @@
column widths are determined by the backend (if supported by the
writer/backend).
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
\textbf{A} & \textbf{B} & \textbf{A or B} \\
\hline
@@ -1329,8 +1329,8 @@
Compound 7, tests the inclusion of various block-level
elements in one logical paragraph. First a table,
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
\hline
Left cell, first
@@ -1538,8 +1538,8 @@
This table has a cell spanning two columns:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
\hline
\multicolumn{2}{|p{0.15\DUtablewidth}|}{\textbf{%
Inputs
@@ -1616,8 +1616,8 @@
Here's a table with cells spanning several rows:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
\hline
\textbf{%
Header row, column 1
@@ -1676,8 +1676,8 @@
Here's a list table exercising all features:
\begin{DUclass}{test}
-\setlength{\DUtablewidth}{40em}
-\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
+\setlength{\DUtablewidth}{40em}%
+\begin{longtable}{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
\caption{list table with integral header}\\
\hline
\textbf{%
@@ -1840,8 +1840,8 @@
\begin{description}
\item[{Math-Accents:}] \leavevmode
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
$\acute{a}$ \texttt{\textbackslash{}acute\{a\}}
&
@@ -2072,8 +2072,8 @@
A table with multi-paragraph multicolumn cells:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.133\DUtablewidth}|p{0.179\DUtablewidth}|p{0.179\DUtablewidth}|p{0.110\DUtablewidth}|p{0.121\DUtablewidth}|p{0.145\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.133\DUtablewidth}|p{0.179\DUtablewidth}|p{0.179\DUtablewidth}|p{0.110\DUtablewidth}|p{0.121\DUtablewidth}|p{0.145\DUtablewidth}|}
\hline
test
@@ -2132,7 +2132,7 @@
A table with multirow header and column-widths set by LaTeX:
-\begin{longtable*}[c]{|l|l|}
+\begin{longtable*}{|l|l|}
\hline
\multirow{2}{*}{\textbf{XXX}} & \textbf{Variable Summary} \\
\cline{2-2}
@@ -2155,7 +2155,7 @@
In a table with column-widths set by LaTeX, each cell has just one line.
Paragraphs are merged (a warning is given).
-\begin{longtable*}[c]{|l|l|}
+\begin{longtable*}{|l|l|}
\hline
11 & first paragraph
second paragraph
@@ -2220,8 +2220,8 @@
Punctuation and footnote symbols
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.028\DUtablewidth}|p{0.424\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.028\DUtablewidth}|p{0.424\DUtablewidth}|}
\hline
–
@@ -2329,8 +2329,8 @@
The \DUroletitlereference{Latin-1 extended} Unicode block
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.051\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.051\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|}
\hline
%
@@ -2673,8 +2673,8 @@
\phantomsection\label{hypertarget-in-plain-text}hypertarget in plain text or in a figure but not in a longtable or
caption:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{Table with %
\label{hypertarget-in-table-title}hypertarget in table title.}\\
\hline
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -888,8 +888,8 @@
\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}
\caption{Plaintext markup syntax and parser system.}
\begin{DUlegend}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
\hline
re
@@ -978,7 +978,7 @@
Tables may be given titles and additional arguments with the \emph{table}
directive:
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[l]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{left-aligned table}\\
\hline
@@ -1015,7 +1015,7 @@
\hline
\end{longtable}
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{center-aligned table}\\
\hline
@@ -1052,7 +1052,7 @@
\hline
\end{longtable}
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{right-aligned table}\\
\hline
@@ -1093,7 +1093,7 @@
column widths are determined by the backend (if supported by the
writer/backend).
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
\textbf{A} & \textbf{B} & \textbf{A or B} \\
\hline
@@ -1333,8 +1333,8 @@
Compound 7, tests the inclusion of various block-level
elements in one logical paragraph. First a table,
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
\hline
Left cell, first
@@ -1542,8 +1542,8 @@
This table has a cell spanning two columns:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
\hline
\multicolumn{2}{|p{0.15\DUtablewidth}|}{\textbf{%
Inputs
@@ -1620,8 +1620,8 @@
Here’s a table with cells spanning several rows:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
\hline
\textbf{%
Header row, column 1
@@ -1680,8 +1680,8 @@
Here’s a list table exercising all features:
\begin{DUclass}{test}
-\setlength{\DUtablewidth}{40em}
-\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
+\setlength{\DUtablewidth}{40em}%
+\begin{longtable}{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
\caption{list table with integral header}\\
\hline
\textbf{%
@@ -1844,8 +1844,8 @@
\begin{description}
\item[{Math-Accents:}] \leavevmode
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
$\acute{a}$ \texttt{\textbackslash{}acute\{a\}}
&
@@ -2076,8 +2076,8 @@
A table with multi-paragraph multicolumn cells:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.133\DUtablewidth}|p{0.179\DUtablewidth}|p{0.179\DUtablewidth}|p{0.110\DUtablewidth}|p{0.121\DUtablewidth}|p{0.145\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.133\DUtablewidth}|p{0.179\DUtablewidth}|p{0.179\DUtablewidth}|p{0.110\DUtablewidth}|p{0.121\DUtablewidth}|p{0.145\DUtablewidth}|}
\hline
test
@@ -2136,7 +2136,7 @@
A table with multirow header and column-widths set by LaTeX:
-\begin{longtable*}[c]{|l|l|}
+\begin{longtable*}{|l|l|}
\hline
\multirow{2}{*}{\textbf{XXX}} & \textbf{Variable Summary} \\
\cline{2-2}
@@ -2159,7 +2159,7 @@
In a table with column-widths set by LaTeX, each cell has just one line.
Paragraphs are merged (a warning is given).
-\begin{longtable*}[c]{|l|l|}
+\begin{longtable*}{|l|l|}
\hline
11 & first paragraph
second paragraph
@@ -2224,8 +2224,8 @@
Punctuation and footnote symbols
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.028\DUtablewidth}|p{0.424\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.028\DUtablewidth}|p{0.424\DUtablewidth}|}
\hline
–
@@ -2333,8 +2333,8 @@
The \DUroletitlereference{Latin-1 extended} Unicode block
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.051\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.051\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|p{0.028\DUtablewidth}|}
\hline
%
@@ -2677,8 +2677,8 @@
\phantomsection\label{hypertarget-in-plain-text}hypertarget in plain text or in a figure but not in a longtable or
caption:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{Table with %
\label{hypertarget-in-table-title}hypertarget in table title.}\\
\hline
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-11-25 23:06:30 UTC (rev 8576)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-11-25 23:06:44 UTC (rev 8577)
@@ -749,8 +749,8 @@
\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}
\caption{Plaintext markup syntax and parser system.}
\begin{DUlegend}
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.156\DUtablewidth}|p{0.563\DUtablewidth}|}
\hline
re
@@ -839,7 +839,7 @@
Tables may be given titles and additional arguments with the \emph{table}
directive:
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[l]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{left-aligned table}\\
\hline
@@ -876,7 +876,7 @@
\hline
\end{longtable}
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{center-aligned table}\\
\hline
@@ -913,7 +913,7 @@
\hline
\end{longtable}
-\setlength{\DUtablewidth}{\linewidth}
+\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
\caption{right-aligned table}\\
\hline
@@ -954,7 +954,7 @@
column widths are determined by the backend (if supported by the
writer/backend).
-\begin{longtable*}[c]{|l|l|l|}
+\begin{longtable*}{|l|l|l|}
\hline
\textbf{A} & \textbf{B} & \textbf{A or B} \\
\hline
@@ -1218,8 +1218,8 @@
Compound 7, tests the inclusion of various block-level
elements in one logical paragraph. First a table,
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|p{0.249\DUtablewidth}|}
\hline
Left cell, first
@@ -1428,8 +1428,8 @@
This table has a cell spanning two columns:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|p{0.086\DUtablewidth}|}
\hline
\multicolumn{2}{|p{0.15\DUtablewidth}|}{\textbf{%
Inputs
@@ -1506,8 +1506,8 @@
Here’s a table with cells spanning several rows:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.296\DUtablewidth}|p{0.156\DUtablewidth}|p{0.226\DUtablewidth}|}
\hline
\textbf{%
Header row, column 1
@@ -1566,8 +1566,8 @@
Here’s a list table exercising all features:
\begin{DUclass}{test}
-\setlength{\DUtablewidth}{40em}
-\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
+\setlength{\DUtablewidth}{40em}%
+\begin{longtable}{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
\caption{list table with integral header}\\
\hline
\textbf{%
@@ -1730,8 +1730,8 @@
\begin{description}
\item[{Math-Accents:}] \leavevmode
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
$\acute{a}$ \texttt{\textbackslash{}acute\{a\}}
&
@@ -1962,8 +1962,8 @@
A table with multi-paragraph multicolumn cells:
-\setlength{\DUtablewidth}{\linewidth}
-\begin{longtable*}[c]{|p{0.133\DUtablewidth}|p{0.179\DUtablewidth}|p{0.179\DUtablewidth}|p{0.110\DUtablewidth}|p{0.121\DUtablewidth}|p{0.145\DUtablewidth}|}...
[truncated message content] |
|
From: <mi...@us...> - 2020-11-27 09:22:52
|
Revision: 8581
http://sourceforge.net/p/docutils/code/8581
Author: milde
Date: 2020-11-27 09:22:49 +0000 (Fri, 27 Nov 2020)
Log Message:
-----------
Implement feature request #40 Option to embed images as data URI.
If the new "embed_image" configuration setting is true, the image
can be read from the local file system, and its MIME type can be
determined, it is base64 encoded and included as a data URI.
TODO:
* Add an "embed" option to the "image" directive to allow embedding
of individual images?
* Use direct inlinging for SVG in HTML5?
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
Added Paths:
-----------
trunk/docutils/test/functional/expected/embed_images_html5.html
trunk/docutils/test/functional/input/embed_images.txt
trunk/docutils/test/functional/tests/embed_images_html5.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-11-26 23:08:18 UTC (rev 8580)
+++ trunk/docutils/HISTORY.txt 2020-11-27 09:22:49 UTC (rev 8581)
@@ -25,6 +25,7 @@
- Installing with ``setup.py`` now requires ``setuptools``.
Alternatively, install with `pip`_ (or "manually").
- Apply patch for bug #399 Fixes in Korean translation.
+ - Implement feature request #40 `Option to embed images as data URI`.
* docutils/MANIFEST.in
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2020-11-26 23:08:18 UTC (rev 8580)
+++ trunk/docutils/RELEASE-NOTES.txt 2020-11-27 09:22:49 UTC (rev 8581)
@@ -78,6 +78,8 @@
* Installing with ``setup.py`` now requires setuptools_.
Alternatively, install with pip_.
+
+* HTML writers: new option to embed images.
* HTML5 writer:
@@ -101,8 +103,6 @@
.. _initial_header_level: docs/user/config.html#initial-header-level
__ https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article
-
-
* LaTeX writer:
- New configuration setting `legacy_class_functions`_.
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2020-11-26 23:08:18 UTC (rev 8580)
+++ trunk/docutils/docs/user/config.txt 2020-11-27 09:22:49 UTC (rev 8581)
@@ -956,7 +956,22 @@
Default: enabled (True).
Options: ``--compact-field-lists, --no-compact-field-lists``.
+embed_images
+~~~~~~~~~~~~
+Embed images in the output HTML file. If the image can be read from
+the local file system and its MIME type can be determined, it is
+base64_ encoded and included as a `data URI`_.
+
+Default: disabled (False).
+Options: ``--embed-images``, ``--link-images``
+
+New in Docutils 0.17.
+
+.. _base64: https://en.wikipedia.org/wiki/Base64
+.. _data URI: https://en.wikipedia.org/wiki/Data_URI_scheme
+
+
.. _embed_stylesheet [html writers]:
embed_stylesheet
@@ -1033,7 +1048,7 @@
* It is recommended to install__ the MathJax library on the same
server as the rest of the deployed site files.
- __ http://docs.mathjax.org/en/latest/installation.html
+ __ https://www.mathjax.org/#installnow
Example: Install the library at the top level of the web
server’s hierarchy in the directory ``MathJax`` and set::
@@ -1046,13 +1061,14 @@
Downside: Downloads JavaScript code from a third-party site --- opens
the door to cross-site scripting attacs!
- Example: MathJax.org recommends ``cdnjs.cloudflare.com``::
+ Example: MathJax `getting started`__ documentation uses::
math-output: mathjax
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js
+ https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
- See https://cdnjs.com/about and https://www.cloudflare.com/terms/ for
- details and terms of use.
+ See https://www.jsdelivr.com/ for details and terms of use.
+
+ __ https://www.mathjax.org/#gettingstarted
* Use a local MathJax installation on the *client* machine, e.g.::
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2020-11-26 23:08:18 UTC (rev 8580)
+++ trunk/docutils/docutils/writers/_html_base.py 2020-11-27 09:22:49 UTC (rev 8581)
@@ -17,9 +17,11 @@
"""common definitions for Docutils HTML writers"""
+import base64
+import mimetypes
+import os, os.path
+import re
import sys
-import os.path
-import re
try: # check for the Python Imaging Library
import PIL.Image
@@ -905,19 +907,10 @@
self.header.extend(header)
del self.body[start:]
- # Image types to place in an <object> element
- object_image_types = {'.swf': 'application/x-shockwave-flash'}
-
def visit_image(self, node):
atts = {}
uri = node['uri']
- ext = os.path.splitext(uri)[1].lower()
- if ext in self.object_image_types:
- atts['data'] = uri
- atts['type'] = self.object_image_types[ext]
- else:
- atts['src'] = uri
- atts['alt'] = node.get('alt', uri)
+ mimetype = mimetypes.guess_type(uri)[0]
# image size
if 'width' in node:
atts['width'] = node['width']
@@ -966,12 +959,35 @@
suffix = ''
if 'align' in node:
atts['class'] = 'align-%s' % node['align']
- if ext in self.object_image_types:
+ # Embed image file (embedded SVG or data URI):
+ if self.settings.embed_images or ('embed' in node):
+ err_msg = ''
+ if not mimetype:
+ err_msg = 'unknown MIME type for "%s"' % uri
+ if not self.settings.file_insertion_enabled:
+ err_msg = 'file insertion disabled.'
+ try:
+ with open(url2pathname(uri), 'rb') as imagefile:
+ imagedata = imagefile.read()
+ except IOError as err:
+ err_msg = str(err)
+ if not err_msg:
+ # TODO (test mimetype for SVG and insert directly)
+ data64 = base64.b64encode(imagedata).decode()
+ uri = u'data:%s;base64,%s' % (mimetype, data64)
+ else:
+ # raise NotImplementedError(os.getcwd() + err_msg)
+ self.document.reporter.error("Cannot embed image\n "+err_msg)
+
+ if mimetype == 'application/x-shockwave-flash':
+ atts['type'] = mimetype
# do NOT use an empty tag: incorrect rendering in browsers
- self.body.append(self.starttag(node, 'object', '', **atts) +
- node.get('alt', uri) + '</object>' + suffix)
+ tag = (self.starttag(node, 'object', '', data=uri, **atts)
+ + node.get('alt', uri) + '</object>' + suffix)
else:
- self.body.append(self.emptytag(node, 'img', suffix, **atts))
+ atts['alt'] = node.get('alt', node['uri'])
+ tag = self.emptytag(node, 'img', suffix, src=uri, **atts)
+ self.body.append(tag)
def depart_image(self, node):
pass
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2020-11-26 23:08:18 UTC (rev 8580)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2020-11-27 09:22:49 UTC (rev 8581)
@@ -124,6 +124,15 @@
('Disable compact simple field lists.',
['--no-compact-field-lists'],
{'dest': 'compact_field_lists', 'action': 'store_false'}),
+ ('Embed images in the output HTML file, if the image '
+ 'files are accessible during processing.',
+ ['--embed-images'],
+ {'default': 0, 'action': 'store_true',
+ 'validator': frontend.validate_boolean}),
+ ('Link to images in the output HTML file. '
+ 'This is the default.',
+ ['--link-images'],
+ {'dest': 'embed_images', 'action': 'store_false'}),
('Added to standard table classes. '
'Defined styles: "borderless". Default: ""',
['--table-style'],
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-11-26 23:08:18 UTC (rev 8580)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-11-27 09:22:49 UTC (rev 8581)
@@ -114,6 +114,15 @@
('Disable compact simple field lists.',
['--no-compact-field-lists'],
{'dest': 'compact_field_lists', 'action': 'store_false'}),
+ ('Embed images in the output HTML file, if the image '
+ 'files are accessible during processing.',
+ ['--embed-images'],
+ {'default': 0, 'action': 'store_true',
+ 'validator': frontend.validate_boolean}),
+ ('Link to images in the output HTML file. '
+ 'This is the default.',
+ ['--link-images'],
+ {'dest': 'embed_images', 'action': 'store_false'}),
('Added to standard table classes. '
'Defined styles: borderless, booktabs, '
'align-left, align-center, align-right, colwidths-auto. '
Added: trunk/docutils/test/functional/expected/embed_images_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/embed_images_html5.html (rev 0)
+++ trunk/docutils/test/functional/expected/embed_images_html5.html 2020-11-27 09:22:49 UTC (rev 8581)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta charset="utf-8"/>
+<meta name="generator" content="Docutils 0.17b.dev: http://docutils.sourceforge.net/" />
+<title>Embedded Images</title>
+<link rel="stylesheet" href="../../../docutils/writers/html5_polyglot/minimal.css" type="text/css" />
+<link rel="stylesheet" href="../../../docutils/writers/html5_polyglot/plain.css" type="text/css" />
+</head>
+<body>
+<main id="embedded-images">
+<h1 class="title">Embedded Images</h1>
+
+<p>The “embed” flag tells Docutils that it should
+try to embed the image in the output document.</p>
+<p>If the image can be read from the local file system, it is <a class="reference external" href="https://en.wikipedia.org/wiki/Base64">base64</a>
+encoded and included as a <a class="reference external" href="https://en.wikipedia.org/wiki/Data_URI_scheme">data URI</a>.
+In future, SVG images may be directly inserted into HTML5.</p>
+<blockquote>
+<figure class="align-center">
+<img alt="biohazard" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiCiAgIHhtbG5zOmlua3NjYXBlPSJodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy9uYW1lc3BhY2VzL2lua3NjYXBlIgogICBzb2RpcG9kaTpkb2NuYW1lPSJiaW9oYXphcmQuc3ZnIgogICBpbmtzY2FwZTp2ZXJzaW9uPSIwLjQ3IHIyMjU4MyIKICAgc29kaXBvZGk6dmVyc2lvbj0iMC4zMiIKICAgaWQ9InN2ZzI0MTU5IgogICBoZWlnaHQ9IjQ4IgogICB3aWR0aD0iNDgiCiAgIHZlcnNpb249IjEuMCI+CiAgPHRpdGxlCiAgICAgaWQ9InRpdGxlMjgzNyI+QmlvaGF6YXJkPC90aXRsZT4KICA8bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGE3Ij4KICAgIDxyZGY6UkRGPgogICAgICA8Y2M6V29yawogICAgICAgICByZGY6YWJvdXQ9IiI+CiAgICAgICAgPGRjOmZvcm1hdD5pbWFnZS9zdmcreG1sPC9kYzpmb3JtYXQ+CiAgICAgICAgPGRjOnR5cGUKICAgICAgICAgICByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPgogICAgICAgIDxkYzp0aXRsZT5CaW9oYXphcmQ8L2RjOnRpdGxlPgogICAgICAgIDxjYzpsaWNlbnNlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9saWNlbnNlcy9wdWJsaWNkb21haW4vIiAvPgogICAgICAgIDxkYzpkZXNjcmlwdGlvbj5TdGFuZGFsb25lIGJpb2hhemFyZCBzeW1ib2wsIHdpdGggbm8gYm9yZGVyLCBiYWNrZ3JvdW5kIG9yIGRlc2NyaXB0aXZlIHRleHQuPC9kYzpkZXNjcmlwdGlvbj4KICAgICAgICA8ZGM6Y3JlYXRvcj4KICAgICAgICAgIDxjYzpBZ2VudD4KICAgICAgICAgICAgPGRjOnRpdGxlPlNpbHNvcjwvZGM6dGl0bGU+CiAgICAgICAgICA8L2NjOkFnZW50PgogICAgICAgIDwvZGM6Y3JlYXRvcj4KICAgICAgICA8ZGM6aWRlbnRpZmllcj48L2RjOmlkZW50aWZpZXI+CiAgICAgICAgPGRjOnNvdXJjZT48L2RjOnNvdXJjZT4KICAgICAgICA8ZGM6cmVsYXRpb24+aHR0cDovL2RlLndpa2lwZWRpYS5vcmcvd2lraS9EYXRlaTpCaW9oYXphcmRfc3ltYm9sLnN2ZzwvZGM6cmVsYXRpb24+CiAgICAgICAgPGRjOnB1Ymxpc2hlcj4KICAgICAgICAgIDxjYzpBZ2VudD4KICAgICAgICAgICAgPGRjOnRpdGxlPldpa2lwZWRpYTwvZGM6dGl0bGU+CiAgICAgICAgICA8L2NjOkFnZW50PgogICAgICAgIDwvZGM6cHVibGlzaGVyPgogICAgICAgIDxkYzpjb250cmlidXRvcj4KICAgICAgICAgIDxjYzpBZ2VudD4KICAgICAgICAgICAgPGRjOnRpdGxlPkJhc3RpcXVlLCBBbmR1eCwgTWFyaWFuU2lnbGVyLCBHTTwvZGM6dGl0bGU+CiAgICAgICAgICA8L2NjOkFnZW50PgogICAgICAgIDwvZGM6Y29udHJpYnV0b3I+CiAgICAgIDwvY2M6V29yaz4KICAgICAgPGNjOkxpY2Vuc2UKICAgICAgICAgcmRmOmFib3V0PSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9saWNlbnNlcy9wdWJsaWNkb21haW4vIj4KICAgICAgICA8Y2M6cGVybWl0cwogICAgICAgICAgIHJkZjpyZXNvdXJjZT0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjUmVwcm9kdWN0aW9uIiAvPgogICAgICAgIDxjYzpwZXJtaXRzCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyNEaXN0cmlidXRpb24iIC8+CiAgICAgICAgPGNjOnBlcm1pdHMKICAgICAgICAgICByZGY6cmVzb3VyY2U9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zI0Rlcml2YXRpdmVXb3JrcyIgLz4KICAgICAgPC9jYzpMaWNlbnNlPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGRlZnMKICAgICBpZD0iZGVmczUiPgogICAgPGlua3NjYXBlOnBlcnNwZWN0aXZlCiAgICAgICBzb2RpcG9kaTp0eXBlPSJpbmtzY2FwZTpwZXJzcDNkIgogICAgICAgaW5rc2NhcGU6dnBfeD0iMCA6IDE3OC4xMzEyNiA6IDEiCiAgICAgICBpbmtzY2FwZTp2cF95PSIwIDogMTAwMCA6IDAiCiAgICAgICBpbmtzY2FwZTp2cF96PSIzNzYuNDM3NSA6IDE3OC4xMzEyNiA6IDEiCiAgICAgICBpbmtzY2FwZTpwZXJzcDNkLW9yaWdpbj0iMTg4LjIxODc1IDogMTE4Ljc1NDE3IDogMSIKICAgICAgIGlkPSJwZXJzcGVjdGl2ZTI4MzUiIC8+CiAgPC9kZWZzPgogIDxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJzdmcyNDE1OSIKICAgICBpbmtzY2FwZTp3aW5kb3cteT0iMzMiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6Y3k9IjIyLjQ1NTQxOCIKICAgICBpbmtzY2FwZTpjeD0iMjIuMTUyNjM5IgogICAgIGlua3NjYXBlOnpvb209IjguOTMxNjY5MyIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI3NzEiCiAgICAgaW5rc2NhcGU6d2luZG93LXdpZHRoPSI5OTMiCiAgICAgaW5rc2NhcGU6cGFnZXNoYWRvdz0iMiIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBib3JkZXJjb2xvcj0iIzY2NjY2NiIKICAgICBwYWdlY29sb3I9IiNmZmZmZmYiCiAgICAgaWQ9ImJhc2UiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiIC8+CiAgPHBhdGgKICAgICBpZD0icGF0aDcyMTQiCiAgICAgc3R5bGU9ImZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZTtkaXNwbGF5OmlubGluZSIKICAgICBkPSJtIDIzLjU4NTE2MywxLjM3Nzc3MSBjIC03LjNlLTUsMS4xZS00IDYuMmUtNSwwLjAwMzkgMCwwLjAwMzkgMC4wMDEzLC0zLjU0ZS00IDAuMDAyNiwtMC4wMDMyIDAuMDAzOSwtMC4wMDM5IC00Ljc4ZS00LDAgLTAuMDAzNCwtMi4zZS01IC0wLjAwMzksMCB6IG0gLTAuMjkzMjg3LDAuMDExNzMgYyAtMC4wMDI3LDMuMzllLTQgLTAuMDA1MSwwLjAwMzIgLTAuMDA3OCwwLjAwMzkgMC4wMTA0NywtNi40N2UtNCAwLjAyMDgsLTAuMDAzMiAwLjAzMTMsLTAuMDAzOSAtMC4wMDI2LDMuMWUtNSAtMC4wMDUzLC0xLjE4ZS00IC0wLjAwNzgsMCAtMC4wMDU3LDIuNmUtNCAtMC4wMTAxNiwtNi45NGUtNCAtMC4wMTU2NCwwIHogbSAxLjQyMzQsMC4wMDc4IGMgMC4wMjA4NSwwLjAwMTYgMC4wNDE3NiwwLjAwMjMgMC4wNjI1NywwLjAwMzkgLTAuMDIwNDcsLTAuMDAxNiAtMC4wNDIwNCwtMC4wMDMyIC0wLjA2MjU3LC0wLjAwMzkgeiBtIDAuMDYyNTcsMC4wMDM5IGMgNS4yNjU5ODcsMC40MTg1NDcgOS40MTI0NTQsNC44MzMyMzQzIDkuNDEyNDU0LDEwLjIwNjI1OCAwLDUuNDcwNzY3IC00LjMwMzU1Myw5LjkzMjc4MSAtOS43MDU3NDMsMTAuMjEwMTgyIGwgMCwyLjA5NjAwNCBjIDEuNDc0ODUyLDAuMjMzMTcgMi42MDQzNzEsMS41MTM5OTMgMi42MDQzNzEsMy4wNTQwNTkgMCwwLjM3NjkzMiAtMC4wNjc4NiwwLjczNzM5MyAtMC4xOTE2MTQsMS4wNzE0NjUgbCAxLjkxNjEyNSwxLjEwNjY1MyBjIDIuOTYxMTgsLTQuNDczMDQyIDguOTM1NDg1LC01LjkzMjU4NiAxMy42NDM1NDMsLTMuMjE0Mzk1IDQuNjk2ODU4LDIuNzExNzM5IDYuNDMxMTE3LDguNTk0NzA2IDQuMDYyOTUxLDEzLjM4OTM3MyAzLjI1MDEyLC02LjMyNTkyNyAwLjk5MDAzNywtMTQuMTY2NTg2IC01LjIzNjA3OSwtMTcuNzYxMjQ2IC0xLjU1Nzc4MywtMC44OTkzODMgLTMuMjE3NTYsLTEuNDQ3MzAyIC00Ljg5NTg4MywtMS42NzM2NjYgMC42NDI0MjYsLTEuNTY2Mjk5IDAuOTk3MTU5LC0zLjI4MTM4NCAwLjk5NzE1OSwtNS4wNzk2NzggMCwtNy4xMzY5NDk3IC01LjU3NjYzOSwtMTIuOTc5NTM2IC0xMi42MDcyODQsLTEzLjQwNTAwOSB6IG0gLTEuNzE2NjgyLDAuMDA3OCBjIC02Ljk5NTUwNywwLjQ2MjA0NyAtMTIuNTM2ODk3LDYuMjg1NDY5MyAtMTIuNTM2ODk3LDEzLjM5NzE4NyAwLDEuNzQ3MSAwLjMzMzkyLDMuNDE2ODI3IDAuOTQyNDE4LDQuOTQ2NzA5IEMgOS44MzgyOTkyLDE5Ljk5MTQ5OCA4LjIyNDA3MjIsMjAuNTMzOTg5IDYuNzExNTc5MiwyMS40MDcyMiAwLjUyNzE0NTU1LDI0Ljk3NzgwNiAtMS43MzgzMjk1LDMyLjczNTk4OSAxLjQxNjg0MzksMzkuMDM5NDM0IC0wLjg2MTIxMjg1LDM0LjI2NzczIDAuODg1Nzg1ODUsMjguNDYzNjYzIDUuNTQyMzU1MiwyNS43NzUxODYgMTAuMjgwMTc5LDIzLjAzOTgxNCAxNi4yOTU0MTYsMjQuNTM1ODkzIDE5LjIzNjczMSwyOS4wNzU2MSBsIDEuODQ5NjUzLC0xLjA2NzU1IGMgLTAuMTE2MjQ1LC0wLjMyNDk1OCAtMC4xNzU5NjgsLTAuNjc1NDIyIC0wLjE3NTk2OCwtMS4wNDAxNzcgMCwtMS40NzQ2ODQgMS4wMzM5MDQsLTIuNzA4MSAyLjQxNjY1MywtMy4wMTQ5NjMgbCAwLC0yLjEzODk5OCBjIC01LjM1NDM2MSwtMC4zMjc5NTkgLTkuNjA0MDUzLC00Ljc2OTg3OCAtOS42MDQwNTMsLTEwLjIwNjI4NCAwLC01LjM0ODQzNzcgNC4xMDY1MTEsLTkuNzQ1NTgxIDkuMzM4MTQxLC0xMC4xOTg0MzYgeiBtIDAuNTk4MywxMi44NTc1MzkgYyAtMi43MDI1MTMsMC4wNjIxNSAtNS4xOTM5LDAuOTgyMTk5IC03LjIzODIzOSwyLjQ3OTIzOSAwLjE2MzMxOSwwLjI0MTY3OCAwLjMzODgsMC40NzU1ODEgMC41MjM5OTUsMC42OTk5NjggMC4xODUyMTEsMC4yMjQzNzkgMC4zODEwMTgsMC40Mzk2NiAwLjU4NjU3MiwwLjY0NTIyIDAuMjA1NTUyLDAuMjA1NTUyIDAuNDIwODM4LDAuNDAxMzY4IDAuNjQ1MjMzLDAuNTg2NTY1IDAuMTY0OTc0LDAuMTM2MTY5IDAuMzQxNzMsMC4yNTg3NjMgMC41MTYxNzQsMC4zODMyMjYgMS41MDkwNDEsLTAuOTkwODAxIDMuMzE2MTU3LC0xLjU3MTk5MyA1LjI2MzQ2NiwtMS41NzE5OTMgMS45NDcyODYsLThlLTYgMy43NTA1MDYsMC41ODExOTIgNS4yNTk1NDUsMS41NzE5OTMgMC4xNzQ0NDYsLTAuMTI0NDYzIDAuMzUxMTkzLC0wLjI0NzA1NyAwLjUxNjE3NiwtMC4zODMyMjYgMC4yMjQzOSwtMC4xODUxOTcgMC40Mzk2NzMsLTAuMzgxMDEzIDAuNjQ1MjE5LC0wLjU4NjU2NSAwLjIwNTU2NywtMC4yMDU1NiAwLjQwMTM3NSwtMC40MjA4NDEgMC41ODY1NzgsLTAuNjQ1MjIgMC4xODUxOTUsLTAuMjI0Mzg3IDAuMzYwNjY5LC0wLjQ1ODI5IDAuNTIzOTk4LC0wLjY5OTk2OCAtMi4xMTgyMjgsLTEuNTUxMTQzIC00LjcxNjA1MSwtMi40NzkyMzkgLTcuNTMxNTE2LC0yLjQ3OTIzOSAtMC4wNjU5OSwwIC0wLjEzMzY4OSwtNy44OGUtNCAtMC4xOTk0NDUsMCAtMC4wMzIxLDUuMDRlLTQgLTAuMDY1NzIsLTcuMzNlLTQgLTAuMDk3NzUsMCB6IG0gLTEyLjMxNzkxLDExLjI3Nzg2NyBjIC0wLjI4NDIyMywyLjYxMDAwMyAwLjIxMTE5OSw1LjMyMzk3MSAxLjYxODkyNCw3Ljc2MjI0IDEuNDA3NzM0LDIuNDM4MjUyIDMuNTEwMTU4LDQuMjI4MDU2IDUuOTEyNTkyLDUuMjg2OTE2IDAuMTI3NjQ4LC0wLjI2MjI4NCAwLjI0MjM5NCwtMC41MzI5NjcgMC4zNDQxMjEsLTAuODA1NTU2IDAuMTAxNzMxLC0wLjI3MjU3MyAwLjE5MDY3NiwtMC41NDgyMDkgMC4yNjU5MDIsLTAuODI4OTk5IDAuMDc1MjUsLTAuMjgwNzk3IDAuMTM5NTA0LC0wLjU2NTU2NCAwLjE4NzcwNCwtMC44NTI0ODEgMC4wMzU0NSwtMC4yMTA5NjQgMC4wNTM3NCwtMC40MjQxMSAwLjA3NDMxLC0wLjYzNzQxNSAtMS42MTI1ODgsLTAuODExNDYzIC0zLjAxODkyNSwtMi4wODcxNTcgLTMuOTkyNTc0LC0zLjc3MzU3OCAtMC45NzM2NTIsLTEuNjg2NDEyIC0xLjM3NDQzNiwtMy41MzkzOTkgLTEuMjcwODk5LC01LjM0MTY2NCAtMC4xOTQ5OTUsLTAuMDg4ODQgLTAuMzkwMDYyLC0wLjE3OTM5MSAtMC41OTA0ODIsLTAuMjU0MTg3IC0wLjI3MjU3NywtMC4xMDE3MSAtMC41NDgyMTYsLTAuMTkwNjY0IC0wLjgyOTAxMiwtMC4yNjU5MDkgLTAuMjgwNzk0LC0wLjA3NTIzIC0wLjU2NTU1MiwtMC4xMzU1ODUgLTAuODUyNDczLC0wLjE4Mzc4NiAtMC4yODY5MTksLTAuMDQ4MjEgLTAuNTc3MTU1LC0wLjA4NDk5IC0wLjg2ODExOSwtMC4xMDU1ODIgeiBtIDI1LjMxNjIzNCwwLjE1MjQ5OCBjIC0wLjI5MDk3NiwwLjAyMDY0IC0wLjU4MTE5NiwwLjA1NzQzIC0wLjg2ODExOCwwLjEwNTU5MiAtMC4yODY5MjQsMC4wNDgyMSAtMC41NzE2OTQsMC4xMDg1NTEgLTAuODUyNDg5LDAuMTgzNzk2IC0wLjI4MDc4LDAuMDc1MjMgLTAuNTYwMzMxLDAuMTY0MTg4IC0wLjgzMjkxNywwLjI2NTkxNiAtMC4yMDA0MTYsMC4wNzQ3NSAtMC4zOTE1NjgsMC4xNjkyMzggLTAuNTg2NTYyLDAuMjU4MDc5IDAuMTAzNTI5LDEuODAyMjU3IC0wLjI5NzI1NCwzLjY1NTI2OCAtMS4yNzA5MDQsNS4zNDE2NzIgLTAuOTczNjQ0LDEuNjg2NDA1IC0yLjM3OTk4NywyLjk1ODE5OCAtMy45OTI1NTYsMy43Njk2NjMgMC4wMjA1NiwwLjIxMzI5NiAwLjAzODg1LDAuNDI2NDUgMC4wNzQyOSwwLjYzNzQwNiAwLjA0ODIsMC4yODY5MjUgMC4xMDg1NDQsMC41NzE2ODQgMC4xODM3ODcsMC44NTI0OSAwLjA3NTI0LDAuMjgwNzg5IDAuMTY0MTk1LDAuNTYwMzQ5IDAuMjY1OTE3LDAuODMyOTEzIDAuMTAxNzEsMC4yNzI1OTggMC4yMTY0OCwwLjUzOTM1NyAwLjM0NDExNSwwLjgwMTY1IDIuNDAyNDQxLC0xLjA1ODg3IDQuNTA0ODYzLC0yLjg0NDc1NiA1LjkxMjU5LC01LjI4MzAxOCAxLjQwNzc0OSwtMi40MzgyNjggMS45MDcwNTgsLTUuMTU2MTUxIDEuNjIyODQzLC03Ljc2NjE1NSB6IG0gLTE0Ljk4NDgzNiwzLjMwMDQyNCAtMS44NjEzNzYsMS4wNzkyODYgYyAyLjM5MzE3NSw0LjgwMDk3IDAuNjcyNDgsMTAuNzAyNDQ4IC00LjAzNTU2NCwxMy40MjA2NTQgLTQuNjg0ODc2LDIuNzA0ODA3IC0xMC42Mjg1NDE4LDEuMjgxNDM3IC0xMy42MDQ0NTM4LC0zLjE0MDA4NyAzLjg2MTY0NSw1Ljk1MDI4NiAxMS43NTg0Njk4LDcuOTAwODQyIDE3Ljk3MjQxMDgsNC4zMTMyMSAxLjUwNTI3MSwtMC44NjkwNzEgMi43NzUwNjIsLTEuOTg5NDMxIDMuNzkzMTMzLC0zLjI3MzAyNiAxLjAzODA2MiwxLjM0OTMyMyAyLjM1MTg2NCwyLjUyMTE3OCAzLjkxODI2NiwzLjQyNTUzOSA2LjIyMDkzMiwzLjU5MTY1MiAxNC4xMjcyNjMsMS42MzMxNyAxNy45ODQxNSwtNC4zMzI3NjggLTIuOTcwNDAxLDQuNDQwNjU4IC04LjkyMjcxNSw1Ljg3NzIzMSAtMTMuNjE2MTc0LDMuMTY3NDYxIC00LjczNzgxOCwtMi43MzUzODggLTYuNDQ5NTExLC04LjY5MzQ2NSAtMy45ODg2NTksLTEzLjUxMDU5IEwgMjYuMjk5MDIsMjkuMDI4NjE3IGMgLTAuNTY1NjkyLDAuNjI5ODQ0IC0xLjM4Njc2OCwxLjAyODQ0OCAtMi4yOTkzNDgsMS4wMjg0NDggLTAuOTI3NTc3LDAgLTEuNzYwMjk5LC0wLjQxMTc5MSAtMi4zMjY3MiwtMS4wNTk3MzYgeiIgLz4KPC9zdmc+Cg==" />
+<figcaption>
+<p>SVG image embedded in a figure.</p>
+</figcaption>
+</figure>
+</blockquote>
+<p>Embedded inline image <img alt="inline-embedded" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAANkE3LLaAgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAZQTFRF////AAAAVcLTfgAAAAF0Uk5TAEDm2GYAAAA2SURBVHicYmBRYOAQYJCQYJC+wSBjAUL2fxjq6hgueTNM7AQh3g0MzAdAiP0BUBYAAAD//wMA4pkLDrFBDzUAAAAASUVORK5CYII=" style="height: 0.8em;" /> scaled to a height of 0.8 em.</p>
+<blockquote>
+</blockquote>
+</main>
+</body>
+</html>
Property changes on: trunk/docutils/test/functional/expected/embed_images_html5.html
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/input/embed_images.txt
===================================================================
--- trunk/docutils/test/functional/input/embed_images.txt (rev 0)
+++ trunk/docutils/test/functional/input/embed_images.txt 2020-11-27 09:22:49 UTC (rev 8581)
@@ -0,0 +1,25 @@
+Embedded Images
+---------------
+
+The "embed" flag tells Docutils that it should
+try to embed the image in the output document.
+
+If the image can be read from the local file system, it is base64_
+encoded and included as a `data URI`_.
+In future, SVG images may be directly inserted into HTML5.
+
+ .. figure:: ../docs/user/rst/images/biohazard.svg
+ :alt: biohazard
+ :align: center
+
+ SVG image embedded in a figure.
+
+
+Embedded inline image |inline-embedded| scaled to a height of 0.8 em.
+
+ .. |inline-embedded| image:: ../docs/user/rst/images/biohazard.png
+ :height: 0.8 em
+
+.. _base64: https://en.wikipedia.org/wiki/Base64
+.. _data URI: https://en.wikipedia.org/wiki/Data_URI_scheme
+
Property changes on: trunk/docutils/test/functional/input/embed_images.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/tests/embed_images_html5.py
===================================================================
--- trunk/docutils/test/functional/tests/embed_images_html5.py (rev 0)
+++ trunk/docutils/test/functional/tests/embed_images_html5.py 2020-11-27 09:22:49 UTC (rev 8581)
@@ -0,0 +1,14 @@
+with open('functional/tests/_standalone_rst_defaults.py') as _f:
+ exec(_f.read())
+
+# Source and destination file names.
+test_source = "embed_images.txt"
+test_destination = "embed_images_html5.html"
+
+# Keyword parameters passed to publish_file.
+writer_name = "html5"
+
+# Settings:
+settings_overrides['smart_quotes'] = 'yes'
+settings_overrides['embed_images'] = 'yes'
+
Property changes on: trunk/docutils/test/functional/tests/embed_images_html5.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-01 09:38:05
|
Revision: 8582
http://sourceforge.net/p/docutils/code/8582
Author: milde
Date: 2020-12-01 09:38:02 +0000 (Tue, 01 Dec 2020)
Log Message:
-----------
Do not write Docutils-generated ToC, when ``use_latex_toc`` is True.
This did happen when publishing from a doctree.
Thanks to Thomas Krug for the report.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
Added Paths:
-----------
trunk/docutils/test/test_writers/test_latex2e_misc.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-11-27 09:22:49 UTC (rev 8581)
+++ trunk/docutils/HISTORY.txt 2020-12-01 09:38:02 UTC (rev 8582)
@@ -89,7 +89,6 @@
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
-
- Remove backwards compatibility code for the deprecated
`styling command`__ prefix ``\docutilsrole``.
@@ -96,7 +95,7 @@
__ docs/user/latex.html#custom-interpreted-text-roles
- Support the `memoir` LaTeX document class.
- Fixes #390, #391, and #392.
+ Fixes bugs #390, #391, and #392.
- The special value "auto" for the `graphicx_option`_ setting
is no longer supported (it never worked for xetex/luatex).
@@ -115,10 +114,13 @@
- Fix bug #408 "Incorrect assert in latex writer
for multiple citation references".
-
+
- Apply patch #175 "Fix alignment of nested tables",
additional fixes to table alignment.
-
+
+ - Do not write Docutils-generated ToC, when ``use_latex_toc``
+ is True. (This did happen when publishing from a doctree.)
+
* docutils/writers/manpage.py
- Fix #394 fix missing new line after rubric.
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-11-27 09:22:49 UTC (rev 8581)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-12-01 09:38:02 UTC (rev 8582)
@@ -3132,6 +3132,8 @@
title)
self.out.append('\n\\tableofcontents\n')
self.has_latex_toc = True
+ # ignore rest of node content
+ raise nodes.SkipNode
else: # Docutils generated contents list
# set flag for visit_bullet_list() and visit_title()
self.is_toc_list = True
Added: trunk/docutils/test/test_writers/test_latex2e_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e_misc.py (rev 0)
+++ trunk/docutils/test/test_writers/test_latex2e_misc.py 2020-12-01 09:38:02 UTC (rev 8582)
@@ -0,0 +1,59 @@
+#! /usr/bin/env python
+# coding: utf-8
+
+# $Id$
+# Author: Günter Milde
+# Maintainer: doc...@li...
+# :Copyright: 2020 Günter Milde,
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+
+"""
+Miscellaneous LaTeX writer tests.
+"""
+from __future__ import absolute_import
+
+import os
+
+if __name__ == '__main__':
+ import __init__
+from test_writers import DocutilsTestSupport
+from docutils import core
+
+contents_test_input = """\
+.. contents:: TOC
+
+foo
+---
+
+bar
+---
+
+"""
+
+class TocTestCase(DocutilsTestSupport.StandardTestCase):
+
+ def test_publish_from_doctree(self):
+ """Ignore the Docutils-generated ToC, when ``use_latex_toc``
+ is True. (This did happen when publishing from a doctree.)
+ """
+ settings_overrides={'output_encoding': 'unicode',
+ '_disable_config': True,}
+ doctree = core.publish_doctree(contents_test_input,
+ settings_overrides=settings_overrides)
+ result = core.publish_from_doctree(doctree,
+ writer_name='latex',
+ settings_overrides=settings_overrides)
+ self.assertNotIn(r'\item \hyperref[foo]{foo}', result)
+ # self.assertIn(r'\tableofcontents', result)
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main()
Property changes on: trunk/docutils/test/test_writers/test_latex2e_misc.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-01 10:53:31
|
Revision: 8583
http://sourceforge.net/p/docutils/code/8583
Author: milde
Date: 2020-12-01 10:53:27 +0000 (Tue, 01 Dec 2020)
Log Message:
-----------
Documentation update.
Restructuring, New input, and fixed links for TODO list item
"Adaptable file extensions".
Update/fix some source comments.
Modified Paths:
--------------
trunk/docutils/docs/dev/todo.txt
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/directives/images.py
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2020-12-01 09:38:02 UTC (rev 8582)
+++ trunk/docutils/docs/dev/todo.txt 2020-12-01 10:53:27 UTC (rev 8583)
@@ -156,7 +156,7 @@
settings. These partially solve the problem, allowing or disabling
**all** file accesses, but not limited access.
-* Configuration file handling needs discussion:
+* Configuration_ file handling needs discussion:
- There should be some error checking on the contents of config
files. How much checking should be done? How loudly should
@@ -497,7 +497,7 @@
* Add support for _`plugins`.
* _`Config directories`: Currently, ~/.docutils, ./docutils.conf/, &
- /etc/docutils.conf are read as configuration files. Proposal: allow
+ /etc/docutils.conf are read as configuration_ files. Proposal: allow
~/.docutils to be a a configuration *directory*, along with
/etc/docutils/ and ./docutils.conf/. Within these directories,
check for config.txt files. We can also have subdirectories here,
@@ -900,94 +900,6 @@
contexts). XLink/XPointer? ``.. baseref::``? See Doc-SIG
2001-08-10.
-* .. _adaptable file extensions:
-
- In target URLs, it would be useful to not explicitly specify the
- file extension. If we're generating HTML, then ".html" is
- appropriate; if PDF, then ".pdf"; etc. How about using ".*" to
- indicate "choose the most appropriate filename extension"? For
- example::
-
- .. _Another Document: another.*
-
- What is to be done for output formats that don't *have* hyperlinks?
- For example, LaTeX targeted at print. Hyperlinks may be "called
- out", as footnotes with explicit URLs. (Don't convert the links.)
-
- But then there's also LaTeX targeted at PDFs, which *can* have
- links. Perhaps a runtime setting for "*" could explicitly provide
- the extension, defaulting to the output file's extension.
-
- Should the system check for existing files? No, not practical.
-
- Handle documents only, or objects (images, etc.) also?
-
- If this handles images also, how to differentiate between document
- and image links? Element context (within "image")? Which image
- extension to use for which document format? Again, a runtime
- setting would suffice.
-
- This may not be just a parser issue; it may need framework support.
-
- Mailing list threads: `Images in both HTML and LaTeX`__ (especially
- `this summary of Lea's objections`__), `more-universal links?`__,
- `Output-format-sensitive link targets?`__
-
- __ http://thread.gmane.org/gmane.text.docutils.user/1239
- __ http://article.gmane.org/gmane.text.docutils.user/1278
- __ http://thread.gmane.org/gmane.text.docutils.user/1915
- __ http://thread.gmane.org/gmane.text.docutils.user/2438
-
- Idea from Jim Fulton: an external lookup table of targets:
-
- I would like to specify the extension (e.g. .txt) [in the
- source, rather than ``filename.*``], but tell the converter to
- change references to the files anticipating that the files will
- be converted too.
-
- For example::
-
- .. _Another Document: another.txt
-
- rst2html.py --convert-links "another.txt bar.txt" foo.txt
-
- That is, name the files for which extensions should be converted.
-
- Note that I want to refer to original files in the original text
- (another.txt rather than another.txt) because I want the
- unconverted text to stand on its own.
-
- Note that in most cases, people will be able to use globs::
-
- rst2html.py --convert-link-extensions-for "`echo *.txt`" foo.txt
-
- It might be nice to be able to use multiple arguments, as in::
-
- rst2html.py --convert-link-extensions-for *.txt -- foo.txt
-
- ::
-
- > What is to be done for output formats
- > that don't have hyperlinks?
-
- Don't convert the links.
-
- ::
-
- > Handle documents only, or objects
- > (images, etc.) also?
-
- No, documents only, but there really is no need for gueswork.
- Just get the file names as command-line arguments. EIBTI
- [explicit is better than implicit].
-
- For images, we probably need separate solution (which is being
- worked on), whereas for documents, the issue is basically
- interlinking between reStructuredText documents. IMO, this cries
- for support for multiple input and output files, i.e. support for
- documents which comprise multiple files. Adding adaptable file
- extensions seems like a kludge. // FW
-
* Implement the header row separator modification to table.el. (Wrote
to Takaaki Ota & the table.el mailing list on 2001-08-12, suggesting
support for "=====" header rows. On 2001-08-17 he replied, saying
@@ -1239,7 +1151,157 @@
particular, see the bodies of definition lists.
+Adaptable file extensions
+-------------------------
+Questions
+`````````
+
+Should Docutils support adaptable file extensions in hyperlinks?
+
+ In the rST source, sister documents are ".txt" files. If we're
+ generating HTML, then ".html" is appropriate; if PDF, then ".pdf";
+ etc.
+
+Handle documents only, or objects (images, etc.) also?
+
+ Different output formats support different sets of image formats (HTML
+ supports ".svg" but not ".pdf", pdfLaTeX supports ".pdf" but not ".svg",
+ LaTeX supports only ".eps").
+
+ This is less urgent 2020 than previously, as `pdflatex` and
+ `lualatex` are now standard and support most image formats. Also, a
+ wrapper like `rubber`__ that provide on-the-fly image conversion
+ depend on the "wrong" extension in the LaTeX source.
+
+ __ https://pypi.org/project/rubber/
+
+At what point should the extensions be substituted?
+
+ Transformations:
+ Fits well in the Docutils processing framework. (Writer-specific
+ configuration is still possible in the respective sections of the
+ configuration_ file.)
+
+ Writers:
+ May be simpler to code.
+
+ Pre- or post-processing:
+ Can be implemented independent of Docutils -- keeps Docutils simple.
+
+ ... those who need more sophisticated filename extension
+ tweaking can simply use regular expressions, which isn't too
+ difficult due to the determinability of the writers. So there
+ is no need to add a complex filename-extension-handling feature
+ to Docutils.
+
+ --- `Lea Wiemann in docutils-users 2004-06-04`__
+
+ __ https://sourceforge.net/p/docutils/mailman/message/6918089/
+
+
+Proposals
+`````````
+
+How about using ".*" to indicate "choose the most appropriate filename
+extension"? For example::
+
+ .. _Another Document: another.*
+
+* My point about using ``.*`` is that any other mechanism inside reST
+ leads to too many ambiguities in reading reST documents; at least
+ with ``.*`` it's clear that some kind of substitution is going on.
+
+ --- Aahz
+
+* What is to be done for output formats that don't *have* hyperlinks?
+ For example, LaTeX targeted at print. Hyperlinks may be "called
+ out", as footnotes with explicit URLs. (Don't convert the links.)
+
+ But then there's also LaTeX targeted at PDFs, which *can* have
+ links. Perhaps a runtime setting for "*" could explicitly provide
+ the extension, defaulting to the output file's extension.
+
+* If this handles images also, how to differentiate between document
+ and image links? Element context (within "image")? Which image
+ extension to use for which document format? For HTML output, there
+ is no reliable way of determining which extension to use (svg, png,
+ jpg, jpeg, gif, ...).
+
+ Should the system check for existing files? No, not practical (the
+ image files may be not available when the document is processed to HTML).
+
+ Mailing list threads: `Images in both HTML and LaTeX`__ (especially
+ `this summary of Lea's objections`__).
+
+ __ https://sourceforge.net/p/docutils/mailman/docutils-users/thread/40BAA4B7.5020801%40python.org/#msg6918066
+ __ https://sourceforge.net/p/docutils/mailman/message/6918089/
+
+Chris Liechti suggests a new ``:link:`` role in `more-universal
+links?`__::
+
+ .. role:: link(rewrite)
+ :transform: .txt|.html
+
+ and then to use it::
+
+ for more information see :link:`README.txt`
+
+ it would be useful if it supported an additional option
+ ``:format: html`` so that separate rules for each format can be
+ defined. (like the "raw" role)
+
+__ https://sourceforge.net/p/docutils/mailman/message/6919484/
+
+
+Idea from Jim Fulton: an external lookup table of targets:
+
+ I would like to specify the extension (e.g. .txt) [in the
+ source, rather than ``filename.*``], but tell the converter to
+ change references to the files anticipating that the files will
+ be converted too.
+
+ For example::
+
+ .. _Another Document: another.txt
+
+ rst2html.py --convert-links "another.txt bar.txt" foo.txt
+
+ That is, name the files for which extensions should be converted.
+
+ Note that I want to refer to original files in the original text
+ (another.txt rather than another.txt) because I want the
+ unconverted text to stand on its own.
+
+ Note that in most cases, people will be able to use globs::
+
+ rst2html.py --convert-link-extensions-for "`echo *.txt`" foo.txt
+
+ It might be nice to be able to use multiple arguments, as in::
+
+ rst2html.py --convert-link-extensions-for *.txt -- foo.txt
+
+ | > Handle documents only, or objects
+ | > (images, etc.) also?
+
+ No, documents only, but there really is no need for guesswork.
+ Just get the file names as command-line arguments. EIBTI
+ [explicit is better than implicit].
+
+In `Patch #169`__ `Hyperlink extension rewriting`, John L. Clark
+suggests command line options that map to-be-changed file extensions, e.g.::
+
+ rst2html --map-extension rst html --map-extension jpg png \
+ input-filename.rst
+
+__ https://sourceforge.net/p/docutils/patches/169/
+
+ Specifying the mapping as regular expressions would make this
+ approach more generic and easier to implement (use ``re.replace``
+ and refer to the "re" module's documentation instead of coding and
+ documenting a home-grown extraction and mapping procedure).
+
+
Math Markup
-----------
@@ -1719,8 +1781,8 @@
This could be an interface to the Filter transform
(docutils.transforms.components.Filter).
- The ideas in `adaptable file extensions`_ above may also be
- applicable here.
+ The ideas in the `adaptable file extensions`_ section above may
+ also be applicable here.
SVG's "switch" statement may provide inspiration.
@@ -2611,8 +2673,8 @@
* support more graphic formats (especially SVG, the only standard
vector format for HTML)
-
+
Missing features
----------------
@@ -2627,9 +2689,9 @@
See https://tex.stackexchange.com/questions/26529/how-can-i-generate-pdf-metadata-from-latex#26530
https://tex.stackexchange.com/questions/161094/adding-custom-metadata-values-to-a-pdf-file
-
-
+
+
* Multiple author entries in docinfo (same thing as in html).
* Consider supporting the "compact" option and class argument (from
@@ -2812,6 +2874,16 @@
* Create a single dynamic_ or unqualified_ front end that can be
installed?
+ The "new" `argparse` module supports `partial parsing`_, so a
+ generic front end may parse and remove additional options to select
+ the reader/parser/writer and leave the remaining arguments intact
+ for ``publish_cmdline()``.
+
+.. _partial parsing:
+ https://docs.python.org/3/library/argparse.html#partial-parsing
+
+.. _configuration: ../user/config.html
+
..
Local Variables:
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2020-12-01 09:38:02 UTC (rev 8582)
+++ trunk/docutils/docutils/frontend.py 2020-12-01 10:53:27 UTC (rev 8583)
@@ -20,8 +20,8 @@
`validate_encoding_error_handler`,
`validate_encoding_and_error_handler`,
`validate_boolean`, `validate_ternary`, `validate_threshold`,
- `validate_colon_separated_string_list`,
- `validate_comma_separated_string_list`,
+ `validate_colon_separated_list`,
+ `validate_comma_separated_list`,
`validate_dependency_file`.
* `make_paths_absolute`.
* SettingSpec manipulation: `filter_settings_spec`.
@@ -175,8 +175,8 @@
config_parser=None, config_section=None):
"""Check/normalize list arguments (split at "," and strip whitespace).
"""
- # `value` is already a ``list`` when given as command line option
- # and "action" is "append" and ``unicode`` or ``str`` else.
+ # `value` may be ``unicode``, ``str``, or a ``list`` (when given as
+ # command line option and "action" is "append").
if not isinstance(value, list):
value = [value]
# this function is called for every option added to `value`
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2020-12-01 09:38:02 UTC (rev 8582)
+++ trunk/docutils/docutils/nodes.py 2020-12-01 10:53:27 UTC (rev 8583)
@@ -1964,7 +1964,7 @@
for `docutils.writers.Writer` subclasses). Unimplemented methods will
raise exceptions.
- For sparse traversals, where only certain node types are of interest,
+ For sparse traversals, where only certain node types are of interest, use
subclass `SparseNodeVisitor` instead. When (mostly or entirely) uniform
processing is desired, subclass `GenericNodeVisitor`.
Modified: trunk/docutils/docutils/parsers/rst/directives/images.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/images.py 2020-12-01 09:38:02 UTC (rev 8582)
+++ trunk/docutils/docutils/parsers/rst/directives/images.py 2020-12-01 10:53:27 UTC (rev 8583)
@@ -53,9 +53,9 @@
'width': directives.length_or_percentage_or_unitless,
'scale': directives.percentage,
'align': align,
- 'name': directives.unchanged,
'target': directives.unchanged_required,
- 'class': directives.class_option}
+ 'class': directives.class_option,
+ 'name': directives.unchanged}
def run(self):
if 'align' in self.options:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-01 11:46:56
|
Revision: 8585
http://sourceforge.net/p/docutils/code/8585
Author: milde
Date: 2020-12-01 11:38:25 +0000 (Tue, 01 Dec 2020)
Log Message:
-----------
Add support for Markdown.
Provide a wrapper for the 3rd party `recommonmark`__ Markdown parser
already in use in Sphinx.
Add test cases for CommonMark parsing.
Also: Correct copyright note and set executable bit on two tests.
Fix small typo in test content.
__ https://pypi.org/project/recommonmark/
Modified Paths:
--------------
trunk/docutils/docutils/parsers/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test_parsers/test_rst/test_bullet_lists.py
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py
trunk/docutils/test/test_parsers/test_rst/test_transitions.py
Added Paths:
-----------
trunk/docutils/docutils/parsers/recommonmark_wrapper.py
trunk/docutils/test/test_parsers/test_recommonmark/
trunk/docutils/test/test_parsers/test_recommonmark/__init__.py
trunk/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
trunk/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py
trunk/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
trunk/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
trunk/docutils/test/test_parsers/test_recommonmark/test_line_length_limit.py
trunk/docutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py
trunk/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py
trunk/docutils/test/test_parsers/test_recommonmark/test_misc.py
trunk/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
trunk/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
trunk/docutils/test/test_parsers/test_recommonmark/test_targets.py
trunk/docutils/test/test_parsers/test_recommonmark/test_transitions.py
trunk/docutils/tools/md2html5.py
trunk/docutils/tools/md2pseudoxml.py
trunk/docutils/tools/md2xml.py
Property Changed:
----------------
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit.py
trunk/docutils/test/test_parsers/test_rst/test_line_length_limit_default.py
Modified: trunk/docutils/docutils/parsers/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/__init__.py 2020-12-01 10:53:38 UTC (rev 8584)
+++ trunk/docutils/docutils/parsers/__init__.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -11,11 +11,27 @@
import sys
from importlib import import_module
-from docutils import Component
+from docutils import Component, frontend
class Parser(Component):
+ settings_spec = (
+ 'Generic Parser Options',
+ None,
+ (('Disable the "raw" directives; replaced with a "warning" '
+ 'system message.',
+ ['--no-raw'],
+ {'action': 'store_false', 'default': 1, 'dest': 'raw_enabled',
+ 'validator': frontend.validate_boolean}),
+ ('Enable the "raw" directive. Enabled by default.',
+ ['--raw-enabled'],
+ {'action': 'store_true'}),
+ ('Maximal number of characters in an input line. Default 10 000.',
+ ['--line-length-limit'],
+ {'metavar': '<length>', 'type': 'int', 'default': 10000,
+ 'validator': frontend.validate_nonnegative_int}),
+ ))
component_type = 'parser'
config_section = 'parsers'
@@ -39,7 +55,10 @@
'restructuredtext': 'rst',
'rest': 'rst',
'restx': 'rst',
- 'rtxt': 'rst',}
+ 'rtxt': 'rst',
+ 'recommonmark': 'recommonmark_wrapper',
+ 'commonmark': 'recommonmark_wrapper',
+ 'markdown': 'recommonmark_wrapper'}
def get_parser_class(parser_name):
"""Return the Parser class from the `parser_name` module."""
Added: trunk/docutils/docutils/parsers/recommonmark_wrapper.py
===================================================================
--- trunk/docutils/docutils/parsers/recommonmark_wrapper.py (rev 0)
+++ trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -0,0 +1,118 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+"""
+A parser for CommonMark MarkDown text using `recommonmark`__.
+
+__ https://pypi.org/project/recommonmark/
+"""
+
+import docutils.parsers
+from docutils import nodes
+
+try:
+ from recommonmark.parser import CommonMarkParser as _recommonmarkParser
+ _recommonmarkParser.supported = ('recommonmark', 'commonmark',
+ 'markdown', 'md')
+ with_recommonmark = True
+except ImportError as err:
+ with_recommonmark = False
+ class _recommonmarkParser(docutils.parsers.Parser):
+ def parse(self, inputstring, document):
+ error = document.reporter.warning(
+ 'Missing dependency: MarkDown input is processed by a 3rd '
+ 'party parser but Python did not find the required module '
+ '"recommonmark" (https://pypi.org/project/recommonmark/).')
+ document.append(error)
+
+class Parser(_recommonmarkParser):
+ config_section = 'recommonmark parser'
+ config_section_dependencies = ('parsers',)
+
+ def parse(self, inputstring, document):
+ """Use the upstream parser and clean up afterwards.
+ """
+ # check for exorbitantly long lines
+ for i, line in enumerate(inputstring.split('\n')):
+ if len(line) > document.settings.line_length_limit:
+ error = document.reporter.error(
+ 'Line %d exceeds the line-length-limit.'%(i+1))
+ document.append(error)
+ return
+
+ # pass to upstream parser
+ try:
+ _recommonmarkParser.parse(self, inputstring, document)
+ except Exception as err:
+ error = document.reporter.error('Parsing with "recommonmark" '
+ 'returned the error:\n%s'%err)
+ document.append(error)
+
+ # Post-Processing
+ # ---------------
+
+ # remove spurious empty lines
+ for node in document.traverse(nodes.TextElement):
+ node.children = [child for child in node.children
+ if not (isinstance(child, nodes.Text)
+ and str(child) == '\n')]
+
+ # add "code" class argument to inline literal (code spans)
+ for node in document.traverse(lambda n: isinstance(n,
+ (nodes.literal, nodes.literal_block))):
+ node['classes'].append('code')
+ # move "language" argument to classes
+ for node in document.traverse(nodes.literal_block):
+ if 'language' in node.attributes:
+ node['classes'].append(node['language'])
+ del node['language']
+
+ # remove empty target nodes
+ for node in document.traverse(nodes.target):
+ # remove empty name
+ node['names'] = [v for v in node['names'] if v]
+ if node.children or [v for v in node.attributes.values() if v]:
+ continue
+ node.parent.remove(node)
+
+ # replace raw nodes if raw is not allowed
+ if not document.settings.raw_enabled:
+ for node in document.traverse(nodes.raw):
+ warning = document.reporter.warning('Raw content disabled.')
+ node.parent.replace(node, warning)
+
+ # fix section nodes
+ for node in document.traverse(nodes.section):
+ # remove spurious IDs (first may be from duplicate name)
+ if len(node['ids']) > 1:
+ node['ids'].pop()
+ # fix section levels
+ section_level = self.get_section_level(node)
+ if node['level'] != section_level:
+ warning = document.reporter.warning(
+ 'Title level inconsistent. Changing from %d to %d.'
+ %(node['level'], section_level),
+ nodes.literal_block('', node[0].astext()))
+ node.insert(1, warning)
+ # remove non-standard attribute "level"
+ del node['level'] # TODO: store the original md level somewhere
+
+ def get_section_level(self, node):
+ level = 1
+ while True:
+ node = node.parent
+ if isinstance(node, nodes.document):
+ return level
+ if isinstance(node, nodes.section):
+ level += 1
Property changes on: trunk/docutils/docutils/parsers/recommonmark_wrapper.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2020-12-01 10:53:38 UTC (rev 8584)
+++ trunk/docutils/test/DocutilsTestSupport.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -47,6 +47,7 @@
import re
import inspect
import traceback
+import warnings
from pprint import pformat
testroot = os.path.abspath(os.path.dirname(__file__) or os.curdir)
@@ -63,7 +64,7 @@
from docutils import frontend, nodes, statemachine, utils
from docutils.utils import urischemes
from docutils.transforms import universal
- from docutils.parsers import rst
+ from docutils.parsers import rst, recommonmark_wrapper
from docutils.parsers.rst import states, tableparser, roles, languages
from docutils.readers import standalone, pep
from docutils.statemachine import StringList, string2lines
@@ -82,7 +83,6 @@
except:
import pdb
-
if sys.version_info >= (3, 0):
unicode = str # noqa
@@ -518,6 +518,38 @@
test_case_class = PEPParserTestCase
+class RecommonmarkParserTestCase(ParserTestCase):
+
+ """Recommonmark-specific parser test case."""
+
+ parser = recommonmark_wrapper.Parser()
+ """Parser shared by all RecommonmarkParserTestCases."""
+
+ option_parser = frontend.OptionParser(
+ components=(recommonmark_wrapper.Parser,))
+ settings = option_parser.get_default_values()
+ settings.report_level = 5
+ settings.halt_level = 5
+ settings.debug = package_unittest.debug
+
+class RecommonmarkParserTestSuite(ParserTestSuite):
+
+ """A collection of RecommonmarkParserTestCases."""
+
+ test_case_class = RecommonmarkParserTestCase
+ skip_message = 'skip "%s" (module `recommonmark` not found)'
+
+ def generateTests(self, dict, dictname='totest'):
+ if 'recommonmark' not in recommonmark_wrapper.Parser.supported:
+ if RecommonmarkParserTestSuite.skip_message: # warn (only once)
+ print(self.skip_message%self.id)
+ RecommonmarkParserTestSuite.skip_message = ''
+ return
+ # suppress UserWarnings from recommonmark parser
+ warnings.filterwarnings('ignore', message='Unsupported.*type')
+ ParserTestSuite.generateTests(self, dict, dictname='totest')
+
+
class GridTableParserTestCase(CustomTestCase):
parser = tableparser.GridTableParser()
@@ -756,7 +788,7 @@
class HtmlPublishPartsTestSuite(CustomTestSuite):
testcase_class = HtmlWriterPublishPartsTestCase
-
+
def generateTests(self, dict, dictname='totest'):
for name, (settings_overrides, cases) in dict.items():
settings = self.suite_settings.copy()
Added: trunk/docutils/test/test_parsers/test_recommonmark/__init__.py
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/__init__.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_recommonmark/__init__.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -0,0 +1,15 @@
+import os
+import os.path
+import sys
+import unittest
+
+sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
+prev = ''
+while sys.path[0] != prev:
+ try:
+ import DocutilsTestSupport
+ break
+ except ImportError:
+ prev = sys.path[0]
+ sys.path[0] = os.path.dirname(prev)
+sys.path.pop(0)
Property changes on: trunk/docutils/test/test_parsers/test_recommonmark/__init__.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+# -*- coding: utf8 -*-
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+
+"""
+Test for block quotes in CommonMark parsers
+Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
+"""
+
+from __future__ import absolute_import
+
+if __name__ == '__main__':
+ import __init__
+from test_parsers import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.RecommonmarkParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['block_quotes'] = [
+["""\
+> block quote
+> line 2
+""",
+"""\
+<document source="test data">
+ <block_quote>
+ <paragraph>
+ block quote
+ line 2
+"""],
+["""\
+Line 1.
+
+ > Indented block quote.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ <block_quote>
+ <paragraph>
+ Indented block quote.
+"""],
+["""\
+Line 1.
+Line 2.
+> Block quote, without blank line before.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ Line 2.
+ <block_quote>
+ <paragraph>
+ Block quote, without blank line before.
+"""],
+["""\
+Line 1.
+Line 2.
+
+>Block quote,
+continuation line
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ Line 2.
+ <block_quote>
+ <paragraph>
+ Block quote,
+ continuation line
+"""],
+["""\
+Here is a paragraph.
+
+> > Nested
+>
+> block quotes.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here is a paragraph.
+ <block_quote>
+ <block_quote>
+ <paragraph>
+ Nested
+ <paragraph>
+ block quotes.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Copied: trunk/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py (from rev 8584, trunk/docutils/test/test_parsers/test_rst/test_bullet_lists.py)
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -0,0 +1,200 @@
+#!/usr/bin/env python3
+# -*- coding: utf8 -*-
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+
+"""
+Test for bullet lists in CommonMark parsers.
+Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
+"""
+
+from __future__ import absolute_import
+
+if __name__ == '__main__':
+ import __init__
+from test_parsers import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.RecommonmarkParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['bullet_lists'] = [
+["""\
+- item
+""",
+"""\
+<document source="test data">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item
+"""],
+["""\
+* item 1
+
+* item 2
+""",
+"""\
+<document source="test data">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item 1
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+No blank line between:
+
++ item 1
++ item 2
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ No blank line between:
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item 1
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+- item 1, paragraph 1.
+
+ item 1, paragraph 2.
+
+- item 2
+""",
+"""\
+<document source="test data">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item 1, paragraph 1.
+ <paragraph>
+ item 1, paragraph 2.
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+- item 1, line 1
+ item 1, line 2
+- item 2
+""",
+"""\
+<document source="test data">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item 1, line 1
+ item 1, line 2
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+Different bullets start different lists:
+
+- item 1
+
++ item 1
+
+* no blank line
+- required between lists
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Different bullets start different lists:
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item 1
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item 1
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ no blank line
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ required between lists
+"""],
+["""\
+- item 1
+continuation of item 1
+""",
+"""\
+<document source="test data">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ item 1
+ continuation of item 1
+"""],
+["""\
+-
+
+empty item above
+""",
+"""\
+<document source="test data">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ empty item above
+"""],
+["""\
+-
+empty item above, no blank line
+""",
+"""\
+<document source="test data">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ empty item above, no blank line
+"""],
+[u"""\
+Unicode bullets are not supported by CommonMark.
+
+• BULLET
+
+‣ TRIANGULAR BULLET
+
+⁃ HYPHEN BULLET
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Unicode bullets are not supported by CommonMark.
+ <paragraph>
+ • BULLET
+ <paragraph>
+ ‣ TRIANGULAR BULLET
+ <paragraph>
+ ⁃ HYPHEN BULLET
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Added: trunk/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -0,0 +1,385 @@
+#!/usr/bin/env python3
+# -*- coding: utf8 -*-
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+"""
+Test for enumerated lists in CommonMark parsers
+Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
+"""
+from __future__ import absolute_import
+
+if __name__ == '__main__':
+ import __init__
+from test_parsers import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.RecommonmarkParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['enumerated_lists'] = [
+["""\
+1. Item one.
+
+2. Item two.
+
+3. Item three.
+""",
+"""\
+<document source="test data">
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+No blank lines betwen items:
+
+1. Item one.
+2. Item two.
+3. Item three.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ No blank lines betwen items:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+1.
+ Content may start at the next line
+ if it's indented at least 3 spaces.
+""",
+"""\
+<document source="test data">
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Content may start at the next line
+ if it's indented at least 3 spaces.
+"""],
+["""\
+1.
+empty item above, no blank line, no indent
+""",
+"""\
+<document source="test data">
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ empty item above, no blank line, no indent
+"""],
+["""\
+Items are auto-numbered.
+No check for consistency: Skipping item 3
+
+1. Item 1.
+2. Item 2.
+4. Item 4.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Items are auto-numbered.
+ No check for consistency: Skipping item 3
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item 1.
+ <list_item>
+ <paragraph>
+ Item 2.
+ <list_item>
+ <paragraph>
+ Item 4.
+"""],
+["""\
+No warning when starting with non-ordinal-1:
+
+0. Item zero.
+1. Item one.
+2. Item two.
+3. Item three.
+
+And again:
+
+2. Item two.
+3. Item three.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ No warning when starting with non-ordinal-1:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item zero.
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+ <paragraph>
+ And again:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+1. Item one: line 1,
+ line 2.
+2. Item two: line 1,
+line 2.
+3. Item three: paragraph 1, line 1,
+ line 2.
+
+ Paragraph 2.
+""",
+"""\
+<document source="test data">
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item one: line 1,
+ line 2.
+ <list_item>
+ <paragraph>
+ Item two: line 1,
+ line 2.
+ <list_item>
+ <paragraph>
+ Item three: paragraph 1, line 1,
+ line 2.
+ <paragraph>
+ Paragraph 2.
+"""],
+["""\
+Supported enumeration sequences:
+
+1. Item 1.
+2. Item 2.
+
+1) Item 1)
+2) Item 2)
+
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Supported enumeration sequences:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item 1.
+ <list_item>
+ <paragraph>
+ Item 2.
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item 1)
+ <list_item>
+ <paragraph>
+ Item 2)
+"""],
+["""\
+Nested enumerated lists:
+
+1. Item 1
+
+ 1) Item 1.1
+ 2) Item 1.2
+ 3) Item 1.3
+
+2. Item 2
+
+ 1. Item 2.1
+
+ 1) Item 2.1.1
+ 2) Item 2.1.2
+ 3) Item 2.1.3
+
+ 2. Item 2.2
+
+ 3. Item 2.3
+
+3. Item 3.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Nested enumerated lists:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item 1
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item 1.1
+ <list_item>
+ <paragraph>
+ Item 1.2
+ <list_item>
+ <paragraph>
+ Item 1.3
+ <list_item>
+ <paragraph>
+ Item 2
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item 2.1
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item 2.1.1
+ <list_item>
+ <paragraph>
+ Item 2.1.2
+ <list_item>
+ <paragraph>
+ Item 2.1.3
+ <list_item>
+ <paragraph>
+ Item 2.2
+ <list_item>
+ <paragraph>
+ Item 2.3
+ <list_item>
+ <paragraph>
+ Item 3.
+"""],
+["""\
+1. Item one: line 1,
+ line 2.
+2. Item two: line 1,
+ line 2.
+3. Item three: paragraph 1, line 1,
+line 2.
+
+ Item three: paragraph 2.
+""",
+"""\
+<document source="test data">
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ Item one: line 1,
+ line 2.
+ <list_item>
+ <paragraph>
+ Item two: line 1,
+ line 2.
+ <list_item>
+ <paragraph>
+ Item three: paragraph 1, line 1,
+ line 2.
+ <paragraph>
+ Item three: paragraph 2.
+"""],
+["""\
+3-space indent, with a trailing space:
+
+1. \n\
+ list item 1
+
+3-space indent, no trailing space:
+
+1.
+ list item 1
+
+2-space indent, empty list item:
+
+1.
+ foo
+
+1-space indent, empty list item:
+
+1.
+ foo
+
+0-space indent, empty list item:
+
+1.
+foo
+
+No item content:
+
+1.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ 3-space indent, with a trailing space:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ list item 1
+ <paragraph>
+ 3-space indent, no trailing space:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ list item 1
+ <paragraph>
+ 2-space indent, empty list item:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ foo
+ <paragraph>
+ 1-space indent, empty list item:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ foo
+ <paragraph>
+ 0-space indent, empty list item:
+ <enumerated_list>
+ <list_item>
+ <paragraph>
+ foo
+ <paragraph>
+ No item content:
+ <enumerated_list>
+ <list_item>
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
Property changes on: trunk/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py 2020-12-01 11:38:25 UTC (rev 8585)
@@ -0,0 +1,92 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+# $Id$
+# :Copyright: © 2020 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any...
[truncated message content] |
|
From: <mi...@us...> - 2020-12-02 17:35:02
|
Revision: 8586
http://sourceforge.net/p/docutils/code/8586
Author: milde
Date: 2020-12-02 17:34:59 +0000 (Wed, 02 Dec 2020)
Log Message:
-----------
New generic front end
Allows the selection of reader, parser, and writer components
from the command line.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/dev/todo.txt
Added Paths:
-----------
trunk/docutils/tools/docutils-frontend.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-12-01 11:38:25 UTC (rev 8585)
+++ trunk/docutils/HISTORY.txt 2020-12-02 17:34:59 UTC (rev 8586)
@@ -25,8 +25,10 @@
- Installing with ``setup.py`` now requires ``setuptools``.
Alternatively, install with `pip`_ (or "manually").
- Apply patch for bug #399 Fixes in Korean translation.
- - Implement feature request #40 `Option to embed images as data URI`.
+
+ .. _pip: https://pypi.org/project/pip/
+
* docutils/MANIFEST.in
- Exclude test outputs.
@@ -41,7 +43,14 @@
(by Takeshi KOMIYA).
- Apply version of patch #167: Let document.set_id() register all
existing IDs (thanks to Takeshi KOMIYA).
+
+* docutils/parsers/recommonmark_wrapper.py
+ - New file. An experimental wrapper to integrate the
+ `recommonmark`__ Markdown parser for use with stock Docutils.
+
+ __ https://pypi.org/project/recommonmark/
+
* docutils/parsers/rst/directives/body.py
- Make the sidebar's "title" argument optional (feature request #69).
@@ -58,6 +67,10 @@
- Fix bug #383: Smart quotes around opening and separator characters.
+* docutils/writers/html*
+
+ - Implement feature request #40 `Option to embed images as data URI`.
+
* docutils/writers/html5_polyglot/
- Use the new semantic tags <main>, <section>, <header>,
@@ -132,9 +145,12 @@
- Run python3 test like python2 against source not the build/-directory
-.. _pip: https://pypi.org/project/pip/
+* tools/docutils_frontend.py
+ - New generic front end that allows the selection of reader, parser,
+ and writer components from the command line.
+
Release 0.16
============
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2020-12-01 11:38:25 UTC (rev 8585)
+++ trunk/docutils/docs/dev/todo.txt 2020-12-02 17:34:59 UTC (rev 8586)
@@ -2849,11 +2849,8 @@
d) _`Dynamic`: Reader and/or Writer are specified by options, with
defaults if unspecified (e.g. ``publish --writer pdf
- [options]``). Is this possible? The option parser would have
- to be told about new options it needs to handle, on the fly.
- Component-specific options would have to be specified *after*
- the component-specifying option.
-
+ [options]``).
+
Allow common options before subcommands, as in CVS? Or group all
options together? In the case of the `fully qualified`_
front ends, all the options will have to be grouped together
@@ -2871,14 +2868,11 @@
directive should override the ``--no-section-numbering`` command
line option then.
-* Create a single dynamic_ or unqualified_ front end that can be
- installed?
+The dynamic_ front end ``tools/docutils-frontend.py`` (new in 0.17) is an
+implementation of concept c). It uses 2-stage argument parsing
+via the "new" `argparse` module supports `partial parsing`_.
+It still needs some polishing and a better name.
- The "new" `argparse` module supports `partial parsing`_, so a
- generic front end may parse and remove additional options to select
- the reader/parser/writer and leave the remaining arguments intact
- for ``publish_cmdline()``.
-
.. _partial parsing:
https://docs.python.org/3/library/argparse.html#partial-parsing
Added: trunk/docutils/tools/docutils-frontend.py
===================================================================
--- trunk/docutils/tools/docutils-frontend.py (rev 0)
+++ trunk/docutils/tools/docutils-frontend.py 2020-12-02 17:34:59 UTC (rev 8586)
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+# :Copyright: © 2015 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+
+"""
+A generic front end to the Docutils Publisher.
+"""
+
+try:
+ import locale # module missing in Jython
+ locale.setlocale(locale.LC_ALL, '')
+except locale.Error:
+ pass
+
+import argparse
+import sys
+
+from docutils.core import publish_cmdline, default_description
+
+description = (u'Generate documents from reStructuredText sources.'
+ )
+epilog = (u'Currently, the component selection cannot be specified in the '
+ u'configuration file. '
+ u'The availability of some options depends on the selected '
+ u'components, the list below adapts to your selection.'
+ )
+
+parser = argparse.ArgumentParser(add_help=False, description=description,
+ epilog=epilog)
+
+parser.add_argument('--reader', choices=('standalone', 'pep'),
+ help=u'Reader name (default "standalone").',
+ default='standalone')
+parser.add_argument('--parser', choices=('markdown', 'rst'),
+ help=u'Parser name (default "rst").',
+ default='rst')
+parser.add_argument('--writer',
+ # choices=('html', 'html4', 'html5', 'latex', 'xelatex',
+ # 'odt', 'xml', 'pseudoxml', 'manpage',
+ # 'pep_html', 's5_html'),
+ help=u'Writer name (default "pseudoxml").',
+ default='pseudoxml')
+
+(args, remainder) = parser.parse_known_args()
+
+
+if '-h' in sys.argv or '--help' in sys.argv:
+ print(parser.format_help())
+ print('')
+
+
+publish_cmdline(reader_name=args.reader,
+ parser_name=args.parser,
+ writer_name=args.writer,
+ description=default_description,
+ argv=remainder)
Property changes on: trunk/docutils/tools/docutils-frontend.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-09 15:52:19
|
Revision: 8589
http://sourceforge.net/p/docutils/code/8589
Author: milde
Date: 2020-12-09 15:52:16 +0000 (Wed, 09 Dec 2020)
Log Message:
-----------
Fix bug #410 The 'document' attribute is None for many nodes.
Use a "property" function to recursively fetch the
`Node.document` value from the parent node.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-12-09 15:34:10 UTC (rev 8588)
+++ trunk/docutils/HISTORY.txt 2020-12-09 15:52:16 UTC (rev 8589)
@@ -25,7 +25,7 @@
- Installing with ``setup.py`` now requires ``setuptools``.
Alternatively, install with `pip`_ (or "manually").
- Apply patch for bug #399 Fixes in Korean translation.
-
+
.. _pip: https://pypi.org/project/pip/
@@ -43,13 +43,15 @@
(by Takeshi KOMIYA).
- Apply version of patch #167: Let document.set_id() register all
existing IDs (thanks to Takeshi KOMIYA).
-
+ - Fix bug #410: Use a "property" function to recursively fetch
+ `Node.document` value from parent node.
+
* docutils/parsers/recommonmark_wrapper.py
- New file. An experimental wrapper to integrate the
`recommonmark`__ Markdown parser for use with stock Docutils.
- __ https://pypi.org/project/recommonmark/
+ __ https://pypi.org/project/recommonmark/
* docutils/parsers/rst/directives/body.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2020-12-09 15:34:10 UTC (rev 8588)
+++ trunk/docutils/docutils/nodes.py 2020-12-09 15:52:16 UTC (rev 8589)
@@ -73,9 +73,6 @@
parent = None
"""Back-reference to the Node immediately containing this Node."""
- document = None
- """The `document` node at the root of the tree containing this Node."""
-
source = None
"""Path or description of the input source which generated this Node."""
@@ -82,6 +79,22 @@
line = None
"""The line number (1-based) of the beginning of this Node in `source`."""
+ _document = None
+
+ @property
+ def document(self):
+ """
+ Return the `document` node at the root of the tree containing this Node.
+ """
+ try:
+ return self._document or self.parent.document
+ except AttributeError:
+ return None
+
+ @document.setter
+ def document(self, value):
+ self._document = value
+
def __bool__(self):
"""
Node instances are always true, even if they're empty. A node is more
@@ -1062,7 +1075,7 @@
def copy(self):
obj = self.__class__(rawsource=self.rawsource, **self.attributes)
- obj.document = self.document
+ obj._document = self._document
obj.source = self.source
obj.line = self.line
return obj
@@ -1344,7 +1357,7 @@
self.decoration = None
"""Document's `decoration` node."""
- self.document = self
+ self._document = self
def __getstate__(self):
"""
@@ -1864,7 +1877,7 @@
def copy(self):
obj = self.__class__(self.transform, self.details, self.rawsource,
**self.attributes)
- obj.document = self.document
+ obj._document = self._document
obj.source = self.source
obj.line = self.line
return obj
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-14 22:44:32
|
Revision: 8590
http://sourceforge.net/p/docutils/code/8590
Author: milde
Date: 2020-12-14 22:44:30 +0000 (Mon, 14 Dec 2020)
Log Message:
-----------
Fix LaTeX code for system messages.
System messages are admonitions, don't use
"alltt" inside them with "legacy class functions".
Thanks to Jerome Carretero for the report.
Fix spurious vspace after DUTitle (move hypertarget code inside).
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/latex2e/docutils.sty
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2020-12-09 15:52:16 UTC (rev 8589)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2020-12-14 22:44:30 UTC (rev 8590)
@@ -2470,7 +2470,7 @@
# Check parent node instead?
_autowidth_table = _in_table and self.active_table.colwidths_auto
_use_env = _plaintext and not isinstance(node.parent,
- (nodes.footnote, nodes.admonition))
+ (nodes.footnote, nodes.admonition, nodes.system_message))
_use_listings = (literal_env == 'lstlisting') and _use_env
# Labels and classes:
@@ -2862,13 +2862,16 @@
self.fallbacks['title'] = PreambleCmds.title_legacy
node['classes'] = ['system-message']
self.visit_admonition(node)
- self.out.append('\n\\DUtitle[system-message]{system-message}\n')
+ if self.settings.legacy_class_functions:
+ self.out.append('\n\\DUtitle[system-message]{system-message\n')
+ else:
+ self.out.append('\n\\DUtitle{system-message\n')
self.append_hypertargets(node)
try:
line = ', line~%s' % node['line']
except KeyError:
line = ''
- self.out.append('\n\n{\\color{red}%s/%s} in \\texttt{%s}%s\n' %
+ self.out.append('}\n\n{\\color{red}%s/%s} in \\texttt{%s}%s\n' %
(node['type'], node['level'],
self.encode(node['source']), line))
if len(node['backrefs']) == 1:
Modified: trunk/docutils/docutils/writers/latex2e/docutils.sty
===================================================================
--- trunk/docutils/docutils/writers/latex2e/docutils.sty 2020-12-09 15:52:16 UTC (rev 8589)
+++ trunk/docutils/docutils/writers/latex2e/docutils.sty 2020-12-14 22:44:30 UTC (rev 8590)
@@ -8,7 +8,7 @@
%% notice and this notice are preserved.
%% This file is offered as-is, without any warranty.
-% .. include:: README
+% .. include:: README.md
%
% Implementation
% ==============
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2020-12-09 15:52:16 UTC (rev 8589)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2020-12-14 22:44:30 UTC (rev 8590)
@@ -2863,8 +2863,8 @@
}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-1}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-1}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~104
@@ -2873,8 +2873,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-2}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-2}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~392
@@ -2883,8 +2883,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-3}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-3}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~401
@@ -2893,8 +2893,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-4}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-4}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~428
@@ -2903,8 +2903,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-5}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-5}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~441
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-12-09 15:52:16 UTC (rev 8589)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2020-12-14 22:44:30 UTC (rev 8590)
@@ -2867,8 +2867,8 @@
}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-1}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-1}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~104
@@ -2877,8 +2877,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-2}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-2}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~392
@@ -2887,8 +2887,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-3}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-3}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~401
@@ -2897,8 +2897,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-4}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-4}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~428
@@ -2907,8 +2907,8 @@
}}
\DUadmonition[system-message]{
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-5}{}}
+\DUtitle[system-message]{system-message
+\raisebox{1em}{\hypertarget{system-message-5}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~441
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-12-09 15:52:16 UTC (rev 8589)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2020-12-14 22:44:30 UTC (rev 8590)
@@ -2770,8 +2770,8 @@
\begin{DUclass}{system-message}
\begin{DUadmonition}
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-1}{}}
+\DUtitle{system-message
+\raisebox{1em}{\hypertarget{system-message-1}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~104
@@ -2782,8 +2782,8 @@
\begin{DUclass}{system-message}
\begin{DUadmonition}
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-2}{}}
+\DUtitle{system-message
+\raisebox{1em}{\hypertarget{system-message-2}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~392
@@ -2794,8 +2794,8 @@
\begin{DUclass}{system-message}
\begin{DUadmonition}
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-3}{}}
+\DUtitle{system-message
+\raisebox{1em}{\hypertarget{system-message-3}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~401
@@ -2806,8 +2806,8 @@
\begin{DUclass}{system-message}
\begin{DUadmonition}
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-4}{}}
+\DUtitle{system-message
+\raisebox{1em}{\hypertarget{system-message-4}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~428
@@ -2818,8 +2818,8 @@
\begin{DUclass}{system-message}
\begin{DUadmonition}
-\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{system-message-5}{}}
+\DUtitle{system-message
+\raisebox{1em}{\hypertarget{system-message-5}{}}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~441
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-15 23:06:19
|
Revision: 8591
http://sourceforge.net/p/docutils/code/8591
Author: milde
Date: 2020-12-15 23:06:16 +0000 (Tue, 15 Dec 2020)
Log Message:
-----------
Rename the generic command line frontend to "docutils-cli.py"
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
Added Paths:
-----------
trunk/docutils/tools/docutils-cli.py
Removed Paths:
-------------
trunk/docutils/tools/docutils-frontend.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-12-14 22:44:30 UTC (rev 8590)
+++ trunk/docutils/HISTORY.txt 2020-12-15 23:06:16 UTC (rev 8591)
@@ -147,10 +147,10 @@
- Run python3 test like python2 against source not the build/-directory
-* tools/docutils_frontend.py
+* tools/docutils_cli.py
- - New generic front end that allows the selection of reader, parser,
- and writer components from the command line.
+ - New generic command line front end that allows the free selection of
+ reader, parser, and writer components.
Release 0.16
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2020-12-14 22:44:30 UTC (rev 8590)
+++ trunk/docutils/RELEASE-NOTES.txt 2020-12-15 23:06:16 UTC (rev 8591)
@@ -27,7 +27,7 @@
* `html5` writer:
Use <blockquote> instead of <div> tags for topics and admonitions.
-
+
Use <summary> and <details> tags for term and definition of a
definition list with class value "details".
@@ -78,7 +78,10 @@
* Installing with ``setup.py`` now requires setuptools_.
Alternatively, install with pip_.
-
+
+* The generic command line front end ``docutils-cli.py`` allows the
+ free selection of reader, parser, and writer components.
+
* HTML writers: new option to embed images.
* HTML5 writer:
@@ -89,7 +92,7 @@
Change the `initial_header_level`_ setting's default to "2", as browsers
use the `same style for <h1> and <h2> when nested in a section`__.
-
+
- Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
<i>, <b>, <u>, <mark>, and <bdi> if a matching class value
is found in `inline` and `literal` elements.
@@ -118,9 +121,9 @@
- Most helper commands and element definitions are now defined in the
LaTeX package `docutils.sty`_ and only inserted in the document
preamble if the stylesheet__ setting does not lists "docutils".
-
+
__ docs/user/config.html#stylesheet-latex-writers
-
+
.. _setuptools: https://pypi.org/project/setuptools/
.. _pip: https://pypi.org/project/pip/
.. _legacy_class_functions: docs/user/config.html#legacy-class-functions
Copied: trunk/docutils/tools/docutils-cli.py (from rev 8590, trunk/docutils/tools/docutils-frontend.py)
===================================================================
--- trunk/docutils/tools/docutils-cli.py (rev 0)
+++ trunk/docutils/tools/docutils-cli.py 2020-12-15 23:06:16 UTC (rev 8591)
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+# :Copyright: © 2015 Günter Milde.
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+#
+# Revision: $Revision$
+# Date: $Date$
+
+"""
+A generic front end to the Docutils Publisher.
+"""
+
+try:
+ import locale # module missing in Jython
+ locale.setlocale(locale.LC_ALL, '')
+except locale.Error:
+ pass
+
+import argparse
+import sys
+
+from docutils.core import publish_cmdline, default_description
+
+description = (u'Generate documents from reStructuredText sources.'
+ )
+epilog = (u'Currently, the component selection cannot be specified in the '
+ u'configuration file. '
+ u'The availability of some options depends on the selected '
+ u'components, the list below adapts to your selection.'
+ )
+
+parser = argparse.ArgumentParser(add_help=False, description=description,
+ epilog=epilog)
+
+parser.add_argument('--reader', choices=('standalone', 'pep'),
+ help=u'Reader name (default "standalone").',
+ default='standalone')
+parser.add_argument('--parser', choices=('markdown', 'rst'),
+ help=u'Parser name (default "rst").',
+ default='rst')
+parser.add_argument('--writer',
+ # choices=('html', 'html4', 'html5', 'latex', 'xelatex',
+ # 'odt', 'xml', 'pseudoxml', 'manpage',
+ # 'pep_html', 's5_html'),
+ help=u'Writer name (default "pseudoxml").',
+ default='pseudoxml')
+
+(args, remainder) = parser.parse_known_args()
+
+
+if '-h' in sys.argv or '--help' in sys.argv:
+ print(parser.format_help())
+ print('')
+
+
+publish_cmdline(reader_name=args.reader,
+ parser_name=args.parser,
+ writer_name=args.writer,
+ description=default_description,
+ argv=remainder)
Deleted: trunk/docutils/tools/docutils-frontend.py
===================================================================
--- trunk/docutils/tools/docutils-frontend.py 2020-12-14 22:44:30 UTC (rev 8590)
+++ trunk/docutils/tools/docutils-frontend.py 2020-12-15 23:06:16 UTC (rev 8591)
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# :Copyright: © 2015 Günter Milde.
-# :License: Released under the terms of the `2-Clause BSD license`_, in short:
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-# This file is offered as-is, without any warranty.
-#
-# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
-#
-# Revision: $Revision$
-# Date: $Date$
-
-"""
-A generic front end to the Docutils Publisher.
-"""
-
-try:
- import locale # module missing in Jython
- locale.setlocale(locale.LC_ALL, '')
-except locale.Error:
- pass
-
-import argparse
-import sys
-
-from docutils.core import publish_cmdline, default_description
-
-description = (u'Generate documents from reStructuredText sources.'
- )
-epilog = (u'Currently, the component selection cannot be specified in the '
- u'configuration file. '
- u'The availability of some options depends on the selected '
- u'components, the list below adapts to your selection.'
- )
-
-parser = argparse.ArgumentParser(add_help=False, description=description,
- epilog=epilog)
-
-parser.add_argument('--reader', choices=('standalone', 'pep'),
- help=u'Reader name (default "standalone").',
- default='standalone')
-parser.add_argument('--parser', choices=('markdown', 'rst'),
- help=u'Parser name (default "rst").',
- default='rst')
-parser.add_argument('--writer',
- # choices=('html', 'html4', 'html5', 'latex', 'xelatex',
- # 'odt', 'xml', 'pseudoxml', 'manpage',
- # 'pep_html', 's5_html'),
- help=u'Writer name (default "pseudoxml").',
- default='pseudoxml')
-
-(args, remainder) = parser.parse_known_args()
-
-
-if '-h' in sys.argv or '--help' in sys.argv:
- print(parser.format_help())
- print('')
-
-
-publish_cmdline(reader_name=args.reader,
- parser_name=args.parser,
- writer_name=args.writer,
- description=default_description,
- argv=remainder)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-15 23:06:41
|
Revision: 8592
http://sourceforge.net/p/docutils/code/8592
Author: milde
Date: 2020-12-15 23:06:26 +0000 (Tue, 15 Dec 2020)
Log Message:
-----------
New option "detailled" for the `pseudoxml` writer.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/writers/pseudoxml.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-12-15 23:06:16 UTC (rev 8591)
+++ trunk/docutils/HISTORY.txt 2020-12-15 23:06:26 UTC (rev 8592)
@@ -143,6 +143,12 @@
- Fix #126 manpage title with spaces.
- Fix #380 commandline option problem in sphinx.
+* docutils/writers/pseudoxml.py:
+
+ - New option `detailled`__.
+
+ __ docs/user/config.html#detailled
+
* test/DocutilsTestSupport.py
- Run python3 test like python2 against source not the build/-directory
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2020-12-15 23:06:16 UTC (rev 8591)
+++ trunk/docutils/docs/user/config.txt 2020-12-15 23:06:26 UTC (rev 8592)
@@ -831,7 +831,7 @@
Enable or disable the promotion of the title of a lone subsection
to a subtitle (docutils.transforms.frontmatter.SectSubTitle).
-Default: disabled (0). Options: ``--section-subtitles,
+Default: disabled (False). Options: ``--section-subtitles,
--no-section-subtitles``.
@@ -869,7 +869,7 @@
Generate XML with a DOCTYPE declaration.
-Default: do (1). Options: ``--no-doctype``.
+Default: do (True). Options: ``--no-doctype``.
indents
~~~~~~~
@@ -894,7 +894,7 @@
Generate XML with an XML declaration.
See also `xml_declaration [html writers]`_.
-Default: do (1). Options: ``--no-xml-declaration``.
+Default: do (True). Options: ``--no-xml-declaration``.
[html writers]
@@ -1234,7 +1234,7 @@
encoding is not UTF-8 or ASCII and the XML declaration is missing,
standard tools may be unable to read the generated XHTML.
-Default: do (1). Options: ``--no-xml-declaration``.
+Default: do (True). Options: ``--no-xml-declaration``.
@@ -1370,7 +1370,7 @@
Auto-hide the presentation controls in slideshow mode, or or keep
them visible at all times.
-Default: auto-hide (1). Options: ``--hidden-controls``,
+Default: auto-hide (True). Options: ``--hidden-controls``,
``--visible-controls``.
current_slide
@@ -1978,9 +1978,14 @@
[pseudoxml writer]
------------------
-This writer does not define specific settings.
+detailled
+~~~~~~~~~
+Pretty-print <#text> nodes.
+Default: False. Options: ``--detailled``.
+
+
[applications]
==============
@@ -2012,7 +2017,7 @@
configuration files or on the command line); on the command line, the
option may also be used more than once.
-Default: none. Options: ``--ignore``.
+Default: None. Options: ``--ignore``.
prune
~~~~~
@@ -2030,7 +2035,7 @@
Recursively scan subdirectories, or ignore subdirectories.
-Default: recurse (1). Options: ``--recurse, --local``.
+Default: recurse (True). Options: ``--recurse, --local``.
silent
~~~~~~
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2020-12-15 23:06:16 UTC (rev 8591)
+++ trunk/docutils/docutils/nodes.py 2020-12-15 23:06:26 UTC (rev 8592)
@@ -455,6 +455,14 @@
return self.copy()
def pformat(self, indent=' ', level=0):
+ try:
+ if self.document.settings.detailled:
+ lines = ['%s%s' % (indent * level, '<#text>')
+ ] + [indent*(level+1) + repr(line)
+ for line in self.splitlines(keepends=True)]
+ return '\n'.join(lines) + '\n'
+ except AttributeError:
+ pass
indent = indent * level
lines = [indent+line for line in self.astext().splitlines()]
if not lines:
Modified: trunk/docutils/docutils/writers/pseudoxml.py
===================================================================
--- trunk/docutils/docutils/writers/pseudoxml.py 2020-12-15 23:06:16 UTC (rev 8591)
+++ trunk/docutils/docutils/writers/pseudoxml.py 2020-12-15 23:06:26 UTC (rev 8592)
@@ -9,7 +9,7 @@
__docformat__ = 'reStructuredText'
-from docutils import writers
+from docutils import writers, frontend
class Writer(writers.Writer):
@@ -16,6 +16,14 @@
supported = ('pprint', 'pformat', 'pseudoxml')
"""Formats this writer supports."""
+
+ settings_spec = (
+ '"Docutils pseudo-XML" Writer Options',
+ None,
+ (('Pretty-print <#text> nodes.',
+ ['--detailled'],
+ {'action': 'store_true', 'validator': frontend.validate_boolean}),
+ ))
config_section = 'pseudoxml writer'
config_section_dependencies = ('writers',)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-15 23:06:46
|
Revision: 8594
http://sourceforge.net/p/docutils/code/8594
Author: milde
Date: 2020-12-15 23:06:43 +0000 (Tue, 15 Dec 2020)
Log Message:
-----------
Merge adjoining <Text> nodes in recommonmark post-processing.
Ensure similar XML and pseudoXML output for rst and markdown input
while preserving whitespace in HTML and LaTeX output.
Modified Paths:
--------------
trunk/docutils/docutils/parsers/recommonmark_wrapper.py
trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
trunk/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
Modified: trunk/docutils/docutils/parsers/recommonmark_wrapper.py
===================================================================
--- trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2020-12-15 23:06:34 UTC (rev 8593)
+++ trunk/docutils/docutils/parsers/recommonmark_wrapper.py 2020-12-15 23:06:43 UTC (rev 8594)
@@ -62,11 +62,17 @@
# Post-Processing
# ---------------
- # remove spurious empty lines
+ # merge adjoining Text nodes:
for node in document.traverse(nodes.TextElement):
- node.children = [child for child in node.children
- if not (isinstance(child, nodes.Text)
- and str(child) == '\n')]
+ children = node.children
+ i = 0
+ while i+1 < len(children):
+ if (isinstance(children[i], nodes.Text)
+ and isinstance(children[i+1], nodes.Text)):
+ children[i] = nodes.Text(children[i]+children.pop(i+1))
+ children[i].parent = node
+ else:
+ i += 1
# add "code" class argument to inline literal (code spans)
for node in document.traverse(lambda n: isinstance(n,
@@ -85,7 +91,7 @@
if node.children or [v for v in node.attributes.values() if v]:
continue
node.parent.remove(node)
-
+
# replace raw nodes if raw is not allowed
if not document.settings.raw_enabled:
for node in document.traverse(nodes.raw):
Modified: trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py 2020-12-15 23:06:34 UTC (rev 8593)
+++ trunk/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py 2020-12-15 23:06:43 UTC (rev 8594)
@@ -68,8 +68,10 @@
<paragraph>
<raw format="html" xml:space="preserve">
<a href="foo">
+ \n\
<emphasis>
bar
+ \n\
<raw format="html" xml:space="preserve">
</a>
"""],
Modified: trunk/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
===================================================================
--- trunk/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py 2020-12-15 23:06:34 UTC (rev 8593)
+++ trunk/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py 2020-12-15 23:06:43 UTC (rev 8594)
@@ -38,6 +38,7 @@
<paragraph>
<emphasis>
emphasis
+ \n\
<emphasis>
also emphasis
"""],
@@ -69,8 +70,7 @@
"""\
<document source="test data">
<paragraph>
- *
- no emphasis without closing asterisk
+ *no emphasis without closing asterisk
"""],
[r"""
No markup when \*escaped or unbalanced *.
@@ -81,22 +81,16 @@
"""\
<document source="test data">
<paragraph>
- No markup when \n\
- *
- escaped or unbalanced \n\
- *
- .
+ No markup when *escaped or unbalanced *.
<paragraph>
What about \n\
<emphasis>
this
- *
- ?
+ *?
Unbalanced \n\
<emphasis>
markup
- _
- is kept as-is without warning.
+ _ is kept as-is without warning.
"""],
[r"""
Emphasized asterisk: *\**
@@ -112,8 +106,7 @@
<paragraph>
Emphasized double asterisk: \n\
<emphasis>
- *
- *
+ **
"""],
]
@@ -127,6 +120,7 @@
<paragraph>
<strong>
strong
+ \n\
<strong>
also strong
"""],
@@ -144,8 +138,7 @@
<paragraph>
Strong double asterisk: \n\
<strong>
- *
- *
+ **
"""],
["""\
**not strong without closing asterisks
@@ -153,8 +146,7 @@
"""\
<document source="test data">
<paragraph>
- **
- not strong without closing asterisks
+ **not strong without closing asterisks
"""],
]
@@ -277,13 +269,10 @@
literal
no literal
<paragraph>
- No warning for \n\
- `
- standalone TeX quotes\' or other \n\
+ No warning for `standalone TeX quotes\' or other \n\
<emphasis>
unbalanced markup
- *
- .
+ *.
"""],
["""\
``not literal without closing backquotes
@@ -291,8 +280,7 @@
"""\
<document source="test data">
<paragraph>
- ``
- not literal without closing backquotes
+ ``not literal without closing backquotes
"""],
[r"""
Python ``list``s use square bracket syntax.
@@ -311,9 +299,7 @@
"""\
<document source="test data">
<paragraph>
- Blank after opening \n\
- ``
- not allowed.
+ Blank after opening `` not allowed.
"""],
[r"""
no blank ``after closing``still ends a literal.
@@ -351,6 +337,7 @@
<paragraph>
Inline image \n\
<image alt="foo " title="train & tracks" uri="train.jpg">
+ \n\
in a paragraph.
"""],
["""\
@@ -429,9 +416,7 @@
"""\
<document source="test data">
<paragraph>
- [
- URI must follow immediately
- ]
+ [URI must follow immediately]
(http://example.com)
"""],
["""\
@@ -504,9 +489,9 @@
<document source="test data">
<paragraph>
Hard line breaks are not supported by Docutils.
- Not the soft line break preceded by two or more spaces,
- nor the more visible alternative,
- a backslash before the line ending.
+ Not the soft line break preceded by two or more spaces,\
+nor the more visible alternative,\
+a backslash before the line ending.
"""],
]
@@ -525,10 +510,7 @@
r
<literal classes="code">
k
- _
- u
- _
- p
+ _u_p
works except for underline.
"""],
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2020-12-15 23:07:00
|
Revision: 8595
http://sourceforge.net/p/docutils/code/8595
Author: milde
Date: 2020-12-15 23:06:58 +0000 (Tue, 15 Dec 2020)
Log Message:
-----------
New directive option "parser" for the "include" directive.
Modified Paths:
--------------
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
Added Paths:
-----------
trunk/docutils/test/test_parsers/test_rst/test_directives/include.md
trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2020-12-15 23:06:43 UTC (rev 8594)
+++ trunk/docutils/docs/ref/rst/directives.txt 2020-12-15 23:06:58 UTC (rev 8595)
@@ -1449,8 +1449,8 @@
.. _file_insertion_enabled: ../../user/config.html#file-insertion-enabled
The "include" directive reads a text file. The directive argument is
-the path to the file to be included, relative to the document
-containing the directive. Unless the options ``literal`` or ``code``
+the path to the file to be included, relative to the document containing
+the directive. Unless the options ``literal``, ``code``, or ``parser``
are given, the file is parsed in the current document's context at the
point of the directive. For example::
@@ -1502,12 +1502,16 @@
Only the content before the first occurrence of the specified text
(but after any ``after`` text) will be included.
+``parser`` : parser name
+ Parse the included content with the specified parser.
+ (New in Docutils 0.17)
+
``literal`` : flag (empty)
The entire included text is inserted into the document as a single
literal block.
``code`` : formal language (optional)
- The argument and the content of the included file are passed to
+ The argument and the included content are passed to
the code_ directive (useful for program listings).
(New in Docutils 0.9)
@@ -1530,7 +1534,6 @@
.. _tab_width: ../../user/config.html#tab-width
-
With ``code`` or ``literal`` the common options `:class:`_ and
`:name:`_ are recognized as well.
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2020-12-15 23:06:43 UTC (rev 8594)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2020-12-15 23:06:58 UTC (rev 8595)
@@ -13,7 +13,7 @@
import sys
from importlib import import_module
-from docutils import nodes
+from docutils import nodes, parsers
from docutils.utils import split_escaped_whitespace, escape2null, unescape
from docutils.parsers.rst.languages import en as _fallback_language_module
@@ -217,6 +217,7 @@
def percentage(argument):
"""
Check for an integer percentage value with optional percent sign.
+ (Directive option conversion function.)
"""
try:
argument = argument.rstrip(' %')
@@ -231,6 +232,7 @@
Check for a positive argument of one of the units and return a
normalized string of the form "<value><unit>" (without space in
between).
+ (Directive option conversion function.)
To be called from directive option conversion functions.
"""
@@ -249,6 +251,7 @@
def length_or_percentage_or_unitless(argument, default=''):
"""
Return normalized string of a length or percentage unit.
+ (Directive option conversion function.)
Add <default> if there is no unit. Raise ValueError if the argument is not
a positive measure of one of the valid CSS units (or without unit).
@@ -409,6 +412,8 @@
def value_or(values, other):
"""
+ Directive option conversion function.
+
The argument can be any of `values` or `argument_type`.
"""
def auto_or_other(argument):
@@ -418,3 +423,16 @@
return other(argument)
return auto_or_other
+def parser_name(argument):
+ """
+ Return a docutils parser whose name matches the argument.
+ (Directive option conversion function.)
+
+ Return `None`, if the argument evaluates to `False`.
+ """
+ if not argument:
+ return None
+ try:
+ return parsers.get_parser_class(argument)
+ except ImportError:
+ raise ValueError('Unknown parser name "%s".'%argument)
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2020-12-15 23:06:43 UTC (rev 8594)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2020-12-15 23:06:58 UTC (rev 8595)
@@ -37,6 +37,7 @@
option_spec = {'literal': directives.flag,
'code': directives.unchanged,
'encoding': directives.encoding,
+ 'parser': directives.parser_name,
'tab-width': int,
'start-line': int,
'end-line': int,
@@ -166,6 +167,13 @@
self.state_machine)
return codeblock.run()
+ if 'parser' in self.options:
+ parser = self.options['parser']()
+ # parse into a new (dummy) document
+ document = utils.new_document(path, self.state.document.settings)
+ parser.parse('\n'.join(include_lines), document)
+ return document.children
+
# include as rST source
#
# Prevent circular inclusion:
Added: trunk/docutils/test/test_parsers/test_rst/test_directives/include.md
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/include.md (rev 0)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/include.md 2020-12-15 23:06:58 UTC (rev 8595)
@@ -0,0 +1,7 @@
+# Title 1
+
+*emphasis* and _also emphasis_
+
+No whitespace required around a[phrase reference].
+
+[phrase reference]: /uri
Added: trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py (rev 0)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py 2020-12-15 23:06:58 UTC (rev 8595)
@@ -0,0 +1,63 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+# $Id$
+# Author: Günter Milde <mi...@us...>,
+# :License: Released under the terms of the `2-Clause BSD license`_, in short:
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+"""
+Test module for `docutils.parsers.rst.directives`.
+"""
+
+from __future__ import absolute_import
+
+if __name__ == '__main__':
+ import __init__
+from test_parsers import DocutilsTestSupport
+
+import docutils
+import docutils.parsers.null
+from docutils.parsers.rst import directives
+
+
+
+class DirectiveOptionConversionTestCase(DocutilsTestSupport.StandardTestCase):
+
+ def test_flag(self):
+ # Raise error when there is an argument:
+ self.assertEqual(None, directives.flag(''))
+ self.assertRaises(ValueError, directives.flag, 'alles')
+
+ def test_unchanged_required(self):
+ # Raise error when there is no argument:
+ self.assertRaises(ValueError, directives.unchanged_required, None)
+ self.assertEqual(3, directives.unchanged_required(3))
+
+ def test_unchanged(self):
+ self.assertEqual('', directives.unchanged(''))
+ self.assertTrue('something' == directives.unchanged('something'))
+ self.assertEqual(3, directives.unchanged(3))
+ self.assertEqual([3], directives.unchanged([3]))
+
+ # ... 13 more direcive option conversion functions.
+
+ def test_parser_name(self):
+ self.assertEqual(None, directives.parser_name(None))
+ self.assertEqual(docutils.parsers.null.Parser,
+ directives.parser_name('null'))
+ self.assertEqual(docutils.parsers.rst.Parser,
+ directives.parser_name('rst'))
+ self.assertEqual(docutils.parsers.recommonmark_wrapper.Parser,
+ directives.parser_name('markdown'))
+ self.assertRaises(ValueError, directives.parser_name, 'fantasy')
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main()
+
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2020-12-15 23:06:43 UTC (rev 8594)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2020-12-15 23:06:58 UTC (rev 8595)
@@ -15,9 +15,9 @@
import __init__
from test_parsers import DocutilsTestSupport
from docutils.parsers.rst import states
+from docutils.parsers.recommonmark_wrapper import with_recommonmark
from docutils.utils.code_analyzer import with_pygments
-
if sys.version_info >= (3, 0):
unichr = chr # noqa
@@ -49,6 +49,7 @@
include15 = mydir('includes/include15.txt')
include16 = mydir('includes/include16.txt')
include_literal = mydir('include_literal.txt')
+include_md = mydir('include.md')
utf_16_file = mydir('utf-16.csv')
utf_16_error_str = ("UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe "
"in position 0: ordinal not in range(128)")
@@ -73,6 +74,32 @@
InputError: [Errno 2] No such file or directory: '\u043c\u0438\u0440.txt'.\
"""
+# Parsing with Markdown (recommonmark) is an optional feature depending
+# on 3rd-party modules:
+if with_recommonmark:
+ markdown_parsing_result = """\
+ <section ids="title-1" names="title\\ 1">
+ <title>
+ Title 1
+ <paragraph>
+ <emphasis>
+ emphasis
+ and \n\
+ <emphasis>
+ also emphasis
+ <paragraph>
+ No whitespace required around a
+ <reference name="phrase reference" refuri="/uri">
+ phrase reference
+ ."""
+else:
+ markdown_parsing_result = """\
+ <system_message level="2" source="test_parsers/test_rst/test_directives/include.md" type="WARNING">
+ <paragraph>
+ Missing dependency: MarkDown input is processed by a 3rd party parser but Python did not find the required module "recommonmark" (https://pypi.org/project/recommonmark/).\
+"""
+
+
totest = {}
totest['include'] = [
@@ -193,6 +220,22 @@
This file is used by ``test_include.py``.
""" % reldir(include1)],
["""\
+Include markdown (recommonmark).
+
+.. include:: %s
+ :parser: markdown
+
+A paragraph.
+""" % include_md,
+"""\
+<document source="test data">
+ <paragraph>
+ Include markdown (recommonmark).
+%s
+ <paragraph>
+ A paragraph.
+""" % markdown_parsing_result],
+["""\
Let's test the parse context.
This paragraph is in a block quote.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-03 21:57:59
|
Revision: 8600
http://sourceforge.net/p/docutils/code/8600
Author: milde
Date: 2021-01-03 21:57:56 +0000 (Sun, 03 Jan 2021)
Log Message:
-----------
Apply patch #177 Arabic mappings by Shahin.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/setup.py
Added Paths:
-----------
trunk/docutils/docutils/languages/ar.py
trunk/docutils/docutils/parsers/rst/languages/ar.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-03 21:05:13 UTC (rev 8599)
+++ trunk/docutils/HISTORY.txt 2021-01-03 21:57:56 UTC (rev 8600)
@@ -37,6 +37,11 @@
- VersionInfo: ValueError for invalid values, fix comparison to tuples.
+* docutils/languages/ar.py
+ docutils/parsers/rst/languages/ar.py:
+
+ - Apply patch # 177 Arabic mappings by Shahin.
+
* docutils/nodes.py
- Apply patch #165: Fix error when copying `system_message` node
@@ -281,8 +286,8 @@
- Fix [ 348 ] Since Python 3.4, the 'U' universal newlines mode has been
deprecated (thanks to hugovk).
-* docutils/languages/la.py
- docutils/parsers/rst/languages/la.py:
+* docutils/languages/ko.py
+ docutils/parsers/rst/languages/ko.py:
- Apply [ 153 ] Korean mappings by Thomas Sungjin Kang.
Added: trunk/docutils/docutils/languages/ar.py
===================================================================
--- trunk/docutils/docutils/languages/ar.py (rev 0)
+++ trunk/docutils/docutils/languages/ar.py 2021-01-03 21:57:56 UTC (rev 8600)
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# $Id: fa.py 4564 2016-08-10 11:48:42Z
+# Author: Shahin <me...@5h...>
+# Copyright: This module has been placed in the public domain.
+
+# New language mappings are welcome. Before doing a new translation, please
+# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
+# translated for each language: one in docutils/languages, the other in
+# docutils/parsers/rst/languages.
+
+"""
+Arabic-language mappings for language-dependent features of Docutils.
+"""
+
+__docformat__ = 'reStructuredText'
+
+labels = {
+ # fixed: language-dependent
+ u'author': u'المؤلف',
+ u'authors': u'المؤلفون',
+ u'organization': u'التنظيم',
+ u'address': u'العنوان',
+ u'contact': u'اتصل',
+ u'version': u'نسخة',
+ u'revision': u'مراجعة',
+ u'status': u'الحالة',
+ u'date': u'تاریخ',
+ u'copyright': u'الحقوق',
+ u'dedication': u'إهداء',
+ u'abstract': u'ملخص',
+ u'attention': u'تنبيه',
+ u'caution': u'احتیاط',
+ u'danger': u'خطر',
+ u'error': u'خطأ',
+ u'hint': u'تلميح',
+ u'important': u'مهم',
+ u'note': u'ملاحظة',
+ u'tip': u'نصيحة',
+ u'warning': u'تحذير',
+ u'contents': u'المحتوى'}
+"""Mapping of node class name to label text."""
+
+bibliographic_fields = {
+ # language-dependent: fixed
+ u'مؤلف': u'author',
+ u'مؤلفون': u'authors',
+ u'التنظيم': u'organization',
+ u'العنوان': u'address',
+ u'اتصل': u'contact',
+ u'نسخة': u'version',
+ u'مراجعة': u'revision',
+ u'الحالة': u'status',
+ u'تاریخ': u'date',
+ u'الحقوق': u'copyright',
+ u'إهداء': u'dedication',
+ u'ملخص': u'abstract'}
+"""Arabic (lowcased) to canonical name mapping for bibliographic fields."""
+
+author_separators = [u'؛', u'،']
+"""List of separator strings for the 'Authors' bibliographic field. Tried in
+order."""
Property changes on: trunk/docutils/docutils/languages/ar.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/docutils/parsers/rst/languages/ar.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/languages/ar.py (rev 0)
+++ trunk/docutils/docutils/parsers/rst/languages/ar.py 2021-01-03 21:57:56 UTC (rev 8600)
@@ -0,0 +1,102 @@
+# -*- coding: utf-8 -*-
+# $Id: fa.py 4564 2016-08-10 11:48:42Z
+# Author: Shahin <me...@5h...>
+# Copyright: This module has been placed in the public domain.
+
+# New language mappings are welcome. Before doing a new translation, please
+# read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be
+# translated for each language: one in docutils/languages, the other in
+# docutils/parsers/rst/languages.
+
+"""
+Arabic-language mappings for language-dependent features of
+reStructuredText.
+"""
+
+__docformat__ = 'reStructuredText'
+
+
+directives = {
+ # language-dependent: fixed
+ u'تنبيه': u'attention',
+ u'احتیاط': u'caution',
+ u'كود': u'code',
+ u'كود': u'code',
+ u'كود': u'code',
+ u'خطر': u'danger',
+ u'خطأ': u'error',
+ u'تلميح': u'hint',
+ u'مهم': u'important',
+ u'ملاحظة': u'note',
+ u'نصيحة': u'tip',
+ u'تحذير': u'warning',
+ u'تذكير': u'admonition',
+ u'شريط-جانبي': u'sidebar',
+ u'موضوع': u'topic',
+ u'قالب-سطري': u'line-block',
+ u'لفظ-حرفي': u'parsed-literal',
+ u'معيار': u'rubric',
+ u'فكرة-الكتاب': u'epigraph',
+ u'تمييز': u'highlights',
+ u'نقل-قول': u'pull-quote',
+ u'ترکیب': u'compound',
+ u'وعاء': u'container',
+ #'questions': u'questions',
+ u'جدول': u'table',
+ u'جدول-csv': u'csv-table',
+ u'جدول-قوائم': u'list-table',
+ #'qa': u'questions',
+ #'faq': u'questions',
+ u'ميتا': u'meta',
+ u'رياضيات': u'math',
+ #'imagemap': u'imagemap',
+ u'صورة': u'image',
+ u'رسم-توضيحي': u'figure',
+ u'تضمين': u'include',
+ u'خام': u'raw',
+ u'تبديل': u'replace',
+ u'یونیکد': u'unicode',
+ u'تاریخ': u'date',
+ u'كائن': u'class',
+ u'قانون': u'role',
+ u'قانون-افتراضي': u'default-role',
+ u'عنوان': u'title',
+ u'المحتوى': u'contents',
+ u'رقم-الفصل': u'sectnum',
+ u'رقم-القسم': u'sectnum',
+ u'رأس-الصفحة': u'header',
+ u'هامش': u'footer',
+ #'footnotes': u'footnotes',
+ #'citations': u'citations',
+ u'': u'target-notes',
+ }
+"""Arabic name to registered (in directives/__init__.py) directive name
+mapping."""
+
+roles = {
+ # language-dependent: fixed
+ u'اختصار': u'abbreviation',
+ u'اختزال': u'acronym',
+ u'كود': u'code',
+ u'فهرس': u'index',
+ u'خفض': u'subscript',
+ u'رفع': u'superscript',
+ u'عنوان-مرجع': u'title-reference',
+ u'مرجع-pep': u'pep-reference',
+ u'rfc-مرجع': u'rfc-reference',
+ u'تأكيد': u'emphasis',
+ u'عريض': u'strong',
+ u'لفظی': u'literal',
+ u'رياضيات': u'math',
+ u'مرجع-مسمى': u'named-reference',
+ u'مرجع-مجهول': u'anonymous-reference',
+ u'مرجع-هامشي': u'footnote-reference',
+ u'مرجع-منقول': u'citation-reference',
+ u'مرجع-معوض': u'substitution-reference',
+ u'هدف': u'target',
+ u'منبع-uri': u'uri-reference',
+ u'uri': u'uri-reference',
+ u'url': u'uri-reference',
+ u'خام': u'raw',}
+"""Mapping of Arabic role names to canonical role names for interpreted text.
+"""
Property changes on: trunk/docutils/docutils/parsers/rst/languages/ar.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2021-01-03 21:05:13 UTC (rev 8599)
+++ trunk/docutils/setup.py 2021-01-03 21:57:56 UTC (rev 8600)
@@ -102,6 +102,7 @@
'Topic :: Text Processing',
'Natural Language :: English', # main/default language, keep first
'Natural Language :: Afrikaans',
+ 'Natural Language :: Arabic',
'Natural Language :: Catalan',
'Natural Language :: Chinese (Simplified)',
'Natural Language :: Chinese (Traditional)',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-03 21:58:08
|
Revision: 8601
http://sourceforge.net/p/docutils/code/8601
Author: milde
Date: 2021-01-03 21:58:06 +0000 (Sun, 03 Jan 2021)
Log Message:
-----------
Clean up Markdown support.
Set 'docutils-cli.py' shebang to python3 (better chance of markdown support).
Remove the 'md2*.py' wrappers. (Use 'docutils-cli.py --parser=markdown'.)
Remove hard-coded print output from test suite when there is no recommonmark module.
Modified Paths:
--------------
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/tools/docutils-cli.py
Removed Paths:
-------------
trunk/docutils/tools/md2html5.py
trunk/docutils/tools/md2pseudoxml.py
trunk/docutils/tools/md2xml.py
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2021-01-03 21:57:56 UTC (rev 8600)
+++ trunk/docutils/test/DocutilsTestSupport.py 2021-01-03 21:58:06 UTC (rev 8601)
@@ -537,13 +537,9 @@
"""A collection of RecommonmarkParserTestCases."""
test_case_class = RecommonmarkParserTestCase
- skip_message = 'skip "%s" (module `recommonmark` not found)'
def generateTests(self, dict, dictname='totest'):
if 'recommonmark' not in recommonmark_wrapper.Parser.supported:
- if RecommonmarkParserTestSuite.skip_message: # warn (only once)
- print(self.skip_message%self.id)
- RecommonmarkParserTestSuite.skip_message = ''
return
# suppress UserWarnings from recommonmark parser
warnings.filterwarnings('ignore', message='Unsupported.*type')
Modified: trunk/docutils/tools/docutils-cli.py
===================================================================
--- trunk/docutils/tools/docutils-cli.py 2021-01-03 21:57:56 UTC (rev 8600)
+++ trunk/docutils/tools/docutils-cli.py 2021-01-03 21:58:06 UTC (rev 8601)
@@ -1,6 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf8 -*-
-# :Copyright: © 2015 Günter Milde.
+# :Copyright: © 2020 Günter Milde.
# :License: Released under the terms of the `2-Clause BSD license`_, in short:
#
# Copying and distribution of this file, with or without modification,
@@ -49,8 +49,8 @@
# choices=('html', 'html4', 'html5', 'latex', 'xelatex',
# 'odt', 'xml', 'pseudoxml', 'manpage',
# 'pep_html', 's5_html'),
- help=u'Writer name (default "pseudoxml").',
- default='pseudoxml')
+ help=u'Writer name (default "html5").',
+ default='html5')
(args, remainder) = parser.parse_known_args()
Deleted: trunk/docutils/tools/md2html5.py
===================================================================
--- trunk/docutils/tools/md2html5.py 2021-01-03 21:57:56 UTC (rev 8600)
+++ trunk/docutils/tools/md2html5.py 2021-01-03 21:58:06 UTC (rev 8601)
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# :Copyright: © 2020 Günter Milde.
-# :License: Released under the terms of the `2-Clause BSD license`_, in short:
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-# This file is offered as-is, without any warranty.
-#
-# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
-#
-# Revision: $Revision$
-# Date: $Date$
-
-"""
-A minimal front end to the Docutils Publisher, parsing CommonMark markdown files
-with `recommonmark` and producing HTML 5 documents.
-
-The output is also valid XML.
-"""
-
-try:
- import locale # module missing in Jython
- locale.setlocale(locale.LC_ALL, '')
-except locale.Error:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-
-description = (u'Generate HTML5 documents from standalone '
- u'Markdown (CommonMark) sources.\n'
- + default_description)
-
-publish_cmdline(#parser=mdparser,
- parser_name="recommonmark",
- writer_name='html5',
- description=description)
Deleted: trunk/docutils/tools/md2pseudoxml.py
===================================================================
--- trunk/docutils/tools/md2pseudoxml.py 2021-01-03 21:57:56 UTC (rev 8600)
+++ trunk/docutils/tools/md2pseudoxml.py 2021-01-03 21:58:06 UTC (rev 8601)
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# :Copyright: © 2020 Günter Milde.
-# :License: Released under the terms of the `2-Clause BSD license`_, in short:
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-# This file is offered as-is, without any warranty.
-#
-# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
-#
-# Revision: $Revision$
-# Date: $Date$
-
-"""
-A minimal front end to the Docutils Publisher, parsing CommonMark markdown
-files with `recommonmark` and producing Pseudo-XML.
-"""
-
-try:
- import locale
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-
-description = ('Generates Pseudo-XML from standalone '
- 'CommonMark sources. ' + default_description)
-
-publish_cmdline(parser_name='recommonmark', description=description)
Deleted: trunk/docutils/tools/md2xml.py
===================================================================
--- trunk/docutils/tools/md2xml.py 2021-01-03 21:57:56 UTC (rev 8600)
+++ trunk/docutils/tools/md2xml.py 2021-01-03 21:58:06 UTC (rev 8601)
@@ -1,34 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# :Copyright: © 2020 Günter Milde.
-# :License: Released under the terms of the `2-Clause BSD license`_, in short:
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-# This file is offered as-is, without any warranty.
-#
-# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
-#
-# Revision: $Revision$
-# Date: $Date$
-
-"""
-A minimal front end to the Docutils Publisher, parsing CommonMark markdown
-files with `recommonmark` and producing Docutils XML.
-"""
-
-try:
- import locale
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-
-description = ('Generates Docutils-native XML from standalone '
- 'CommonMark sources. ' + default_description)
-
-publish_cmdline(parser_name='recommonmark', writer_name='xml',
- description=description)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-08 15:24:08
|
Revision: 8602
http://sourceforge.net/p/docutils/code/8602
Author: milde
Date: 2021-01-08 15:24:05 +0000 (Fri, 08 Jan 2021)
Log Message:
-----------
Small fixes.
Avoid spurious blank lines in LaTeX output.
Update comments, trim whitespace.
Todo entry for minor parsing bug.
Modified Paths:
--------------
trunk/docutils/docs/dev/todo.txt
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2021-01-03 21:58:06 UTC (rev 8601)
+++ trunk/docutils/docs/dev/todo.txt 2021-01-08 15:24:05 UTC (rev 8602)
@@ -807,6 +807,12 @@
__ rst/alternatives.html#or-not-to-do
+Bugs
+----
+
+* A container directive with ``:class:`` option gets the spurious
+ class value "class".
+
Misc
----
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2021-01-03 21:58:06 UTC (rev 8601)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2021-01-08 15:24:05 UTC (rev 8602)
@@ -371,7 +371,6 @@
def visit_meta(self, node):
if node.hasattr('lang'):
node['xml:lang'] = node['lang']
- # del(node['lang'])
meta = self.emptytag(node, 'meta', **node.non_default_attributes())
self.add_meta(meta)
def depart_meta(self, node):
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-03 21:58:06 UTC (rev 8601)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-08 15:24:05 UTC (rev 8602)
@@ -1119,7 +1119,7 @@
(none,
self.literal_block_env,
self.literal_block_options,
- none ) = re.split(r'(\w+)(.*)', settings.literal_block_env)
+ none) = re.split(r'(\w+)(.*)', settings.literal_block_env)
elif settings.use_verbatim_when_possible:
self.literal_block_env = 'verbatim'
#
@@ -1645,24 +1645,24 @@
def visit_block_quote(self, node):
self.duclass_open(node)
- self.out.append( '\\begin{quote}')
+ self.out.append('\\begin{quote}')
def depart_block_quote(self, node):
- self.out.append( '\\end{quote}\n')
+ self.out.append('\\end{quote}\n')
self.duclass_close(node)
def visit_bullet_list(self, node):
self.duclass_open(node)
if self.is_toc_list:
- self.out.append( '\\begin{list}{}{}' )
+ self.out.append('\\begin{list}{}{}')
else:
- self.out.append( '\\begin{itemize}' )
+ self.out.append('\\begin{itemize}')
def depart_bullet_list(self, node):
if self.is_toc_list:
- self.out.append( '\\end{list}\n' )
+ self.out.append('\\end{list}\n')
else:
- self.out.append( '\\end{itemize}\n' )
+ self.out.append('\\end{itemize}\n')
self.duclass_close(node)
def visit_superscript(self, node):
@@ -1701,7 +1701,7 @@
def depart_title_reference(self, node):
if node['classes']:
self.depart_inline(node)
- self.out.append( '}' )
+ self.out.append('}')
def visit_citation(self, node):
if self._use_latex_citations:
@@ -1758,10 +1758,10 @@
self.out.append(']}')
def visit_classifier(self, node):
- self.out.append( '(\\textbf{' )
+ self.out.append('(\\textbf{')
def depart_classifier(self, node):
- self.out.append( '})' )
+ self.out.append('})')
def visit_colspec(self, node):
self.active_table.visit_colspec(node)
@@ -1827,10 +1827,10 @@
def visit_definition_list(self, node):
self.duclass_open(node)
- self.out.append( '\\begin{description}\n' )
+ self.out.append('\\begin{description}\n')
def depart_definition_list(self, node):
- self.out.append( '\\end{description}\n' )
+ self.out.append('\\end{description}\n')
self.duclass_close(node)
def visit_definition_list_item(self, node):
@@ -2122,7 +2122,7 @@
self._enumeration_counters.pop()
def visit_field(self, node):
- # output is done in field_argument, field_body, field_name
+ # output is done in field_body, field_name
pass
def depart_field(self, node):
@@ -2649,16 +2649,18 @@
def visit_paragraph(self, node):
# insert blank line, unless
- # * the paragraph is first in a list item or compound,
+ # * the paragraph is first in a list item, compound, or container
# * follows a non-paragraph node in a compound,
# * is in a table with auto-width columns
index = node.parent.index(node)
if index == 0 and isinstance(node.parent,
- (nodes.list_item, nodes.description, nodes.compound)):
+ (nodes.list_item, nodes.description,
+ nodes.compound, nodes.container)):
pass
- elif (index > 0 and isinstance(node.parent, nodes.compound) and
- not isinstance(node.parent[index - 1], nodes.paragraph) and
- not isinstance(node.parent[index - 1], nodes.compound)):
+ elif (index > 0
+ and isinstance(node.parent, nodes.compound)
+ and not isinstance(node.parent[index - 1],
+ (nodes.paragraph, nodes.compound))):
pass
elif self.active_table.colwidths_auto:
if index == 1: # second paragraph
@@ -2971,8 +2973,6 @@
self.out.append('}] \\leavevmode ')
def visit_tgroup(self, node):
- #self.out.append(self.starttag(node, 'colgroup'))
- #self.context.append('</colgroup>\n')
pass
def depart_tgroup(self, node):
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2021-01-03 21:58:06 UTC (rev 8601)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2021-01-08 15:24:05 UTC (rev 8602)
@@ -1522,7 +1522,6 @@
}
\begin{DUclass}{custom}
-
paragraph 1
paragraph 2
@@ -2042,7 +2041,6 @@
\newcommand*{\DUCLASSscshape}{\scshape}
\begin{DUclass}{scshape}
-
paragraph 1
paragraph 2
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-01-03 21:58:06 UTC (rev 8601)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-01-08 15:24:05 UTC (rev 8602)
@@ -1526,7 +1526,6 @@
}
\begin{DUclass}{custom}
-
paragraph 1
paragraph 2
@@ -2046,7 +2045,6 @@
\newcommand*{\DUCLASSscshape}{\scshape}
\begin{DUclass}{scshape}
-
paragraph 1
paragraph 2
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2021-01-03 21:58:06 UTC (rev 8601)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2021-01-08 15:24:05 UTC (rev 8602)
@@ -1412,7 +1412,6 @@
}
\begin{DUclass}{custom}
-
paragraph 1
paragraph 2
@@ -1932,7 +1931,6 @@
\newcommand*{\DUCLASSscshape}{\scshape}
\begin{DUclass}{scshape}
-
paragraph 1
paragraph 2
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-08 15:24:40
|
Revision: 8603
http://sourceforge.net/p/docutils/code/8603
Author: milde
Date: 2021-01-08 15:24:32 +0000 (Fri, 08 Jan 2021)
Log Message:
-----------
Make "meta" elements available for "latex" and "odt".
Basic "odt" support exists, "latex" support is planned.
In future, the `meta directive`__ may insert <meta> instead of
pending nodes, `making transforms/components.Filter` obsolete
(solves bug #241).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/transforms/components.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/HISTORY.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -62,6 +62,11 @@
- Make the sidebar's "title" argument optional (feature request #69).
+* docutils/parsers/rst/directives/html.py
+
+ - Make "meta" elements available for "latex" and "odt".
+ (Basic "odt" support exists, "latex" support is planned.)
+
* docutils/parsers/rst/directives/misc.py
- Prevent infinite inclusion loops.
@@ -74,6 +79,10 @@
- Fix bug #383: Smart quotes around opening and separator characters.
+* docutils/transforms/components.py
+
+ - Allow a comma-separated list of formats for the Filter transform.
+
* docutils/writers/html*
- Implement feature request #40 `Option to embed images as data URI`.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/RELEASE-NOTES.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -35,6 +35,17 @@
Remove the IE PNG Fix by Angus Turnbull. IE has native PNG
support since version 7.
+* Make <meta> a standard Docutils doctree node.
+
+ The `meta directive`__ will insert <meta> instead of pending nodes.
+ Writers may ignore some or all <meta> elements if they are not
+ supported by the output format.
+
+ The ``transforms/components.Filter`` class will become obsolete by
+ this change and may be removed in future.
+
+ __ docs/ref/rst/directives.html#meta
+
* ``Node.traverse()`` will return an iterator instead of a list.
* Remove ``utils.unique_combinations``
@@ -70,7 +81,7 @@
.. _auto_id_prefix: docs/user/config.html#auto-id-prefix
.. _rst2html.py: docs/user/tools.html#rst2html-py
.. _reference name: docs/ref/rst/restructuredtext.html#reference-names
-.. _identifier normalization: directives.html#identifier-normalization
+.. _identifier normalization: docs/ref/rst/directives.html#identifier-normalization
Release 0.17
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docs/ref/rst/directives.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -1224,62 +1224,6 @@
HTML-Specific
---------------
-Meta
-====
-
-:Directive Type: "meta"
-:Doctree Element: meta (non-standard)
-:Directive Arguments: None.
-:Directive Options: None.
-:Directive Content: Must contain a flat field list.
-
-The "meta" directive is used to specify HTML metadata stored in HTML
-META tags. "Metadata" is data about data, in this case data about web
-pages. Metadata is used to describe and classify web pages in the
-World Wide Web, in a form that is easy for search engines to extract
-and collate.
-
-Within the directive block, a flat field list provides the syntax for
-metadata. The field name becomes the contents of the "name" attribute
-of the META tag, and the field body (interpreted as a single string
-without inline markup) becomes the contents of the "content"
-attribute. For example::
-
- .. meta::
- :description: The reStructuredText plaintext markup language
- :keywords: plaintext, markup language
-
-This would be converted to the following HTML::
-
- <meta name="description"
- content="The reStructuredText plaintext markup language">
- <meta name="keywords" content="plaintext, markup language">
-
-Support for other META attributes ("http-equiv", "scheme", "lang",
-"dir") are provided through field arguments, which must be of the form
-"attr=value"::
-
- .. meta::
- :description lang=en: An amusing story
- :description lang=fr: Une histoire amusante
-
-And their HTML equivalents::
-
- <meta name="description" lang="en" content="An amusing story">
- <meta name="description" lang="fr" content="Une histoire amusante">
-
-Some META tags use an "http-equiv" attribute instead of the "name"
-attribute. To specify "http-equiv" META tags, simply omit the name::
-
- .. meta::
- :http-equiv=Content-Type: text/html; charset=ISO-8859-1
-
-HTML equivalent::
-
- <meta http-equiv="Content-Type"
- content="text/html; charset=ISO-8859-1">
-
-
Imagemap
========
@@ -1914,6 +1858,76 @@
parser is "title-reference".
+Metadata
+========
+
+:Directive Type: "meta"
+:Doctree Element: pending_, meta (non-standard)
+:Directive Arguments: None.
+:Directive Options: None.
+:Directive Content: Must contain a flat field list.
+
+The "meta" directive is used to specify metadata\ [#]_ to be stored
+in, e.g., HTML META tags or as ODT file properties. If the output
+format does not support "invisible" metadata, it is silently
+dropped by the writer.
+
+.. note:: Data from some `bibliographic fields`_ is automatically
+ extracted and stored in META tags, too. However, Bibliographic
+ Fields are also visible in the document's screen rendering or
+ printout.
+
+ For an "invisible" *document title*, see the `metadata document
+ title`_ directive below.
+
+Within the directive block, a flat field list provides the syntax for
+metadata. The field name becomes the contents of the "name" attribute
+of the META tag, and the field body (interpreted as a single string
+without inline markup) becomes the contents of the "content"
+attribute. For example::
+
+ .. meta::
+ :description: The reStructuredText plaintext markup language
+ :keywords: plaintext, markup language
+
+This would be converted to the following HTML::
+
+ <meta name="description"
+ content="The reStructuredText plaintext markup language">
+ <meta name="keywords" content="plaintext, markup language">
+
+Support for other META attributes ("http-equiv", "scheme", "lang",
+"dir") are provided through field arguments, which must be of the form
+"attr=value"::
+
+ .. meta::
+ :description lang=en: An amusing story
+ :description lang=fr: Une histoire amusante
+
+And their HTML equivalents::
+
+ <meta name="description" lang="en" content="An amusing story">
+ <meta name="description" lang="fr" content="Une histoire amusante">
+
+Some META tags use an "http-equiv" attribute instead of the "name"
+attribute. To specify "http-equiv" META tags, simply omit the name::
+
+ .. meta::
+ :http-equiv=Content-Type: text/html; charset=ISO-8859-1
+
+HTML equivalent::
+
+ <meta http-equiv="Content-Type"
+ content="text/html; charset=ISO-8859-1">
+
+.. [#] "Metadata" is data about data, in this case data about the
+ document. Metadata is, e.g., used to describe and classify web
+ pages in the World Wide Web, in a form that is easy for search
+ engines to extract and collate.
+
+.. _bibliographic fields: restructuredtext.html#bibliographic-fields
+
+
Metadata Document Title
=======================
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2021-01-08 15:24:32 UTC (rev 8603)
@@ -3117,7 +3117,7 @@
http://www.w3.org/TR/WCAG10-HTML-TECHS/#link-text
.. _image: directives.html#image
.. _replace: directives.html#replace
-.. _meta: directives.html#meta
+.. _meta: directives.html#metadata
.. _figure: directives.html#figure
.. _admonition: directives.html#admonitions
.. _role: directives.html#custom-interpreted-text-roles
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -35,7 +35,7 @@
node = self.meta()
pending = nodes.pending(components.Filter,
{'component': 'writer',
- 'format': 'html',
+ 'format': 'html,latex,odt',
'nodes': [node]})
node['content'] = utils.unescape(utils.escape2null(
' '.join(indented)))
Modified: trunk/docutils/docutils/transforms/components.py
===================================================================
--- trunk/docutils/docutils/transforms/components.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/transforms/components.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -35,7 +35,8 @@
For example, the reStructuredText "meta" directive creates a "pending"
element containing a "meta" element (in ``pending.details['nodes']``).
Only writers (``pending.details['component'] == 'writer'``) supporting the
- "html" format (``pending.details['format'] == 'html'``) will include the
+ "html", latex, or "odf" formats
+ (``pending.details['format'] == 'html,latex,odf'``) will include the
"meta" element; it will be deleted from the output of all other writers.
"""
@@ -44,9 +45,11 @@
def apply(self):
pending = self.startnode
component_type = pending.details['component'] # 'reader' or 'writer'
- format = pending.details['format']
+ formats = (pending.details['format']).split(',')
component = self.document.transformer.components[component_type]
- if component.supports(format):
- pending.replace_self(pending.details['nodes'])
+ for format in formats:
+ if component.supports(format):
+ pending.replace_self(pending.details['nodes'])
+ break
else:
pending.parent.remove(pending)
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -2541,21 +2541,12 @@
self.out.append(self.context.pop())
self.duclass_close(node)
- ## def visit_meta(self, node):
- ## self.out.append('[visit_meta]\n')
- # TODO: set keywords for pdf?
- # But:
- # The reStructuredText "meta" directive creates a "pending" node,
- # which contains knowledge that the embedded "meta" node can only
- # be handled by HTML-compatible writers. The "pending" node is
- # resolved by the docutils.transforms.components.Filter transform,
- # which checks that the calling writer supports HTML; if it doesn't,
- # the "pending" node (and enclosed "meta" node) is removed from the
- # document.
- # --- docutils/docs/peps/pep-0258.html#transformer
+ def visit_meta(self, node):
+ # TODO: set keywords for pdf or write info for dropped content?
+ pass
- ## def depart_meta(self, node):
- ## self.out.append('[depart_meta]\n')
+ def depart_meta(self, node):
+ pass
def visit_math(self, node, math_env='$'):
"""math role"""
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/docutils/writers/manpage.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -860,11 +860,12 @@
def depart_math_block(self, node):
self.depart_literal_block(node)
- def visit_meta(self, node):
- raise NotImplementedError(node.astext())
+ # <meta> shall become an optional standard node:
+ # def visit_meta(self, node):
+ # raise NotImplementedError(node.astext())
- def depart_meta(self, node):
- pass
+ # def depart_meta(self, node):
+ # pass
def visit_note(self, node):
self.visit_admonition(node, 'note')
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2021-01-08 15:24:05 UTC (rev 8602)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2021-01-08 15:24:32 UTC (rev 8603)
@@ -34,7 +34,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="The reStructuredText plaintext markup language" name="description">
<pending>
@@ -42,7 +42,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="plaintext,markup language" name="keywords">
"""],
@@ -58,7 +58,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="An amusing story" lang="en" name="description">
<pending>
@@ -66,7 +66,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="Un histoire amusant" lang="fr" name="description">
"""],
@@ -81,7 +81,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
"""],
@@ -97,7 +97,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content over multiple lines" name="name">
"""],
@@ -116,7 +116,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
"""],
@@ -169,7 +169,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
<system_message level="3" line="1" source="test data" type="ERROR">
@@ -194,7 +194,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
<pending>
@@ -202,7 +202,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="name">
<system_message level="3" line="1" source="test data" type="ERROR">
@@ -239,7 +239,7 @@
.transform: docutils.transforms.components.Filter
.details:
component: 'writer'
- format: 'html'
+ format: 'html,latex,odt'
nodes:
<meta content="escaped linebreak" name="name:with:colons">
<pending>
@@ -246,8 +246,8 @@
.. internal attributes:
.transform: docutils.transforms.components.Filter
.details:
- component: \'writer\'
- format: \'html\'
+ component: 'writer'
+ format: 'html,latex,odt'
nodes:
<meta content="content" name="unescaped:embedded:colons">
"""],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-08 23:34:12
|
Revision: 8604
http://sourceforge.net/p/docutils/code/8604
Author: milde
Date: 2021-01-08 23:34:09 +0000 (Fri, 08 Jan 2021)
Log Message:
-----------
Fix/improve "odf" writer metadata handling.
Fix "keyword" splitting,
patch by Casper Meijn, https://github.com/caspermeijn/docutils/commit/af5c7718f68abfb15f5225524b42c9bd1179fce1
Allow generic fields (stored as "Custom Properties"),
based on patch #122 by pifi.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/odt.txt
trunk/docutils/docutils/writers/odf_odt/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-08 15:24:32 UTC (rev 8603)
+++ trunk/docutils/HISTORY.txt 2021-01-08 23:34:09 UTC (rev 8604)
@@ -157,6 +157,12 @@
- Fix #126 manpage title with spaces.
- Fix #380 commandline option problem in sphinx.
+* docutils/writers/odf_odt/__init__.py:
+
+ - Fix/improve metadata handling:
+ fix "keyword" splitting,
+ allow generic fields (stored as "Custom Properties").
+
* docutils/writers/pseudoxml.py:
- New option `detailled`__.
Modified: trunk/docutils/docs/user/odt.txt
===================================================================
--- trunk/docutils/docs/user/odt.txt 2021-01-08 15:24:32 UTC (rev 8603)
+++ trunk/docutils/docs/user/odt.txt 2021-01-08 23:34:09 UTC (rev 8604)
@@ -90,7 +90,7 @@
The following command line options are specific to ``odtwriter``:
---stylesheet=<URL> Specify a stylesheet URL, used verbatim.
+--stylesheet=<URL> Specify a stylesheet URL, used verbatim.
Default: writers/odf_odt/styles.odt in the
installation directory.
--odf-config-file=<file>
@@ -147,8 +147,8 @@
`Custom header/footers: inserting page numbers, date, time, etc`_
for details
-
+
Styles and Classes
==================
@@ -157,7 +157,7 @@
describes those styles.
Note that with the ``--stylesheet`` command line option, you can
-use either ``styles.odt`` or ``styles.xml``, as described below.
+use either ``styles.odt`` or ``styles.xml``, as described below.
Use of ``styles.odt`` is recommended over ``styles.xml``.
You can modify the look of documents generated by ``odtwriter`` in
@@ -497,7 +497,7 @@
~~~~~~~~~~~~
A table style is generated by ``oowriter`` for each table that you
-create. Therefore, ``odtwriter`` attempts to do something similar.
+create. Therefore, ``odtwriter`` attempts to do something similar.
These styles are created in the ``content.xml`` document in the
generated ``.odt`` file. These styles have names prefixed with
"rststyle-table-".
@@ -514,7 +514,7 @@
apply different styles to different tables within the same document
by customizing and using tables in your stylesheet: ``styles.odt``
or whatever you name your copy of it using the --stylesheet command
-line option. Then, follow these rules to apply a table style to
+line option. Then, follow these rules to apply a table style to
the tables in your document:
- The default table style -- Optionally, alter and customize the
@@ -541,7 +541,7 @@
do not specify a style with the ".. class::" directive.
Customize the table properties in ``oowriter`` using the table
-properties dialog for the table (style) that you wish to customize.
+properties dialog for the table (style) that you wish to customize.
Note that "--table-border-thickness" command line option overrides
the border thickness specified in the stylesheet.
@@ -605,7 +605,7 @@
rststyle-citation
The style for citations. This style affects the citation
- content, *not* the citation reference in the body of the document.
+ content, *not* the citation reference in the body of the document.
You might need to adjust the indentation in this style
depending on the length of the label used in your citations.
@@ -714,7 +714,7 @@
1. Create a configuration file containing a "Formats" section. The
configuration file obeys the file format supported by the Python
- ConfigParser module:
+ ConfigParser module:
`ConfigParser -- Configuration file parser --
http://docs.python.org/lib/module-ConfigParser.html
<http://docs.python.org/lib/module-ConfigParser.html>`_.
@@ -754,7 +754,7 @@
control of the generation of ODF content:
- Class ``wrap`` -- Use this to cause the wrapping of text around
- an image. The default is *not* to wrap text around images.
+ an image. The default is *not* to wrap text around images.
Here is an example::
.. class:: wrap
@@ -778,7 +778,7 @@
In order to use this capability, do the following:
- Define the character style for your custom role in a stylesheet
- (a copy of ``styles.odt``) with the prefix "rststyle-".
+ (a copy of ``styles.odt``) with the prefix "rststyle-".
Remember: (1) If the name of your custom role is "pretty", then
define a character style named "rststyle-pretty". (2) Define the
style as a *character* style, and *not*, for example as a
@@ -817,7 +817,7 @@
The ``..contents::`` directive causes ``odtwriter`` to generate
either:
-1. A static, outline style table of contents, if the
+1. A static, outline style table of contents, if the
``--generate-list-toc`` command line option is specified, or
2. An ODF/``oowriter`` style table of contents containing
@@ -929,7 +929,7 @@
Line 2 of container.
More information on how to define a new style (for example, in your
-``styles.odt``) can be found in section
+``styles.odt``) can be found in section
`Defining and using custom style names`_.
@@ -960,7 +960,7 @@
Footnotes and citations are supported.
There are additional styles ``rststyle-footnote`` and
-``rststyle-citation`` for footnotes and citations. See
+``rststyle-citation`` for footnotes and citations. See
`Footnote and citation styles`_.
You may need to modify the citation style to fit the length of your
@@ -1027,17 +1027,21 @@
The meta directive
------------------
-``odtwriter`` supports the ``meta`` directive. Two fields are
-recognized: "keywords" and "description". Here is an example::
+``odtwriter`` supports the ``meta`` directive. "keywords"
+and "description" are set in their respective odt fields.
+Other meta fields are set as "Custom Properties".
+Here is an example::
.. meta::
:keywords: reStructuredText, docutils, formatting
:description lang=en: A reST document, contains formatted
text in a formatted style.
+ :custom_var: Value
To see the results of the ``meta`` directive in ``oowriter``,
select menu item "File/Properties...", then click on the
-"Description" tab.
+"Description" tab ("keywords" and "description" fields) and the
+"Custom Properties" tab.
Footnote references inside footnotes
@@ -1064,8 +1068,8 @@
the default page size for your locale. In order for this to work,
the following conditions must be met:
-1. The program ``paperconf`` must be available on your system.
- ``odtwriter`` uses ``paperconf -s`` to obtain the paper size.
+1. The program ``paperconf`` must be available on your system.
+ ``odtwriter`` uses ``paperconf -s`` to obtain the paper size.
See ``man paperconf`` for more information.
2. The default page height and width must be removed from the
@@ -1188,6 +1192,3 @@
.. _`OASIS Open Document Format for Office Applications (OpenDocument) TC`:
http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office
-
-
-
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2021-01-08 15:24:32 UTC (rev 8603)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2021-01-08 23:34:09 UTC (rev 8604)
@@ -328,23 +328,6 @@
return ascii
-WORD_SPLIT_PAT1 = re.compile(r'\b(\w*)\b\W*')
-
-
-def split_words(line):
- # We need whitespace at the end of the string for our regexpr.
- line += ' '
- words = []
- pos1 = 0
- mo = WORD_SPLIT_PAT1.search(line, pos1)
- while mo is not None:
- word = mo.groups()[0]
- words.append(word)
- pos1 = mo.end()
- mo = WORD_SPLIT_PAT1.search(line, pos1)
- return words
-
-
#
# Classes
#
@@ -808,17 +791,24 @@
el1.text = title
else:
el1.text = '[no title]'
- meta_dict = self.visitor.get_meta_dict()
- keywordstr = meta_dict.get('keywords')
- if keywordstr is not None:
- keywords = split_words(keywordstr)
- for keyword in keywords:
- el1 = SubElement(root, 'meta:keyword', nsdict=METNSD)
- el1.text = keyword
- description = meta_dict.get('description')
- if description is not None:
- el1 = SubElement(root, 'dc:description', nsdict=METNSD)
- el1.text = description
+ for prop, value in self.visitor.get_meta_dict().items():
+ # 'keywords', 'description', and 'subject' have their own fields:
+ if prop == 'keywords':
+ keywords = re.split(', *', value)
+ for keyword in keywords:
+ el1 = SubElement(root, 'meta:keyword', nsdict=METNSD)
+ el1.text = keyword
+ elif prop == 'description':
+ el1 = SubElement(root, 'dc:description', nsdict=METNSD)
+ el1.text = value
+ # TODO: handle "subject" (which element is it?)
+ ## elif prop == 'subject':
+ ## el1 = SubElement(root, 'xxxxxxxx', nsdict=METNSD)
+ ## el1.text = value
+ else: # Store remaining properties as custom/user-defined
+ el1 = SubElement(root, 'meta:user-defined',
+ attrib={'meta:name': prop}, nsdict=METNSD)
+ el1.text = value
s1 = ToString(doc)
#doc = minidom.parseString(s1)
#s1 = doc.toprettyxml(' ')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-11 11:07:34
|
Revision: 8606
http://sourceforge.net/p/docutils/code/8606
Author: milde
Date: 2021-01-11 11:07:31 +0000 (Mon, 11 Jan 2021)
Log Message:
-----------
Support the "meta" directive in LaTeX.
Set PDF document properties from "meta" directive content
using "hyperref" options.
Also set "pdflang" if the document language is not "en".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/dev/todo.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/cyrillic.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/xetex-cyrillic.tex
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/HISTORY.txt 2021-01-11 11:07:31 UTC (rev 8606)
@@ -149,6 +149,8 @@
- Do not write Docutils-generated ToC, when ``use_latex_toc``
is True. (This did happen when publishing from a doctree.)
+
+ - Set PDF document properties from "meta" directive content.
* docutils/writers/manpage.py
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/docs/dev/todo.txt 2021-01-11 11:07:31 UTC (rev 8606)
@@ -210,7 +210,23 @@
* Perhaps the ``Component.supports`` method should deal with
individual features ("meta" etc.) instead of formats ("html" etc.)?
+ Currently, only the `<meta> node`_ requires the framework.
+
+ Do we need it at all? Or rather let the writers just ignore some
+ nodes (like we already do for "class" values)?
+
+ The current implementation of the framework also leads to bug
+ `bug #241`__ "doctree-based publishing != publish_string".
+ The "components.Filter" transform is run by publish_doctree(). When
+ filtering based on the output format, it should be run by
+ publish_from_doctree() instead because only then the writer is
+ known.
+
+ So we need to either remove or fix the framework.
+
+ __ https://sourceforge.net/p/docutils/bugs/241/
+
* Think about _`large documents` made up of multiple subdocument
files. Issues: continuity (`persistent sequences`_ above),
cross-references (`name-to-id mapping file`_ above and `targets in
@@ -608,7 +624,19 @@
<http://www.loria.fr/~rougier/coding/article/rst2html.py>`__
by Nicolas Rougier for a sample implementation.
+<meta> node
+-----------
+Up to 0.17, <meta> nodes are non-standard (not part of the Docutils
+document tree specification).
+
+The "Filter" transform removes "meta" nodes from the doctree unless the
+output format is "html" (rsp. "html", "latex", or "odt" since 0.17).
+
+Suggestion:
+ Make "meta" a generic directive and <meta> nodes standard nodes that
+ are kept in the doctree. Allow writers to ignore <meta> nodes.
+
Documentation
=============
@@ -2692,14 +2720,6 @@
a figure in LaTeX is 100 % of the text width, setting the 'align'
argument has currently no effect on the LaTeX output.
-
-* Let `meta` directive insert PDF-keywords into header?
-
- See https://tex.stackexchange.com/questions/26529/how-can-i-generate-pdf-metadata-from-latex#26530
- https://tex.stackexchange.com/questions/161094/adding-custom-metadata-values-to-a-pdf-file
-
-
-
* Multiple author entries in docinfo (same thing as in html).
* Consider supporting the "compact" option and class argument (from
@@ -2834,7 +2854,12 @@
* What about if we don't know which Reader and/or Writer we are
going to use? If the Reader/Writer is specified on the
- command-line? (Will this ever happen?)
+ command-line?
+
+ The dynamic_ front end ``tools/docutils-cli.py`` (new in 0.17) is an
+ implementation of concept d) below. It uses 2-stage argument parsing
+ via the `argparse` module's `partial parsing`_. It still needs some
+ polishing.
Perhaps have different types of front ends:
@@ -2856,7 +2881,7 @@
probably only useful for testing purposes.
d) _`Dynamic`: Reader and/or Writer are specified by options, with
- defaults if unspecified (e.g. ``publish --writer pdf
+ defaults if unspecified (e.g. ``publish --writer manpage
[options]``).
Allow common options before subcommands, as in CVS? Or group all
@@ -2876,11 +2901,6 @@
directive should override the ``--no-section-numbering`` command
line option then.
-The dynamic_ front end ``tools/docutils-frontend.py`` (new in 0.17) is an
-implementation of concept c). It uses 2-stage argument parsing
-via the "new" `argparse` module supports `partial parsing`_.
-It still needs some polishing and a better name.
-
.. _partial parsing:
https://docs.python.org/3/library/argparse.html#partial-parsing
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2021-01-11 11:07:31 UTC (rev 8606)
@@ -1190,9 +1190,10 @@
self.date = []
# PDF properties: pdftitle, pdfauthor
- # TODO?: pdfcreator, pdfproducer, pdfsubject, pdfkeywords
+ self.pdfauthor = []
self.pdfinfo = []
- self.pdfauthor = []
+ if settings.language_code != 'en':
+ self.pdfinfo.append(' pdflang={%s},'%settings.language_code)
# Stack of section counters so that we don't have to use_latex_toc.
# This will grow and shrink as processing occurs.
@@ -2542,8 +2543,18 @@
self.duclass_close(node)
def visit_meta(self, node):
- # TODO: set keywords for pdf or write info for dropped content?
- pass
+ name = node.attributes.get('name')
+ content = node.attributes.get('content')
+ if not name or not content:
+ return
+ if name in ('author', 'creator', 'keywords', 'subject', 'title'):
+ # fields with dedicated hyperref options:
+ self.pdfinfo.append(' pdf%s={%s},'%(name, content))
+ elif name == 'producer':
+ self.pdfinfo.append(' addtopdfproducer={%s},'%content)
+ else:
+ # generic interface (case sensitive!)
+ self.pdfinfo.append(' pdfinfo={%s={%s}},'%(name, content))
def depart_meta(self, node):
pass
Modified: trunk/docutils/test/functional/expected/cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/cyrillic.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/cyrillic.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -27,6 +27,9 @@
\usepackage{bookmark}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
+\hypersetup{
+ pdflang={ru},
+}
%%% Body
\begin{document}
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -186,6 +186,8 @@
}{}
\hypersetup{
pdftitle={reStructuredText Test Document},
+ pdfkeywords={reStructuredText, test, parser},
+ pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
pdfauthor={David Goodger;Me;Myself;I}
}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -187,6 +187,8 @@
}{}
\hypersetup{
pdftitle={reStructuredText Test Document},
+ pdfkeywords={reStructuredText, test, parser},
+ pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
pdfauthor={David Goodger;Me;Myself;I}
}
Modified: trunk/docutils/test/functional/expected/xetex-cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2021-01-11 11:07:17 UTC (rev 8605)
+++ trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2021-01-11 11:07:31 UTC (rev 8606)
@@ -32,6 +32,9 @@
\usepackage{bookmark}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
+\hypersetup{
+ pdflang={ru},
+}
%%% Body
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-26 23:38:42
|
Revision: 8607
http://sourceforge.net/p/docutils/code/8607
Author: milde
Date: 2021-01-26 23:38:39 +0000 (Tue, 26 Jan 2021)
Log Message:
-----------
Revert "html5 writer: wrap image elements in <p> unless inline or in figure."
This wrapper is not required as we can set the display to "block" with CSS.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-11 11:07:31 UTC (rev 8606)
+++ trunk/docutils/HISTORY.txt 2021-01-26 23:38:39 UTC (rev 8607)
@@ -104,8 +104,7 @@
Use <ins> and <del> if a matching class value
is found in `inline`, `literal`, or `container` elements.
- - Wrap block-level image elements in <p> (except for figures).
- Move non-essential styling from ``minimal.css`` to ``plain.css``.
+ - Move non-essential styling from ``minimal.css`` to ``plain.css``.
Support numbered figures in ``plain.css``.
- Fix bug #398: properly close link tag to "schema.dcterms".
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2021-01-11 11:07:31 UTC (rev 8606)
+++ trunk/docutils/docutils/writers/_html_base.py 2021-01-26 23:38:39 UTC (rev 8607)
@@ -950,13 +950,13 @@
del atts[att_name]
if style:
atts['style'] = ' '.join(style)
- if isinstance(node.parent, (nodes.figure, nodes.compound)):
+ if (isinstance(node.parent, nodes.TextElement) or
+ (isinstance(node.parent, nodes.reference) and
+ not isinstance(node.parent.parent, nodes.TextElement))):
+ # Inline context or surrounded by <a>...</a>.
+ suffix = ''
+ else:
suffix = '\n'
- elif not isinstance(node.parent, (nodes.TextElement, nodes.reference)):
- self.body.append('<p class="image-wrapper">')
- suffix = '</p>\n'
- else:
- suffix = ''
if 'align' in node:
atts['class'] = 'align-%s' % node['align']
# Embed image file (embedded SVG or data URI):
@@ -1343,15 +1343,12 @@
atts['class'] += ' image-reference'
if not isinstance(node.parent, nodes.TextElement):
assert len(node) == 1 and isinstance(node[0], nodes.image)
- if not isinstance(node.parent, (nodes.figure, nodes.compound)):
- self.body.append('<p class="image-wrapper">')
+ atts['class'] += ' image-reference'
self.body.append(self.starttag(node, 'a', '', **atts))
def depart_reference(self, node):
self.body.append('</a>')
if not isinstance(node.parent, nodes.TextElement):
- if not isinstance(node.parent, (nodes.figure, nodes.compound)):
- self.body.append('</p>')
self.body.append('\n')
self.in_mailto = False
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2021-01-11 11:07:31 UTC (rev 8606)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2021-01-26 23:38:39 UTC (rev 8607)
@@ -17,7 +17,6 @@
import os.path
import re
import sys
-
import docutils
from docutils import frontend, nodes, writers, io
from docutils.transforms import writer_aux
@@ -538,13 +537,13 @@
def visit_generated(self, node):
pass
- # Image types to place in an <object> element
+ # Use <object> instead of <img> for some image types:
+
# SVG not supported by IE up to version 8
# (html4css1 strives for IE6 compatibility)
object_image_types = {'.svg': 'image/svg+xml',
'.swf': 'application/x-shockwave-flash'}
- # do not wrap block-level images in <p></p> (for backwards compatibility)
def visit_image(self, node):
atts = {}
uri = node['uri']
@@ -747,32 +746,6 @@
def depart_paragraph(self, node):
self.body.append(self.context.pop())
- # do not wrap images in paragraphs (for backwards compatibility)
- def visit_reference(self, node):
- atts = {'class': 'reference'}
- if 'refuri' in node:
- atts['href'] = node['refuri']
- if ( self.settings.cloak_email_addresses
- and atts['href'].startswith('mailto:')):
- atts['href'] = self.cloak_mailto(atts['href'])
- self.in_mailto = True
- atts['class'] += ' external'
- else:
- assert 'refid' in node, \
- 'References must have "refuri" or "refid" attribute.'
- atts['href'] = '#' + node['refid']
- atts['class'] += ' internal'
- if not isinstance(node.parent, nodes.TextElement):
- assert len(node) == 1 and isinstance(node[0], nodes.image)
- atts['class'] += ' image-reference'
- self.body.append(self.starttag(node, 'a', '', **atts))
-
- def depart_reference(self, node):
- self.body.append('</a>')
- if not isinstance(node.parent, nodes.TextElement):
- self.body.append('\n')
- self.in_mailto = False
-
# ersatz for first/last pseudo-classes
def visit_sidebar(self, node):
self.body.append(
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2021-01-11 11:07:31 UTC (rev 8606)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2021-01-26 23:38:39 UTC (rev 8607)
@@ -1378,7 +1378,7 @@
<div class="footer">
<hr class="footer" />
<p>Document footer</p>
-<p><a class="reference external" href="http://validator.w3.org/check?uri=referer"><img alt="Valid XHTML 1.0!" src="http://www.w3.org/Icons/valid-xhtml10" style="width: 88px; height: 31px;" /></a> <a class="reference external" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
+<p><a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Valid XHTML 1.0!" src="http://www.w3.org/Icons/valid-xhtml10" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
</div>
</body>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2021-01-11 11:07:31 UTC (rev 8606)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2021-01-26 23:38:39 UTC (rev 8607)
@@ -570,18 +570,18 @@
<section id="images-and-figures">
<h4><a class="toc-backref" href="#toc-entry-56"><span class="sectnum">2.14.2</span> Images and Figures</a></h4>
<p>An image directive (also clickable -- a hyperlink reference):</p>
-<p class="image-wrapper"><a class="reference internal image-reference" href="#directives"><img alt="../../../docs/user/rst/images/title.png" class="class1 class2" src="../../../docs/user/rst/images/title.png" /></a></p>
+<a class="reference internal image-reference" href="#directives"><img alt="../../../docs/user/rst/images/title.png" class="class1 class2" src="../../../docs/user/rst/images/title.png" /></a>
<p>Image with multiple IDs:</p>
-<p class="image-wrapper"><span id="image-target-2"></span><span id="image-target-1"></span><img alt="../../../docs/user/rst/images/title.png" id="image-target-3" src="../../../docs/user/rst/images/title.png" /></p>
+<span id="image-target-2"></span><span id="image-target-1"></span><img alt="../../../docs/user/rst/images/title.png" id="image-target-3" src="../../../docs/user/rst/images/title.png" />
<p>A centered image:</p>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" class="align-center" src="../../../docs/user/rst/images/biohazard.png" /></p>
+<img alt="../../../docs/user/rst/images/biohazard.png" class="align-center" src="../../../docs/user/rst/images/biohazard.png" />
<p>A left-aligned image:</p>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" class="align-left" src="../../../docs/user/rst/images/biohazard.png" /></p>
+<img alt="../../../docs/user/rst/images/biohazard.png" class="align-left" src="../../../docs/user/rst/images/biohazard.png" />
<p>This paragraph might flow around the image.
The specific behavior depends upon the style sheet and
the browser or rendering software used.</p>
<p>A right-aligned image:</p>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" class="align-right" src="../../../docs/user/rst/images/biohazard.png" /></p>
+<img alt="../../../docs/user/rst/images/biohazard.png" class="align-right" src="../../../docs/user/rst/images/biohazard.png" />
<p>This paragraph might flow around the image.
The specific behavior depends upon the style sheet and
the browser or rendering software used.</p>
@@ -588,13 +588,13 @@
<p>For inline images see <a class="reference internal" href="#substitution-definitions">Substitution Definitions</a>.</p>
<p>Image size:</p>
<p>An image 2 em wide:</p>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em;" /></p>
+<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em;" />
<p>An image 2 em wide and 15 pixel high:</p>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em; height: 15px;" /></p>
+<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="width: 2em; height: 15px;" />
<p>An image occupying 50% of the line width:</p>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/title.png" src="../../../docs/user/rst/images/title.png" style="width: 50%;" /></p>
+<img alt="../../../docs/user/rst/images/title.png" src="../../../docs/user/rst/images/title.png" style="width: 50%;" />
<p>An image 2 cm high:</p>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="height: 2cm;" /></p>
+<img alt="../../../docs/user/rst/images/biohazard.png" src="../../../docs/user/rst/images/biohazard.png" style="height: 2cm;" />
<p>A <em>figure</em> is an image with a caption and/or a legend. With page-based output
media, figures might float to a different position if this helps the page
layout.</p>
@@ -1244,7 +1244,7 @@
<h2><a class="toc-backref" href="#toc-entry-42"><span class="sectnum">3</span> HTML specific</a></h2>
<section id="svg-images">
<h3><a class="toc-backref" href="#toc-entry-43"><span class="sectnum">3.1</span> SVG Images</a></h3>
-<p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.svg" class="align-left" src="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" /></p>
+<img alt="../../../docs/user/rst/images/biohazard.svg" class="align-left" src="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" />
<p>Scalable vector graphics (SVG) images are the only standards-compliable way
to include vector graphics in HTML documents. However, they are not
supported by all backends/output formats. (E.g., LaTeX supports the
@@ -1279,30 +1279,30 @@
SVG image is scaled or clipped/padded. Images wrapped in <span class="docutils literal"><img></span> are
always scaled.</p>
<ul>
-<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" /></p>
+<li><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%;" />
<p>A scaling image (scales with the browser window), occupying 50% of the line
width. The <span class="docutils literal">viewBox</span> setting in the image file enables auto-scaling also in
<span class="docutils literal"><object></span> tags and embedded SVG (if width and hight are set to 100% in the
SVG <image> tag).</p>
</li>
-<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/title.svg" class="align-right" src="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" /></p>
+<li><img alt="../../../docs/user/rst/images/title.svg" class="align-right" src="../../../docs/user/rst/images/title.svg" style="width: 50%; height: 15px;" />
<p>A fixed-size image in a box 50% wide and 15 pixles high. This image is
scaled, if wrapped in an <span class="docutils literal"><img></span> tag but clipped in an <span class="docutils literal"><object></span> tag
or within SVG.</p>
</li>
-<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 1.5em;" /></p>
+<li><img alt="../../../docs/user/rst/images/title-scaling.svg" class="align-right" src="../../../docs/user/rst/images/title-scaling.svg" style="width: 50%; height: 1.5em;" />
<p>A right aligned, scaling image 50% wide and 1.5 em high. (This SVG image
keeps the aspect ratio.)</p>
</li>
<li><p>An inline image <img alt="inline-svg" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 0.8em;" /> scaled to a height of 0.8 em.</p>
</li>
-<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" /></p>
+<li><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="height: 1em;" />
<p>A scaling image 1 em high, right aligned:</p>
</li>
<li><p>A scaling image 5 mm x 5 mm, centered, with hyperlink reference:</p>
-<p class="image-wrapper"><a class="reference internal image-reference" href="#svg-images"><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-center" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="width: 5mm; height: 5mm;" /></a></p>
+<a class="reference internal image-reference" href="#svg-images"><img alt="../../../docs/user/rst/images/biohazard-scaling.svg" class="align-center" src="../../../docs/user/rst/images/biohazard-scaling.svg" style="width: 5mm; height: 5mm;" /></a>
</li>
-<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard.svg" class="align-right" src="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" /></p>
+<li><img alt="../../../docs/user/rst/images/biohazard.svg" class="align-right" src="../../../docs/user/rst/images/biohazard.svg" style="width: 4cm; height: 2em;" />
<p>A fixed-size image in a 4 cm x 2 em box.</p>
</li>
</ul>
@@ -1310,12 +1310,12 @@
konqueror) support the <span class="docutils literal"><img></span> tag but don't display contained bitmap
images in this case.</p>
<ul>
-<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard-bitmap.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap.svg" style="width: 3em;" /></p>
+<li><img alt="../../../docs/user/rst/images/biohazard-bitmap.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap.svg" style="width: 3em;" />
<p>A small, fixed-size SVG image with embedded bitmap, The <span class="docutils literal">:width:</span> is
set to 3 em in the rST source. Does not scale if wrapped in <span class="docutils literal"><object></span>
tags.</p>
</li>
-<li><p class="image-wrapper"><img alt="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" style="width: 3em;" /></p>
+<li><img alt="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" class="align-right" src="../../../docs/user/rst/images/biohazard-bitmap-scaling.svg" style="width: 3em;" />
<p>A scaling SVG image with embedded bitmap, 3 em wide.</p>
</li>
</ul>
@@ -1336,7 +1336,7 @@
concerns.</p>
<p>Images with extension <span class="docutils literal">.swf</span> are placed inside <object> elements.
For complete control over display options use raw HTML.</p>
-<p class="image-wrapper"><object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash">[biohazard.swf]</object></p>
+<object class="align-left" data="../../../docs/user/rst/images/biohazard.swf" style="width: 4cm; height: 2em;" type="application/x-shockwave-flash">[biohazard.swf]</object>
<p>An SWF image in a 4 cm x 2 em box, left aligned.</p>
<p>An inline SWF image <object data="../../../docs/user/rst/images/biohazard.swf" style="width: 0.8em; height: 0.8em;" type="application/x-shockwave-flash">inline-swf</object> scaled to 0.8 em x 0.8 em.</p>
</section>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-01-26 23:39:06
|
Revision: 8609
http://sourceforge.net/p/docutils/code/8609
Author: milde
Date: 2021-01-26 23:39:02 +0000 (Tue, 26 Jan 2021)
Log Message:
-----------
Support "captionbelow" class value for tables in HTML5.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/writers/html5_polyglot/minimal.css
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-01-26 23:38:51 UTC (rev 8608)
+++ trunk/docutils/HISTORY.txt 2021-01-26 23:39:02 UTC (rev 8609)
@@ -106,6 +106,7 @@
- Move non-essential styling from ``minimal.css`` to ``plain.css``.
Support numbered figures in ``plain.css``.
+ Support "captionbelow" class value for tables in ``minimal.css``.
- Fix bug #398: properly close link tag to "schema.dcterms".
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2021-01-26 23:38:51 UTC (rev 8608)
+++ trunk/docutils/docs/user/config.txt 2021-01-26 23:39:02 UTC (rev 8609)
@@ -1189,21 +1189,24 @@
The default CSS sylesheet defines:
-borderless
- No borders around the table.
+ borderless
+ No borders around the table.
+
+ booktabs
+ Lines above and below the table and a thin line after the head.
+
+ align-left, align-center, align-right
+ Align the tables
+
+ colwidths-auto
+ Delegate the determination of table column widths to the backend
+ (leave out the ``<colgroup>`` column specification).
+ See also the "widths" option of the `table directive`_.
+
+ captionbelow
+ Place the table caption below the table
+ (only with the `HTML5 writer`_, new in 0.17).
-booktabs
- Lines above and below the table and a thin line after the head.
-
-align-left, align-center, align-right
- Align the tables
-
-colwidths-auto
- Delegate the determination of table column widths to the backend
- (Leave out the ``<colgroup>`` column specification.)
-
- Cf. the `table directive`_.
-
Default: "". Option: ``--table-style``.
.. _table directive: ../ref/rst/directives.html#table
Modified: trunk/docutils/docutils/writers/html5_polyglot/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2021-01-26 23:38:51 UTC (rev 8608)
+++ trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2021-01-26 23:39:02 UTC (rev 8609)
@@ -43,7 +43,7 @@
h2 + p.section-subtitle {
font-size: 1.6em;
}
-h3 + p.section-subtitle {
+h3 + p.section-subtitle {
font-size: 1.28em;
}
p.subtitle,
@@ -247,8 +247,12 @@
table > caption {
text-align: left;
- margin-bottom: 0.25em
+ margin-top: 0.2em;
+ margin-bottom: 0.2em;
}
+table.captionbelow {
+ caption-side: bottom;
+}
table.borderless td, table.borderless th {
border: 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-02-13 12:00:23
|
Revision: 8621
http://sourceforge.net/p/docutils/code/8621
Author: milde
Date: 2021-02-13 12:00:20 +0000 (Sat, 13 Feb 2021)
Log Message:
-----------
Small fixes and tweaks in the "minimal" HTML5 style sheet.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/html5_polyglot/minimal.css
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-02-13 12:00:01 UTC (rev 8620)
+++ trunk/docutils/HISTORY.txt 2021-02-13 12:00:20 UTC (rev 8621)
@@ -106,10 +106,13 @@
Use <ins> and <del> if a matching class value
is found in `inline`, `literal`, or `container` elements.
- - Move non-essential styling from ``minimal.css`` to ``plain.css``.
- Support numbered figures in ``plain.css``.
- Support "captionbelow" class value for tables in ``minimal.css``.
+ - ``minimal.css``:
+ Move non-essential styling from to ``plain.css``.
+ Support "captionbelow" class value for tables.
+ Small fixes and tweaks.
+ ``plain.css``: Support numbered figures.
+
- Fix bug #398: properly close link tag to "schema.dcterms".
* docutils/writers/latex2e/__init__.py:
Modified: trunk/docutils/docutils/writers/html5_polyglot/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2021-02-13 12:00:01 UTC (rev 8620)
+++ trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2021-02-13 12:00:20 UTC (rev 8621)
@@ -29,7 +29,8 @@
.align-bottom { vertical-align: bottom; }
/* titles */
-h1.title, p.subtitle {
+h1.title,
+p.subtitle {
text-align: center;
}
p.topic-title,
@@ -39,12 +40,12 @@
p.system-message-title {
font-weight: bold;
}
-h1 + p.subtitle,
-h2 + p.section-subtitle {
+h1 + p.subtitle {
font-size: 1.6em;
}
-h3 + p.section-subtitle {
- font-size: 1.28em;
+h2 + p.section-subtitle,
+p.sidebar-title {
+ font-size: 1.2em;
}
p.subtitle,
p.section-subtitle,
@@ -52,9 +53,6 @@
font-weight: bold;
margin-top: -0.5em;
}
-p.sidebar-title {
- font-size: larger;
-}
p.rubric {
font-size: larger;
color: maroon;
@@ -146,7 +144,10 @@
}
/* Bibliographic Fields (docinfo) */
-pre.address { font: inherit; }
+pre.address {
+ font: inherit;
+ margin: 0.5em 0;
+}
dd.authors > p { margin: 0; }
/* Option Lists */
@@ -157,7 +158,7 @@
/* Footnotes and Citations */
dl.footnote.superscript > dd {margin-left: 1em; }
dl.footnote.brackets > dd {margin-left: 2em; }
-dl > dt.label { font-weight: normal; }
+dl.footnote > dt { font-weight: normal; }
a.footnote-reference.brackets:before,
dt.label > span.brackets:before { content: "["; }
a.footnote-reference.brackets:after,
@@ -165,19 +166,11 @@
a.footnote-reference.superscript,
dl.footnote.superscript > dt.label {
vertical-align: super;
- font-size: smaller;
+ font-size: small;
}
dt.label > span.fn-backref { margin-left: 0.2em; }
dt.label > span.fn-backref > a { font-style: italic; }
-/* Line Blocks */
-div.line-block { display: block; }
-div.line-block div.line-block {
- margin-top: 0;
- margin-bottom: 0;
- margin-left: 40px;
-}
-
/* Figures, Images, and Tables */
.figure.align-left,
figure.align-left,
@@ -224,16 +217,18 @@
blockquote,
div.topic,
div.admonition,
-div.system-message,
-pre.literal-block,
-pre.doctest-block,
-pre.math,
-pre.code {
- margin-left: 1.5em;
- margin-right: 1.5em;
+div.system-message {
+ margin-left: 2em;
+ margin-right: 2em;
}
+div.line-block { display: block; }
+div.line-block div.line-block {
+ margin: 0 0 0 2em;
+}
+pre { margin-left: 2em; }
pre.code .ln { color: gray; } /* line numbers */
+
/* Tables */
table { border-collapse: collapse; }
td, th {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-02-13 12:01:01
|
Revision: 8623
http://sourceforge.net/p/docutils/code/8623
Author: milde
Date: 2021-02-13 12:00:58 +0000 (Sat, 13 Feb 2021)
Log Message:
-----------
Update planned changes for HTML5 writer.
Modified Paths:
--------------
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/writers/_html_base.py
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2021-02-13 12:00:39 UTC (rev 8622)
+++ trunk/docutils/RELEASE-NOTES.txt 2021-02-13 12:00:58 UTC (rev 8623)
@@ -26,7 +26,9 @@
and/or ``\DUtitle`` or set to "True".
* `html5` writer:
- Use <blockquote> instead of <div> tags for topics and admonitions.
+ Use <blockquote> instead of <div> tags for topics and admonitions,
+ <aside> instad of <dl> for footnote text and citations,
+ and <nav> instead of <div> for the Table of Contents.
Use <summary> and <details> tags for term and definition of a
definition list with class value "details".
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2021-02-13 12:00:39 UTC (rev 8622)
+++ trunk/docutils/docutils/writers/_html_base.py 2021-02-13 12:00:58 UTC (rev 8623)
@@ -543,6 +543,7 @@
def visit_citation(self, node):
# Use definition list for bibliographic references.
# Join adjacent citation entries.
+ # TODO: use <aside>.
if not self.in_footnote_list:
listnode = node.copy()
listnode['ids'] = []
@@ -855,7 +856,9 @@
self.body_suffix[:0] = footer
del self.body[start:]
- # TODO: use the new HTML5 element <aside>? (Also for footnote text)
+ # TODO: use the new HTML5 element <aside> for footnote text
+ # (allows better styling with CSS, the current <dl> list styling
+ # with "float" interferes with sidebars).
def visit_footnote(self, node):
if not self.in_footnote_list:
listnode = node.copy()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-02-18 23:09:31
|
Revision: 8625
http://sourceforge.net/p/docutils/code/8625
Author: milde
Date: 2021-02-18 23:09:23 +0000 (Thu, 18 Feb 2021)
Log Message:
-----------
Small documentation update.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/html.txt
trunk/docutils/docs/user/latex.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-02-13 12:01:10 UTC (rev 8624)
+++ trunk/docutils/HISTORY.txt 2021-02-18 23:09:23 UTC (rev 8625)
@@ -46,10 +46,10 @@
* docutils/nodes.py
- - Apply patch #165: Fix error when copying `system_message` node
- (by Takeshi KOMIYA).
- - Apply version of patch #167: Let document.set_id() register all
- existing IDs (thanks to Takeshi KOMIYA).
+ - Apply patch #165 "Fix error when copying `system_message` node"
+ by Takeshi KOMIYA.
+ - Apply version of patch #167 "Let document.set_id() register all
+ existing IDs" (thanks to Takeshi KOMIYA).
- Fix bug #410: Use a "property" function to recursively fetch
`Node.document` value from parent node.
@@ -186,8 +186,8 @@
reader, parser, and writer components.
-Release 0.16
-============
+Release 0.16 (2020-01-16)
+=========================
* General
Modified: trunk/docutils/docs/user/html.txt
===================================================================
--- trunk/docutils/docs/user/html.txt 2021-02-13 12:01:10 UTC (rev 8624)
+++ trunk/docutils/docs/user/html.txt 2021-02-18 23:09:23 UTC (rev 8625)
@@ -95,14 +95,14 @@
The ``html5_polyglot`` writer generates `polyglot HTML`_ [#]_ output, valid
XML [#safetext]_ that is compatible with `HTML5`_. New features and elements
-will only be used if they are widely supported to make documents `viewable
-with any browser`_.
+are used if they are widely supported.
-There is no hard-coded formatting information in the HTML document. Correct
-rendering of elements not directly supported by HTML depends on a CSS_ style
-sheet. The provided style sheets minimal.css_ and plain.css_ define required
-and optional styling rules respectively. Adaption of the layout is possible
-with `custom style sheets`_. [#safetext]_
+There is no hard-coded formatting information in the HTML document.
+Correct rendering of elements not directly supported by HTML depends
+on a CSS_ style sheet. The provided style sheet minimal.css_ defines
+required and styling rules, plain.css_ and responsive.css_ add
+optional rules for better legibility. Adaption of the layout is
+possible with `custom style sheets`_. [#safetext]_
New in Docutils 0.13
@@ -114,6 +114,7 @@
.. _[html5 writer]: config.html#html5-writer
.. _minimal.css: ../../docutils/writers/html5_polyglot/minimal.css
.. _plain.css: ../../docutils/writers/html5_polyglot/plain.css
+.. _responsive.css: ../../docutils/writers/html5_polyglot/responsive.css
.. _custom style sheets: ../howto/html-stylesheets.html
.. _viewable with any browser: http://www.anybrowser.org/campaign
.. _Benefits of polyglot XHTML5: http://xmlplease.com/xhtml/xhtml5polyglot/
Modified: trunk/docutils/docs/user/latex.txt
===================================================================
--- trunk/docutils/docs/user/latex.txt 2021-02-13 12:01:10 UTC (rev 8624)
+++ trunk/docutils/docs/user/latex.txt 2021-02-18 23:09:23 UTC (rev 8625)
@@ -152,7 +152,7 @@
This includes processing bibliographic references or indices, as well as
compilation or conversion of figures.
-__ https://launchpad.net/rubber/
+__ https://gitlab.com/latex-rubber/rubber/
Configuration
@@ -1967,8 +1967,7 @@
--hyperref-option=unicode
(works also with non-unicode input/output encoding (e.g. "koi8r" or
-"latin1"). Newer versions of hyperref default to "unicode=true" if the
-document language is "russian".
+"latin1"). Newer versions of hyperref default to "unicode=true".
.. _hyperref_option: config.html#stylesheet-latex-writers
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2021-02-18 23:09:47
|
Revision: 8626
http://sourceforge.net/p/docutils/code/8626
Author: milde
Date: 2021-02-18 23:09:44 +0000 (Thu, 18 Feb 2021)
Log Message:
-----------
latex-writer: add \\leavevmode after term or field name if required.
Based on patch #176 by John Thorvald Wodder II
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_cornercases.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
Added Paths:
-----------
trunk/docutils/test/functional/expected/latex_leavevmode.tex
trunk/docutils/test/functional/input/latex_leavevmode.txt
trunk/docutils/test/functional/tests/latex_leavevmode.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-02-18 23:09:23 UTC (rev 8625)
+++ trunk/docutils/HISTORY.txt 2021-02-18 23:09:44 UTC (rev 8626)
@@ -156,6 +156,9 @@
is True. (This did happen when publishing from a doctree.)
- Set PDF document properties from "meta" directive content.
+
+ - Apply version of patch #176 "LaTeX writer: Append \leavevmode to
+ non-docinfo field names" by John Thorvald Wodder II.
* docutils/writers/manpage.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2021-02-18 23:09:23 UTC (rev 8625)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2021-02-18 23:09:44 UTC (rev 8626)
@@ -1577,6 +1577,30 @@
def pop_output_collector(self):
self.out = self.out_stack.pop()
+ def term_postfix(self, node):
+ """
+ Return LaTeX code required between term or field name and content.
+
+ In a LaTeX "description" environment (used for definition
+ lists and non-docinfo field lists), a ``\\leavevmode``
+ between an item's label and content ensures the correct
+ placement of certain block constructs.
+ """
+ for child in node:
+ if not isinstance(child, (nodes.Invisible, nodes.footnote,
+ nodes.citation)):
+ break
+ else:
+ return ''
+ if isinstance(child, (nodes.image)):
+ return '\\leavevmode\n' # Images get an additional newline.
+ if isinstance(child, (nodes.container, nodes.compound)):
+ return self.term_postfix(child)
+ if not isinstance(child,
+ (nodes.paragraph, nodes.math_block)):
+ return r'\leavevmode'
+ return ''
+
# Visitor methods
# ---------------
@@ -2130,7 +2154,8 @@
pass
def visit_field_body(self, node):
- pass
+ if not isinstance(node.parent.parent, nodes.docinfo):
+ self.out.append(self.term_postfix(node))
def depart_field_body(self, node):
if self.out is self.docinfo:
@@ -2970,9 +2995,12 @@
self.out.append('\\item[{')
def depart_term(self, node):
- # \leavevmode results in a line break if the
- # term is followed by an item list.
- self.out.append('}] \\leavevmode ')
+ self.out.append('}] ')
+ # Do we need a \leavevmode (line break if the field body begins
+ # with a list or environment)?
+ next_node = node.next_node(descend=False, siblings=True)
+ if not isinstance(next_node, nodes.classifier):
+ self.out.append(self.term_postfix(next_node))
def visit_tgroup(self, node):
pass
Modified: trunk/docutils/test/functional/expected/latex_cornercases.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_cornercases.tex 2021-02-18 23:09:23 UTC (rev 8625)
+++ trunk/docutils/test/functional/expected/latex_cornercases.tex 2021-02-18 23:09:44 UTC (rev 8626)
@@ -437,7 +437,7 @@
}
\begin{description}
-\item[{definition:}] \leavevmode
+\item[{definition:}]
list
\end{description}
@@ -490,7 +490,7 @@
}
\begin{description}
-\item[{definition:}] \leavevmode
+\item[{definition:}]
list
\end{description}
Added: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex (rev 0)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex 2021-02-18 23:09:44 UTC (rev 8626)
@@ -0,0 +1,408 @@
+\documentclass[a4paper]{article}
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{cmap} % fix search and cut-and-paste in Acrobat
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{alltt}
+\usepackage{amsmath}
+\usepackage{float} % extended float configuration
+\floatplacement{figure}{H} % place figures here definitely
+\usepackage{graphicx}
+\setcounter{secnumdepth}{0}
+\usepackage{longtable,ltcaption,array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+\usepackage{tabularx}
+
+%%% Custom LaTeX preamble
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {% "#1" does not work in end-part of environment.
+ \def\DocutilsClassFunctionName{DUCLASS#1}
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+
+% Provide a length variable and set default, if it is new
+\providecommand*{\DUprovidelength}[2]{
+ \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+}
+
+% abstract title
+\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}
+
+% admonition (specially marked topic)
+\providecommand{\DUadmonition}[2][class-arg]{%
+ % try \DUadmonition#1{#2}:
+ \ifcsname DUadmonition#1\endcsname%
+ \csname DUadmonition#1\endcsname{#2}%
+ \else
+ \begin{center}
+ \fbox{\parbox{0.9\linewidth}{#2}}
+ \end{center}
+ \fi
+}
+
+% width of docinfo table
+\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
+
+% field list environment (for separate configuration of `field lists`)
+\ifthenelse{\isundefined{\DUfieldlist}}{
+ \newenvironment{DUfieldlist}%
+ {\quote\description}
+ {\enddescription\endquote}
+}{}
+
+% numerical or symbol footnotes with hyperlinks and backlinks
+\providecommand*{\DUfootnotemark}[3]{%
+ \raisebox{1em}{\hypertarget{#1}{}}%
+ \hyperlink{#2}{\textsuperscript{#3}}%
+}
+\providecommand{\DUfootnotetext}[4]{%
+ \begingroup%
+ \renewcommand{\thefootnote}{%
+ \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
+ \protect\hyperlink{#2}{#3}}%
+ \footnotetext{#4}%
+ \endgroup%
+}
+
+% custom inline roles: \DUrole{#1}{#2} tries \DUrole#1{#2}
+\providecommand*{\DUrole}[2]{%
+ \ifcsname DUrole#1\endcsname%
+ \csname DUrole#1\endcsname{#2}%
+ \else%
+ #2%
+ \fi%
+}
+
+% line block environment
+\DUprovidelength{\DUlineblockindent}{2.5em}
+\ifthenelse{\isundefined{\DUlineblock}}{
+ \newenvironment{DUlineblock}[1]{%
+ \list{}{\setlength{\partopsep}{\parskip}
+ \addtolength{\partopsep}{\baselineskip}
+ \setlength{\topsep}{0pt}
+ \setlength{\itemsep}{0.15\baselineskip}
+ \setlength{\parsep}{0pt}
+ \setlength{\leftmargin}{#1}}
+ \raggedright
+ }
+ {\endlist}
+}{}
+
+% list of command line options
+\providecommand*{\DUoptionlistlabel}[1]{\bfseries #1 \hfill}
+\DUprovidelength{\DUoptionlistindent}{3cm}
+\ifthenelse{\isundefined{\DUoptionlist}}{
+ \newenvironment{DUoptionlist}{%
+ \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
+ \setlength{\rightmargin}{1cm}
+ \setlength{\leftmargin}{\rightmargin}
+ \addtolength{\leftmargin}{\labelwidth}
+ \addtolength{\leftmargin}{\labelsep}
+ \renewcommand{\makelabel}{\DUoptionlistlabel}}
+ }
+ {\endlist}
+}{}
+
+% informal heading
+\providecommand*{\DUrubric}[1]{\subsubsection*{\emph{#1}}}
+
+% title for topics, admonitions, unsupported section levels, and sidebar
+\providecommand*{\DUtitle}[2][class-arg]{%
+ % call \DUtitle#1{#2} if it exists:
+ \ifcsname DUtitle#1\endcsname%
+ \csname DUtitle#1\endcsname{#2}%
+ \else
+ \smallskip\noindent\textbf{#2}\smallskip%
+ \fi
+}
+
+% titlereference standard role
+\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
+
+% hyperlinks:
+\ifthenelse{\isundefined{\hypersetup}}{
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage{bookmark}
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
+}{}
+\hypersetup{
+ pdftitle={Styling of Elements in Definition- or Field-List},
+ pdfauthor={Hänsel;Gretel}
+}
+
+%%% Body
+\begin{document}
+\title{Styling of Elements in Definition- or Field-List%
+ \label{styling-of-elements-in-definition-or-field-list}}
+\author{}
+\date{}
+\maketitle
+
+% Docinfo
+\begin{center}
+\begin{tabularx}{\DUdocinfowidth}{lX}
+\textbf{Author}: &
+ Hänsel \\
+\textbf{Author}: &
+ Gretel \\
+\textbf{Address}: &
+ {\raggedright
+123 Example Street\\
+Example, EX Canada } \\
+\textbf{Generic Docinfo List Field}: &
+\begin{itemize}
+\item This is a list.
+
+\item It does not require \texttt{\textbackslash{}leavevmode} because it is in the docinfo.
+\end{itemize}
+\\
+\end{tabularx}
+\end{center}
+
+\begin{DUclass}{abstract}
+\begin{quote}
+\DUtitle[abstract]{Abstract}
+
+Test that \texttt{\textbackslash{}leavevmode} is inserted after the term or field-name
+when required for correct placement of the item.
+\end{quote}
+\end{DUclass}
+
+
+\section{Elements needing \texttt{\textbackslash{}leavevmode}%
+ \label{elements-needing-leavevmode}%
+}
+
+\begin{DUfieldlist}
+\item[{Bullet List:}]\leavevmode
+\begin{itemize}
+\item This is a bullet list nested in a field list.
+
+\item It needs \texttt{\textbackslash{}leavevmode} so that it will start on a new line
+after the term.
+
+\item Without \texttt{\textbackslash{}leavevmode}, the first bullet would be on the same line as
+the term, and the following bullets would not line up.
+\end{itemize}
+
+\item[{Enumerated List:}]\leavevmode
+\begin{enumerate}
+\item This is an enumerated list.
+
+\item All lists need \texttt{\textbackslash{}leavevmode}.
+\end{enumerate}
+
+\item[{Field List:}]\leavevmode
+\begin{DUfieldlist}
+\item[{Field List:}]
+Like this one
+
+\item[{Needs \texttt{\textbackslash{}leavevmode}:}]
+Yes
+\end{DUfieldlist}
+
+\item[{empty:}]\end{DUfieldlist}
+
+\begin{description}
+\item[{Definition List}] \leavevmode
+\begin{description}
+\item[{Nested}]
+inside another definition list.
+
+\item[{Needs \texttt{\textbackslash{}leavevmode}?}] \leavevmode
+\begin{description}
+\item[{Yes.}]
+Independent of the nesting level.
+
+\end{description}
+
+\end{description}
+
+\item[{Option List}] \leavevmode
+\begin{DUoptionlist}
+\item[-h] Show help
+
+\item[-v] Be verbose
+
+\item[-{}-rare] a) This description starts with an enumeration
+c) but does not need \texttt{\textbackslash{}leavevmode}.
+\end{DUoptionlist}
+
+\item[{Literal Block}] \leavevmode
+\begin{quote}
+\begin{alltt}
+_needs_leavevmode = True
+\end{alltt}
+\end{quote}
+
+\item[{Doctest Block}] \leavevmode
+\begin{quote}
+\begin{alltt}
+>>> needs_leavevmode(nodes.doctest_block)
+True
+\end{alltt}
+\end{quote}
+
+\item[{Line Block}] \leavevmode
+\begin{DUlineblock}{0em}
+\item[] Needs “\texttt{\textbackslash{}leavevmode}”,
+\item[] so that all lines start with the same indent.
+\end{DUlineblock}
+
+\item[{Block Quote}] \leavevmode
+%
+
+\begin{quote}
+Block Quotes need “\texttt{\textbackslash{}leavevmode}”, too,
+so that all lines start with the same indent.
+\end{quote}
+
+\item[{Table}] \leavevmode
+\setlength{\DUtablewidth}{\linewidth}%
+\begin{longtable*}{|p{0.051\DUtablewidth}|p{0.051\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+
+3
+ &
+4
+ \\
+\hline
+\end{longtable*}
+
+\item[{Figure}] \leavevmode
+\begin{figure}
+\noindent\makebox[\linewidth][c]{\includegraphics{../../../docs/user/rst/images/title.png}}
+\caption{A figure}
+\end{figure}
+
+\item[{Image}] \leavevmode
+
+\includegraphics{../../../docs/user/rst/images/title.png}
+
+\item[{Rubric}] \leavevmode
+\DUrubric{A Rubric}
+
+\item[{Admonition}] \leavevmode
+\DUadmonition[note]{
+\DUtitle[note]{Note}
+
+Admonitions need to be preceded by \texttt{\textbackslash{}leavevmode}.
+Otherwise, the term ends up centered above the admonition box.
+
+So do \emph{System Messages}, as they use the “DUadmonition”
+LaTeX environment.
+}
+
+\end{description}
+
+
+\section{Elements not needing \texttt{\textbackslash{}leavevmode}%
+ \label{elements-not-needing-leavevmode}%
+}
+
+\begin{description}
+\item[{Paragraph}]
+Paragraphs don’t need \texttt{\textbackslash{}leavevmode}. They are meant
+to start after the term and have a hanging indent.
+
+\begin{itemize}
+\item Subsequent elements don’t need \texttt{\textbackslash{}leavevmode} either.
+\end{itemize}
+
+\item[{Math Block}] %
+\begin{equation*}
+\sum_{i=1}^n i = \frac{n^2+n}{2}
+\end{equation*}
+LaTeX starts math blocks (both single-line and multiline) in a new
+paragraph automatically, with or without \texttt{\textbackslash{}leavevmode}, so
+\texttt{\textbackslash{}leavevmode} isn’t needed.
+
+\item[{Term with Classifier: classifier}] \leavevmode
+\begin{itemize}
+\item After a \emph{classifier}, \texttt{\textbackslash{}leavevmode} is not required.
+
+\item This holds for all elements that normally need \texttt{\textbackslash{}leavevmode}.
+\end{itemize}
+
+\end{description}
+
+
+\section{Ambiguous cases%
+ \label{ambiguous-cases}%
+}
+
+\begin{description}
+\item[{Comment and Target}] \leavevmode
+% This is ignored.
+
+\begin{itemize}
+\item Comments and other “Invisible” nodes (substitution definitions,
+targets, pending) must be skipped when determining whether a
+\texttt{\textbackslash{}leavevmode} is required.
+\end{itemize}
+
+\item[{Substitution Definition and Class directive}]
+\DUrole{test}{Is \texttt{\textbackslash{}leavevmode} required? Answer: No (because a paragraph follows).}
+
+\item[{Compound}]
+\begin{DUclass}{compound}
+\DUroletitlereference{Compound} and \DUroletitlereference{Container} wrap around other block elements.
+They get a \texttt{\textbackslash{}leavevmode}, if the first nested element is a
+list or similar.
+\end{DUclass}
+
+\item[{Container}] \leavevmode
+\begin{DUclass}{my-class}
+
+\begin{itemize}
+\item This list inside a container requires a \texttt{\textbackslash{}leavevmode}.
+\end{itemize}
+\end{DUclass}
+
+\item[{Footnote}] %
+\DUfootnotetext{f1}{f1}{1}{\phantomsection\label{f1}%
+This footnote will move to the bottom of the page.
+}
+
+A \texttt{\textbackslash{}leavevmode} is required, if the first list item value is a
+footnote and a list or similar follows.
+
+\item[{Citation}] \leavevmode\begin{figure}[b]\raisebox{1em}{\hypertarget{example73}{}}[example73]
+No Name, “Citations move to the bottom as well”,
+Musterstadt, 1973.
+\end{figure}
+
+\begin{itemize}
+\item A \texttt{\textbackslash{}leavevmode} is required, if the first list item value is a
+citation and a list or similar follows.
+\end{itemize}
+
+\item[{Raw Block Text}] \leavevmode
+“Raw” blocks are always preceded by
+\verb|\leavevmode|, just in case.
+
+\end{description}
+
+\end{document}
Property changes on: trunk/docutils/test/functional/expected/latex_leavevmode.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2021-02-18 23:09:23 UTC (rev 8625)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2021-02-18 23:09:44 UTC (rev 8626)
@@ -464,18 +464,18 @@
}
\begin{description}
-\item[{Term}] \leavevmode
+\item[{Term}]
Definition
-\item[{Term}] \leavevmode (\textbf{classifier})
+\item[{Term}] (\textbf{classifier})
Definition paragraph 1.
Definition paragraph 2.
-\item[{Term}] \leavevmode
+\item[{Term}]
Definition
-\item[{Term}] \leavevmode (\textbf{classifier one})(\textbf{classifier two})
+\item[{Term}] (\textbf{classifier one})(\textbf{classifier two})
Definition
\end{description}
@@ -1374,7 +1374,7 @@
\end{DUfieldlist}
a paragraph,
\begin{description}
-\item[{a definition}] \leavevmode
+\item[{a definition}]
list,
\end{description}
@@ -1840,7 +1840,7 @@
physical system changes in time.
\begin{description}
-\item[{Math-Accents:}] \leavevmode
+\item[{Math-Accents:}] \leavevmode
\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable*}{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
@@ -2188,7 +2188,7 @@
\end{quote}
\begin{description}
-\item[{In a definition list:}] \leavevmode
+\item[{In a definition list:}] \leavevmode
\begin{DUoptionlist}
\item[-{}-help] show help
@@ -2646,10 +2646,10 @@
\end{itemize}
\begin{description}
-\item[{simple}] \leavevmode
+\item[{simple}]
description term
-\item[{{[}bracketed{]}}] \leavevmode
+\item[{{[}bracketed{]}}]
description term
\end{description}
@@ -2719,7 +2719,7 @@
(name) of a reference node equals the link URL.
\begin{description}
-\item[{Example:}] \leavevmode
+\item[{Example:}]
a long URL that should wrap in the output
\url{http://docutils.sourceforge.net/docs/user/latex.html\#id79}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-02-18 23:09:23 UTC (rev 8625)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2021-02-18 23:09:44 UTC (rev 8626)
@@ -468,18 +468,18 @@
}
\begin{description}
-\item[{Term}] \leavevmode
+\item[{Term}]
Definition
-\item[{Term}] \leavevmode (\textbf{classifier})
+\item[{Term}] (\textbf{classifier})
Definition paragraph 1.
Definition paragraph 2.
-\item[{Term}] \leavevmode
+\item[{Term}]
Definition
-\item[{Term}] \leavevmode (\textbf{classifier one})(\textbf{classifier two})
+\item[{Term}] (\textbf{classifier one})(\textbf{classifier two})
Definition
\end{description}
@@ -1378,7 +1378,7 @@
\end{DUfieldlist}
a paragraph,
\begin{description}
-\item[{a definition}] \leavevmode
+\item[{a definition}]
list,
\end{description}
@@ -1844,7 +1844,7 @@
physical system changes in time.
\begin{description}
-\item[{Math-Accents:}] \leavevmode
+\item[{Math-Accents:}] \leavevmode
\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable*}{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
@@ -2192,7 +2192,7 @@
\end{quote}
\begin{description}
-\item[{In a definition list:}] \leavevmode
+\item[{In a definition list:}] \leavevmode
\begin{DUoptionlist}
\item[-{}-help] show help
@@ -2650,10 +2650,10 @@
\end{itemize}
\begin{description}
-\item[{simple}] \leavevmode
+\item[{simple}]
description term
-\item[{{[}bracketed{]}}] \leavevmode
+\item[{{[}bracketed{]}}]
description term
\end{description}
@@ -2723,7 +2723,7 @@
(name) of a reference node equals the link URL.
\begin{description}
-\item[{Example:}] \leavevmode
+\item[{Example:}]
a long URL that should wrap in the output
\url{http://docutils.sourceforge.net/docs/user/latex.html\#id79}
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2021-02-18 23:09:23 UTC (rev 8625)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2021-02-18 23:09:44 UTC (rev 8626)
@@ -327,18 +327,18 @@
}
\begin{description}
-\item[{Term}] \leavevmode
+\item[{Term}]
Definition
-\item[{Term}] \leavevmode (\textbf{classifier})
+\item[{Term}] (\textbf{classifier})
Definition paragraph 1.
Definition paragraph 2.
-\item[{Term}] \leavevmode
+\item[{Term}]
Definition
-\item[{Term}] \leavevmode (\textbf{classifier one})(\textbf{classifier two})
+\item[{Term}] (\textbf{classifier one})(\textbf{classifier two})
Definition
\end{description}
@@ -1261,7 +1261,7 @@
\end{DUfieldlist}
a paragraph,
\begin{description}
-\item[{a definition}] \leavevmode
+\item[{a definition}]
list,
\end{description}
@@ -1728,7 +1728,7 @@
physical system changes in time.
\begin{description}
-\item[{Math-Accents:}] \leavevmode
+\item[{Math-Accents:}] \leavevmode
\setlength{\DUtablewidth}{\linewidth}%
\begin{longtable*}{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
@@ -2076,7 +2076,7 @@
\end{quote}
\begin{description}
-\item[{In a definition list:}] \leavevmode
+\item[{In a definition list:}] \leavevmode
\begin{DUoptionlist}
\item[--help] show help
@@ -2534,10 +2534,10 @@
\end{itemize}
\begin{description}
-\item[{simple}] \leavevmode
+\item[{simple}]
description term
-\item[{{[}bracketed{]}}] \leavevmode
+\item[{{[}bracketed{]}}]
description term
\end{description}
@@ -2607,7 +2607,7 @@
(name) of a reference node equals the link URL.
\begin{description}
-\item[{Example:}] \leavevmode
+\item[{Example:}]
a long URL that should wrap in the output
\url{http://docutils.sourceforge.net/docs/user/latex.html\#id79}
Added: trunk/docutils/test/functional/input/latex_leavevmode.txt
===================================================================
--- trunk/docutils/test/functional/input/latex_leavevmode.txt (rev 0)
+++ trunk/docutils/test/functional/input/latex_leavevmode.txt 2021-02-18 23:09:44 UTC (rev 8626)
@@ -0,0 +1,164 @@
+Styling of Elements in Definition- or Field-List
+================================================
+
+:Authors: Hänsel, Gretel
+:Address: 123 Example Street
+ Example, EX Canada
+:Generic Docinfo List Field:
+ - This is a list.
+ - It does not require ``\leavevmode`` because it is in the docinfo.
+:Abstract:
+ Test that ``\leavevmode`` is inserted after the term or field-name
+ when required for correct placement of the item.
+
+Elements needing ``\leavevmode``
+********************************
+
+:Bullet List:
+ - This is a bullet list nested in a field list.
+ - It needs ``\leavevmode`` so that it will start on a new line
+ after the term.
+ - Without ``\leavevmode``, the first bullet would be on the same line as
+ the term, and the following bullets would not line up.
+
+:Enumerated List:
+ 1. This is an enumerated list.
+ 2. All lists need ``\leavevmode``.
+
+:Field List:
+ :Field List: Like this one
+ :Needs ``\leavevmode``: Yes
+
+:empty:
+
+Definition List
+ Nested
+ inside another definition list.
+ Needs ``\leavevmode``?
+ Yes.
+ Independent of the nesting level.
+
+Option List
+ -h Show help
+ -v Be verbose
+ --rare a) This description starts with an enumeration
+ c) but does not need ``\leavevmode``.
+
+Literal Block
+ ::
+
+ _needs_leavevmode = True
+
+Doctest Block
+ >>> needs_leavevmode(nodes.doctest_block)
+ True
+
+Line Block
+ | Needs "``\leavevmode``",
+ | so that all lines start with the same indent.
+
+Block Quote
+ ..
+
+ Block Quotes need "``\leavevmode``", too,
+ so that all lines start with the same indent.
+
+Table
+ +---+---+
+ | 1 | 2 |
+ +---+---+
+ | 3 | 4 |
+ +---+---+
+
+Figure
+ .. figure:: ../../../docs/user/rst/images/title.png
+
+ A figure
+
+Image
+ .. image:: ../../../docs/user/rst/images/title.png
+
+Rubric
+ .. rubric:: A Rubric
+
+Admonition
+ .. note::
+
+ Admonitions need to be preceded by ``\leavevmode``.
+ Otherwise, the term ends up centered above the admonition box.
+
+ So do *System Messages*, as they use the "DUadmonition"
+ LaTeX environment.
+
+
+Elements not needing ``\leavevmode``
+************************************
+
+Paragraph
+ Paragraphs don't need ``\leavevmode``. They are meant
+ to start after the term and have a hanging indent.
+
+ * Subsequent elements don't need ``\leavevmode`` either.
+
+Math Block
+ .. math::
+
+ \sum_{i=1}^n i = \frac{n^2+n}{2}
+
+ LaTeX starts math blocks (both single-line and multiline) in a new
+ paragraph automatically, with or without ``\leavevmode``, so
+ ``\leavevmode`` isn't needed.
+
+Term with Classifier: classifier
+ - After a *classifier*, ``\leavevmode`` is not required.
+ - This holds for all elements that normally need ``\leavevmode``.
+
+Ambiguous cases
+***************
+
+Comment and Target
+ .. This is ignored.
+
+ .. _foo:
+
+ * Comments and other "Invisible" nodes (substitution definitions,
+ targets, pending) must be skipped when determining whether a
+ ``\leavevmode`` is required.
+
+Substitution Definition and Class directive
+ .. |no-leavevmode| replace:: No (because a paragraph follows).
+
+ .. class:: test
+
+ Is ``\leavevmode`` required? Answer: |no-leavevmode|
+
+Compound
+ .. compound::
+
+ `Compound` and `Container` wrap around other block elements.
+ They get a ``\leavevmode``, if the first nested element is a
+ list or similar.
+
+Container
+ .. container:: my-class
+
+ * This list inside a container requires a ``\leavevmode``.
+
+Footnote
+ .. [#f1] This footnote will move to the bottom of the page.
+
+ A ``\leavevmode`` is required, if the first list item value is a
+ footnote and a list or similar follows.
+
+Citation
+ .. [example73] No Name, "Citations move to the bottom as well",
+ Musterstadt, 1973.
+
+ * A ``\leavevmode`` is required, if the first list item value is a
+ citation and a list or similar follows.
+
+Raw Block Text
+ .. raw:: latex
+
+ “Raw” blocks are always preceded by
+ \verb|\leavevmode|, just in case.
Property changes on: trunk/docutils/test/functional/input/latex_leavevmode.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/tests/latex_leavevmode.py
===================================================================
--- trunk/docutils/test/functional/tests/latex_leavevmode.py (rev 0)
+++ trunk/docutils/test/functional/tests/latex_leavevmode.py 2021-02-18 23:09:44 UTC (rev 8626)
@@ -0,0 +1,10 @@
+# Source and destination file names.
+test_source = "latex_leavevmode.txt"
+test_destination = "latex_leavevmode.tex"
+
+# Keyword parameters passed to publish_file.
+writer_name = "latex"
+
+# Settings
+# use "smartquotes" transition:
+settings_overrides['smart_quotes'] = True
Property changes on: trunk/docutils/test/functional/tests/latex_leavevmode.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|