Skip to content

fix(render): don't markdown-escape values rendered inside code spans#1

Merged
kim-em merged 1 commit into
masterfrom
fix-md-code-cell-escape
May 27, 2026
Merged

fix(render): don't markdown-escape values rendered inside code spans#1
kim-em merged 1 commit into
masterfrom
fix-md-code-cell-escape

Conversation

@kim-em

@kim-em kim-em commented May 27, 2026

Copy link
Copy Markdown
Contributor

This PR fixes a rendering bug in Crossrefs.Render.renderRow: tag and declaration cells are wrapped in `...` code spans but then passed through mdTableEscape, which backslash-escapes _, *, [, ], (, ), #. Markdown does not interpret any of these inside a code span, so the escapes leak through as literal backslashes. A decl like Subgroup.card_subgroup_dvd_card rendered as Subgroup.card\_subgroup\_dvd\_card.

Add a separate mdCodeCellEscape that only handles characters which can break out of the code span or the surrounding table cell (backticks → ˋ look-alike, |, newlines) and use it for the tag and decl cells. Free-text cells (title, description, comment) still go through the full mdTableEscape.

Caught by the test render against leanprover-community/mathlib4#39909 (comment).

🤖 Prepared with Claude Code

`renderRow` wraps the tag and declaration name in `` `...` `` code spans
before passing them through `mdTableEscape`. Markdown doesn't interpret
`_`, `*`, `[`, etc. inside a code span, so the backslash escapes leak
through verbatim: a decl like `Subgroup.card_subgroup_dvd_card` rendered
as `Subgroup.card\_subgroup\_dvd\_card`.

Add `mdCodeCellEscape` covering only what can break out of the span or
the surrounding table cell (backticks, `|`, newlines) and use it for the
tag and decl cells. Free-text cells (title, description, comment) still
go through `mdTableEscape`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kim-em
kim-em merged commit 712fc65 into master May 27, 2026
@kim-em
kim-em deleted the fix-md-code-cell-escape branch May 27, 2026 18:29
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.

1 participant