Skip to content

fix: stop over-escaping inline chars in markdown autoescape#119

Merged
lbliii merged 1 commit intomainfrom
lbliii/fix-changelog
Apr 24, 2026
Merged

fix: stop over-escaping inline chars in markdown autoescape#119
lbliii merged 1 commit intomainfrom
lbliii/fix-changelog

Conversation

@lbliii
Copy link
Copy Markdown
Owner

@lbliii lbliii commented Apr 24, 2026

Summary

The v0.8.0 release notes shipped with mangled output (2026\-04\-24, feat\-UX, \#\# Summary inside every <details> block) because Kida's autoescape="markdown" was backslash-escaping 16 characters on every interpolated value — including hyphens, parens, hashes, and pipes that don't actually need escaping inline.

Changes

  • markdown_escape trimmed to inline-only chars (\, `, *, _, [, ], <) plus block-leading markers (#, >, -, +, ordered-list digits) escaped only at line start, matching CommonMark/GFM parsing.
  • Markup.__markdown__() added so {{ x | safe }} opts out of escaping in markdown mode the same way it does in HTML mode (previously a no-op under markdown autoescape).
  • Built-in release-notes templates pipe PR body_excerpt and body through | safe so PR-body markdown renders as authored.
  • 14 snapshot files refreshed; new tests cover line-leading vs inline behavior; [Unreleased] changelog entry added with breaking-change note per the project's release style.

Test plan

  • uv run pytest — 4202 passed, 5 skipped
  • uv run ruff check / format — clean
  • Re-rendered a v0.8.0-equivalent fixture end-to-end and confirmed dates, hyphens, parens, and ## Summary headings inside <details> blocks now render cleanly

🤖 Generated with Claude Code

Trim `markdown_escape` to escape only inline-significant characters
(\, `, *, _, [, ], <) plus block-leading markers (#, >, -, +, ordered-list
digits) at line start. Hyphens, parens, hashes, and pipes mid-line now
render unmangled — release notes no longer show `2026\-04\-24` or
`divide\(1, 0\)`.

Add `__markdown__` to `Markup` so `{{ x | safe }}` opts out of escaping
in markdown mode the same way it does in HTML mode. Built-in release-notes
templates pipe PR `body_excerpt` and `body` through `| safe` so PR-body
markdown (`## Summary`, bullet lists, inline code) renders as authored
instead of as backslash-escaped literals inside `<details>` blocks.

Snapshots refreshed across 14 templates; all 4202 tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lbliii lbliii merged commit 5c6141d into main Apr 24, 2026
10 checks passed
@lbliii lbliii deleted the lbliii/fix-changelog branch April 24, 2026 18:48
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