Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ format:

```

Literal pipes in AsciiDoc headers and cells are escaped automatically.

`orgtbl` follows the conventions of Emacs
[org-mode](http://orgmode.org/manual/Tables.html), and is editable also
in the minor orgtbl-mode. Hence its name:
Expand Down
2 changes: 1 addition & 1 deletion tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def make_header_line(is_header, colwidths, colaligns):
# print the table line and make the aboveline if it is a header

cell_values, colwidths, colaligns = args
data_line = "|" + "|".join(cell_values)
data_line = "|" + "|".join(cell.replace("|", r"\|") for cell in cell_values)

if is_header:
line = make_header_line(True, colwidths, colaligns) + "\n" + data_line
Expand Down
9 changes: 9 additions & 0 deletions test/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,15 @@ def test_asciidoc():
assert_equal(expected, result)


@mark.parametrize("headers", [[], ["left|right", "value"]])
def test_asciidoc_literal_separators(headers):
result = tabulate([[r"a\|b||c", "tail"]], headers=headers, tablefmt="asciidoc")
lines = result.splitlines()
assert r"a\\|b\|\|c" in lines[-2]
if headers:
assert r"left\|right" in lines[2]


def test_asciidoc_headerless():
"Output: asciidoc without headers"
expected = "\n".join(
Expand Down