Skip to content

Fixed markdown preview rendering indented code blocks outside their list item - #114

Merged
oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/markdown-indented-code-blocks
May 12, 2026
Merged

oleg68 merged 1 commit into
nbplugins:mainfrom
oleg68:bugfix/markdown-indented-code-blocks

Conversation

@oleg68

@oleg68 oleg68 commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fenced code blocks indented inside ordered list items are now rendered inside their parent <li>, visually nested under the list item
  • Ordered list numbering no longer resets to 1 after an indented code block — subsequent items continue from their written number
  • Leading spaces stripped from indented code block content (dedent), fixing copy-paste

Top-level (non-indented) code blocks still break the list as before.

Test plan

  • Open docs/tune-fedora.md (or any .md with an ordered list containing indented fenced code blocks) in the preview
  • Verify code block is visually indented under its list item, not at the left margin
  • Verify list numbering continues correctly after the code block (item 2 shows as 2, not 1)
  • Copy code from the block and verify no extra leading spaces
  • Verify a top-level (non-indented) code block between two 1.-started lists still resets numbering

🤖 Generated with Claude Code

…ist item

Fenced code blocks indented inside an ordered list item were rendered as
standalone <pre> elements between separate <ol> elements, causing:
- Wrong visual nesting (code block at left margin, not indented under its item)
- Ordered list numbering reset to 1 after each code block
- 4 extra leading spaces copied from the code block content

Fix: detect indented fences (preceding segment ends with whitespace) and
embed the <pre> inside the parent <li>, continuing the same <ol> for
subsequent list items. Top-level code blocks (no indent) still break the
list as expected. Added orderedListNumber() to emit <ol start="N"> so
any list — indented or top-level — renders from its written start number.
Added dedent() to strip common leading indentation from code block content.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@oleg68
oleg68 merged commit 2d337e1 into nbplugins:main May 12, 2026
3 checks passed
@oleg68
oleg68 deleted the bugfix/markdown-indented-code-blocks branch May 12, 2026 09:20
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