Skip to content

fix(formatters): fix HTML entities and escaped underscores in table output#313

Merged
betegon merged 4 commits intomainfrom
fix/table-rendering-html-entities-escaped-urls
Mar 2, 2026
Merged

fix(formatters): fix HTML entities and escaped underscores in table output#313
betegon merged 4 commits intomainfrom
fix/table-rendering-html-entities-escaped-urls

Conversation

@betegon
Copy link
Member

@betegon betegon commented Mar 2, 2026

Summary

Fixes two rendering bugs introduced in efb59ba (the markdown rendering pipeline):

  1. <unknown> displays as &lt;unknown&gt;escapeMarkdownInline used HTML entities to escape angle brackets, but marked keeps them as-is in text tokens, so they showed up literally in terminal output.
  2. /_astro/ displays as /\_astro/ — escaped underscores in URLs got captured by GFM autolink detection, which doesn't process backslash escapes, leaving the backslash visible.

Changes

  • escapeMarkdownInline / escapeMarkdownCell: use CommonMark backslash escapes (\</\>) instead of HTML entities. marked correctly parses these as escape tokens with the decoded character.
  • renderOneInline link case: detect GFM autolinks via link.raw (starts with URL scheme, not [) and strip backslash-escape artifacts from both link text and href.
  • Tests: added angle bracket escape tests for both functions, plus round-trip tests verifying <unknown> and URLs with underscores render correctly through the full pipeline.

Test plan

  • bun test test/lib/formatters/markdown.test.ts — 77 tests pass (3 new)
  • Manual: bun src/bin.ts issue list against projects with <unknown> titles and URL-containing titles

…pe artifacts in autolinks

`escapeMarkdownInline` and `escapeMarkdownCell` were using HTML entities
(`&lt;`/`&gt;`) to prevent `<tag>` from being parsed as HTML. But `marked`
keeps entities as-is in text tokens, so `<unknown>` rendered literally as
`&lt;unknown&gt;`. Switching to CommonMark backslash escapes (`\<`/`\>`)
fixes this — `marked` emits them as `escape` tokens with the decoded char.

Also fixes backslash-escaped underscores leaking into GFM autolinks.
When a URL like `https://site.com/_astro/file.js` was escaped to
`\_astro`, the GFM autolink detector captured the escaped form and
preserved the backslash literally. Now `renderOneInline` detects
autolinks via `link.raw` and strips escape artifacts from both the
link text and href.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (formatters) Render all terminal output as markdown by BYK in #297
  • (issue-list) Global limit with fair distribution, compound cursor, and richer progress by BYK in #306

Bug Fixes 🐛

Api

  • Use limit param for issues endpoint page size by BYK in #309
  • Auto-correct ':' to '=' in --field values with a warning by BYK in #302

Other

  • (ci) Generate JUnit XML to silence codecov-action warnings by BYK in #300
  • (formatters) Fix HTML entities and escaped underscores in table output by betegon in #313
  • (nightly) Push to GHCR from artifacts dir so layer titles are bare filenames by BYK in #301
  • (test) Handle 0/-0 in getComparator anti-symmetry property test by BYK in #308

Internal Changes 🔧

  • (api) Wire listIssuesPaginated through @sentry/api SDK for type safety by BYK in #310

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Codecov Results 📊

2272 passed | Total: 2272 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +4
Passed Tests 📈 +4
Failed Tests
Skipped Tests

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 3233 uncovered lines.
✅ Project coverage is 80.08%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
markdown.ts 89.63% ⚠️ 34 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    80.05%    80.08%    +0.03%
==========================================
  Files          120       120         —
  Lines        16218     16226        +8
  Branches         0         0         —
==========================================
+ Hits         12983     12993       +10
- Misses        3235      3233        -2
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review March 2, 2026 11:58
Rename `unescape` to `stripEscapes` to avoid shadowing the global,
remove unnecessary escape/character from regex char class, and collapse
arrow function to a single line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

betegon and others added 2 commits March 2, 2026 13:47
The biome lint fix in 91f35df accidentally dropped \] from the
stripEscapes regex. This restores it so all 8 characters escaped by
escapeMarkdownInline are correctly unescaped in autolinks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@betegon betegon merged commit 8e7e77f into main Mar 2, 2026
20 checks passed
@betegon betegon deleted the fix/table-rendering-html-entities-escaped-urls branch March 2, 2026 13:00
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