mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
make text
generate wrong table when it has empty table cells. Closes #1544
This commit is contained in:
parent
8f7936d75c
commit
438f9fe3de
1
CHANGES
1
CHANGES
@ -39,6 +39,7 @@ Bugs fixed
|
||||
* PR#281, PR#282, #1509: TODO extension not compatible with websupport. Thanks
|
||||
to Takeshi Komiya.
|
||||
* #1477: gettext does not extract nodes.line in a table or list.
|
||||
* #1544: `make text` generate wrong table when it has empty table cells.
|
||||
|
||||
Release 1.2.2 (released Mar 2, 2014)
|
||||
====================================
|
||||
|
@ -11,7 +11,7 @@
|
||||
import os
|
||||
import re
|
||||
import textwrap
|
||||
from itertools import groupby
|
||||
from itertools import groupby, izip_longest
|
||||
|
||||
from docutils import nodes, writers
|
||||
from docutils.utils import column_width
|
||||
@ -503,7 +503,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
self.add_text(''.join(out) + self.nl)
|
||||
|
||||
def writerow(row):
|
||||
lines = zip(*row)
|
||||
lines = izip_longest(*row)
|
||||
for line in lines:
|
||||
out = ['|']
|
||||
for i, cell in enumerate(line):
|
||||
|
@ -139,3 +139,29 @@ def test_nonascii_maxwidth(app):
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
line_widths = [column_width(line) for line in lines]
|
||||
assert max(line_widths) < MAXWIDTH
|
||||
|
||||
|
||||
@with_text_app()
|
||||
def test_table_with_empty_cell(app):
|
||||
contents = (u"""
|
||||
+-----+-----+
|
||||
| XXX | XXX |
|
||||
+-----+-----+
|
||||
| | XXX |
|
||||
+-----+-----+
|
||||
| XXX | |
|
||||
+-----+-----+
|
||||
""")
|
||||
|
||||
(app.srcdir / 'contents.rst').write_text(contents, encoding='utf-8')
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'contents.txt').text(encoding='utf-8')
|
||||
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXX | XXX |"
|
||||
assert lines[2] == "+-------+-------+"
|
||||
assert lines[3] == "| | XXX |"
|
||||
assert lines[4] == "+-------+-------+"
|
||||
assert lines[5] == "| XXX | |"
|
||||
assert lines[6] == "+-------+-------+"
|
||||
|
Loading…
Reference in New Issue
Block a user