Skip to content

Commit

Permalink
Let latex writer line trimming from depart_entry() work as before sph…
Browse files Browse the repository at this point in the history
…inx-doc#8081

This is cosmetic as the blank line starting varwidth environment used
for merged table cells in latex output changed nothing to PDF.

Nevertheless I extended a unit test to have a multi-paragraph merged
cell using varwidth. What is important is that \sphinxAtStartPar line
itself is never followed by blank line.
  • Loading branch information
jfbu committed Jan 30, 2021
1 parent be20f17 commit be57d3f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion sphinx/writers/latex.py
Expand Up @@ -1163,7 +1163,8 @@ def visit_paragraph(self, node: Element) -> None:
else:
# the \sphinxAtStartPar is to allow hyphenation of first word of
# a paragraph in narrow contexts such as in a table cell
self.body.append('\n\\sphinxAtStartPar\n')
# added as two items (cf. line trimming in depart_entry())
self.body.extend(['\n','\\sphinxAtStartPar\n'])

def depart_paragraph(self, node: Element) -> None:
self.body.append('\n')
Expand Down
4 changes: 2 additions & 2 deletions tests/roots/test-latex-table/complex.rst
Expand Up @@ -11,9 +11,9 @@ grid table
+---------+ +---------+
| cell2-1 | | cell2-3 |
+ +---------+---------+
| | cell3-2 |
| | cell3-2-par1 |
+---------+ |
| cell4-1 | |
| cell4-1 | cell3-2-par2 |
+---------+---------+---------+
| cell5-1 |
+---------+---------+---------+
Expand Down
Expand Up @@ -19,15 +19,13 @@
\hline
\sphinxmultirow{3}{1}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}

\sphinxAtStartPar
cell1\sphinxhyphen{}1
\par
\vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}%
}%
&\sphinxmultirow{3}{2}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}

\sphinxAtStartPar
cell1\sphinxhyphen{}2
\par
Expand All @@ -38,15 +36,13 @@
cell1\sphinxhyphen{}3
&\sphinxmultirow{3}{4}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}

\sphinxAtStartPar
cell1\sphinxhyphen{}4
\par
\vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}%
}%
&\sphinxmultirow{2}{5}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}

\sphinxAtStartPar
cell1\sphinxhyphen{}5
\par
Expand All @@ -55,7 +51,6 @@
\\
\cline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}

\sphinxAtStartPar
cell2\sphinxhyphen{}3
\par
Expand Down
7 changes: 3 additions & 4 deletions tests/roots/test-latex-table/expects/gridtable.tex
Expand Up @@ -19,7 +19,6 @@
cell1\sphinxhyphen{}1
&\sphinxmultirow{2}{5}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{3}}

\sphinxAtStartPar
cell1\sphinxhyphen{}2
\par
Expand All @@ -31,7 +30,6 @@
\\
\cline{1-1}\cline{3-3}\sphinxmultirow{2}{7}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{3}}

\sphinxAtStartPar
cell2\sphinxhyphen{}1
\par
Expand All @@ -44,9 +42,11 @@
\cline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}%
\sphinxmultirow{2}{9}{%
\begin{varwidth}[t]{\sphinxcolwidth{2}{3}}
\sphinxAtStartPar
cell3\sphinxhyphen{}2\sphinxhyphen{}par1

\sphinxAtStartPar
cell3\sphinxhyphen{}2
cell3\sphinxhyphen{}2\sphinxhyphen{}par2
\par
\vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}%
}%
Expand All @@ -58,7 +58,6 @@
&\multicolumn{2}{l|}{\sphinxtablestrut{9}}\\
\hline\sphinxstartmulticolumn{3}%
\begin{varwidth}[t]{\sphinxcolwidth{3}{3}}

\sphinxAtStartPar
cell5\sphinxhyphen{}1
\par
Expand Down

0 comments on commit be57d3f

Please sign in to comment.