Skip to content

Fix duplicate Show more buttons and exposed CSS in code blocks - #10

Open
xrmb wants to merge 2 commits into
FrankEBailey:mainfrom
xrmb:fix-codeblock-display
Open

Fix duplicate Show more buttons and exposed CSS in code blocks#10
xrmb wants to merge 2 commits into
FrankEBailey:mainfrom
xrmb:fix-codeblock-display

Conversation

@xrmb

@xrmb xrmb commented Jul 5, 2026

Copy link
Copy Markdown

Summary

  • Removed duplicate shAll() and initCollapse() calls from the window.onload handler so long code blocks / blockquotes get exactly one Show more button and one fade overlay.
  • Fixed the regex-based syntax highlighter so keyword, number, attribute, and function-call replacements only apply to text outside existing <span class="sh-*"> tags. This stops the highlighter from corrupting its own markup and exposing internal class names like class="sh-cm"> as visible text in code blocks.

Test plan

  • Build 64-bit mdview.wlx64
  • Open test.md and confirm long code blocks show exactly one Show more button
  • Confirm JavaScript, HTML, Python, and SQL code blocks render without visible internal CSS class names
  • Confirm syntax highlighting still colors keywords, strings, comments, and numbers correctly

window.onload invoked shAll() and initCollapse() twice. This produced a
second Show more button / fade overlay on every collapsible code block
and blockquote, and the second syntax-highlighting pass corrupted the
DOM and exposed internal CSS class names as visible text.
@xrmb
xrmb force-pushed the fix-codeblock-display branch from accb96c to 0085977 Compare July 5, 2026 04:03
The regex-based highlighter was matching keywords, numbers, and
attribute names inside the <span class="sh-*"> tags it had just
created, producing visible fragments like class="sh-cm"> in the
rendered code block. Split each replacement so it only applies to
text outside existing HTML tags.
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