Skip to content

Split table cells on a pipe that follows a closing code span backtick - #729

Merged
nicholasserra merged 2 commits into
trentm:masterfrom
youdie006:table-pipe-after-code-span
Sep 30, 2026
Merged

nicholasserra merged 2 commits into
trentm:masterfrom
youdie006:table-pipe-after-code-span

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

With extras=["tables"], a pipe directly after a code span is not treated as a cell border, so a compact row loses a cell:

|Flag|Meaning|
|-|-|
|`-v`|verbose|

gives <td><code>-v</code>|verbose</td><td></td> instead of <td><code>-v</code></td><td>verbose</td>.

Tables._split_row splits on (?<![\\])|. The backtick in the lookbehind was added for #399 to keep `` |` `` in one cell, but it also skips a pipe right after the backtick that closes a code span. This keeps the pipe only when the backtick before it opens a span (an odd number of backticks so far in the row), and otherwise splits as before.

Only that case changes: `|`, `a|b`, a row with unmatched backticks, and escaped pipes render the same as on master (I compared these before and after). The new tm-case tables_code_span_adjacent_pipe fails on master; make testone has no other failures apart from the 7 pygments>=2.21 cases that fail the same way on master in my environment, and make testredos passes.

Written with AI assistance (Claude); I have reviewed the change.

_split_row did not split on any pipe preceded by a backtick, to keep
`|` inside a cell (trentm#399). That also covered a pipe right after the
backtick that closes a code span, so a compact row like
|`-v`|verbose| put "verbose" into the first cell. Only keep the pipe
when the backtick before it opens a code span.
@nicholasserra

Copy link
Copy Markdown
Collaborator

LGTM thanks!

@nicholasserra
nicholasserra merged commit 27cd678 into trentm:master Sep 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants