Escape pipes when writing a CoefTable as markdown - #1007
Merged
Conversation
An unescaped `|` ends the cell it sits in, so a row containing one presents more cells than the alignment row and the table stops parsing as a table at all. Downstream packages hit this with the R-style `Pr(>|z|)` p-value header: the header row then has 10 pipe-delimited fields against the alignment row's 8, so Julia's Markdown parser degrades the whole table to a paragraph (and turns the `---` rules into en-dashes on the way). Escape `|` in row names, column names and string cells — the same rule the Markdown stdlib applies in `plain(::IO, ::Markdown.Table)` — before the column widths are measured, so the widths stay consistent with what is printed.
andreasnoack
force-pushed
the
an/escape-markdown-pipes
branch
from
August 21, 2026 13:47
7cf6a81 to
c0defdf
Compare
palday
approved these changes
Aug 24, 2026
palday
left a comment
Member
There was a problem hiding this comment.
@andreasnoack care to patch bump and release this right away? I'll take a look at #1008 when I get some time later in the week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
show(::IO, ::MIME"text/markdown", ::CoefTable)never escapes|, so any cell containing one silently destroys the table. Downstream packages hit this with the R-stylePr(>|z|)p-value header (GLM, MixedModels, and others build their coefficient tables with it), which is why it is easy to reproduce but invisible from inside StatsBase — no header or fixture here contains a pipe.Reproduction
The header row carries the two extra pipes from
Pr(>|z|), so it presents 10 pipe-delimited fields against the alignment row's 8. No markdown parser accepts that as a table; Julia's degrades it to a paragraph and then applies inline typography to the---rules, turning them into en-dashes. Rendered through Documenter or any markdown viewer, the whole table appears as one run of pipes and dashes.Fix
Escape
|in row names, column names and string cells — the same rule the Markdown stdlib applies inplain(::IO, ::Markdown.Table)— before the column widths are measured, so the widths stay consistent with what is printed.Added a test covering a pipe in a header, a row name and a string cell, asserting that every row presents the same number of cells and that the output parses as a
Markdown.Table. It fails without the fix. The two existing golden-output markdown tests are unchanged, since neither contains a pipe.Related
#1008 is an alternative that goes further: it drops the hand-rolled writer in favour of building a
Markdown.Table, which removes this class of bug rather than this instance of it. That one changes the emitted spacing and adds Markdown as a dependency, so it is offered separately rather than folded in here.🤖 Generated with Claude Code