Skip to content

fix(renderer): honor nested fence lengths#1704

Merged
1 commit merged into
nesquena:masterfrom
Michaelyklam:fix/issue-1696-fence-length
May 5, 2026
Merged

fix(renderer): honor nested fence lengths#1704
1 commit merged into
nesquena:masterfrom
Michaelyklam:fix/issue-1696-fence-length

Conversation

@Michaelyklam
Copy link
Copy Markdown
Contributor

Thinking Path

What Changed

  • Updated static/ui.js fenced-code matching to capture {3,} backtick opener runs and require \2 plus optional extra backticks on close.
  • Applied the same fence-length rule to user-message fenced rendering and to the blockquote pre-pass fence-state walker.
  • Kept normal 3-backtick language rendering and empty-fence handling covered.
  • Updated source/driver tests that extract renderMd() so they include the new shared fence helpers.

Why It Matters

  • Fixes nested markdown/code examples where an outer 4+ or 5+ backtick fence contains inner triple-backtick fences.
  • Prevents stray outer closers from leaking into prose and keeps the code block as one intact <pre><code> block.

Fixes #1696

Verification

  • pytest tests/test_sprint16.py::test_render_md_fenced_code_with_five_backtick_outer_preserves_inner_triples tests/test_sprint16.py::test_render_md_fenced_code_with_four_backtick_outer_preserves_inner_triples tests/test_sprint16.py::test_render_md_fenced_code_three_backtick_path_still_renders_language tests/test_renderer_js_behaviour.py::TestFencedCodeFenceLength tests/test_1325_user_fenced_code.py::TestUserFencedBlocks::test_four_backtick_outer_fence_preserves_inner_triple_fence -q — 7 passed
  • pytest tests/test_sprint16.py tests/test_renderer_js_behaviour.py tests/test_1325_user_fenced_code.py tests/test_issue1438_fence_anchoring.py tests/test_issue1154_fenced_code_leak.py tests/test_issue1618_yaml_json_diff_newline_preserve.py tests/test_issue1446_glued_heading_lift.py tests/test_issue_code_syntax_highlight.py -q — 197 passed
  • git diff --check — passed
  • env -u HERMES_CONFIG_PATH /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/ -q — 4484 passed, 2 skipped, 3 xpassed, 1 warning, 8 subtests passed in 407.20s

No screenshots included: this is a renderer parsing fix verified at the rendered-HTML level with the actual static/ui.js renderMd() node driver.

Risks / Follow-ups

  • This keeps the existing backtick-only scope; tilde fences were not added.
  • Info strings that are not a single language token still do not produce a language header, matching the existing conservative language handling.

Model Used

  • OpenAI Codex gpt-5.5 via Hermes Agent CLI.
  • Tool use: Hermes file tools, shell/git/pytest, GitHub CLI.

@nesquena-hermes nesquena-hermes closed this pull request by merging all changes into nesquena:master in 4daa238 May 5, 2026
Michaelyklam pushed a commit to Michaelyklam/hermes-webui that referenced this pull request May 5, 2026
Michaelyklam added a commit to Michaelyklam/hermes-webui that referenced this pull request May 5, 2026
10 PRs (3 surfaces additions, 7 fixes):
- nesquena#1644 model picker chip + group count (@bergeouss, closes nesquena#1425)
- nesquena#1684 update network failures UX (@Michaelyklam, closes nesquena#1321)
- nesquena#1685 Codex spark models (@Michaelyklam, closes nesquena#1680)
- nesquena#1689 normalize profile base homes (@Michaelyklam, refs nesquena#749)
- nesquena#1693 adaptive title refresh deadlock (@ai-ag2026)
- nesquena#1701 normalize update banner URL (@Michaelyklam, closes nesquena#1691)
- nesquena#1702 workspace double-click rename (@Michaelyklam, closes nesquena#1698)
- nesquena#1703 cache invalidation on auth-store drift (@Michaelyklam, closes nesquena#1699)
- nesquena#1704 markdown fence lengths (@Michaelyklam, closes nesquena#1696)
- nesquena#1706 multi-image paste fix (@Michaelyklam, closes nesquena#1697)

Tests: 4477 → 4503 (+26). Opus: SHIP, 7/7 verification clean.

Co-authored-by: Michael Lam <Michaelyklam1@gmail.com>
Co-authored-by: ai-ag2026 <noreply@github.com>
Co-authored-by: bergeouss <noreply@github.com>
@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Closed by the v0.51.4 release in PR #1707 (merged at 4daa238, deployed to production).

Live on production: https://github.com/nesquena/hermes-webui/releases/tag/v0.51.4

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants