Skip to content

Fix dark theme code block readability and add TOC heading font-size hierarchy#2

Merged
CoderBoyBoy merged 7 commits intomainfrom
copilot/optimize-markdown-component
Mar 20, 2026
Merged

Fix dark theme code block readability and add TOC heading font-size hierarchy#2
CoderBoyBoy merged 7 commits intomainfrom
copilot/optimize-markdown-component

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

Two issues: code blocks in dark mode had near-invisible text, and TOC sidebar headings all rendered at the same font size regardless of depth.

Dark theme code block colors

Shiki dual-theme generates color:#24292E;--shiki-dark:#E1E4E8 on spans — light-mode color as default, dark-mode in a CSS variable. No CSS rule activated --shiki-dark, so light-theme text colors (dark grays, navy blues) rendered against the #161b22 background.

  • Added CSS rules to set color: var(--shiki-dark) !important on .shiki and .shiki span for .markdown-theme-dark, .markdown-theme-github-dark, and .markdown-theme-auto (via prefers-color-scheme: dark)
.markdown-theme-dark .markdown-body .code-block .shiki span,
.markdown-theme-github-dark .markdown-body .code-block .shiki span {
  color: var(--shiki-dark) !important;
}

Dark theme code block after fix

TOC sidebar heading hierarchy

All TOC levels rendered at the base 0.8125em. Added per-level font sizes via existing toc-level-{depth} classes:

  • Level 1: 1em + font-weight: 600
  • Level 2: 0.9375em
  • Level 3: 0.875em
  • Level 4: 0.8125em

TOC heading hierarchy


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 3 commits March 20, 2026 03:28
Co-authored-by: CoderBoyBoy <11583532+CoderBoyBoy@users.noreply.github.com>
- Replace toolbar icons (ToolbarIcon.tsx) with lucide-react components
- Replace code block action buttons (copy/download/preview) with lucide-react SVG icons
- Add parseCodeMeta utility for parsing extended code fence attributes
- Add extractCodeBlocks utility for extracting code blocks with metadata
- Add remark-code-meta plugin for preserving meta through render pipeline
- Update rehype-highlight-code to forward meta as data-* attributes
- Simplify sanitize schema to use data* wildcard
- Add 24 comprehensive unit tests for code-meta parsing
- Export new utilities (parseCodeMeta, extractCodeBlocks, remarkCodeMeta)

Co-authored-by: CoderBoyBoy <11583532+CoderBoyBoy@users.noreply.github.com>
… icons

- Add code block extended attributes documentation to README
- Add parseCodeMeta/extractCodeBlocks API documentation to README
- Update project structure in README to reflect new files
- Update website demo to showcase code block extended attributes
- Add code block meta example tab to website code examples
- Update feature descriptions for both EN and ZH

Co-authored-by: CoderBoyBoy <11583532+CoderBoyBoy@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize markdown component functionality and appearance feat: lucide-react icons, code block extended attributes with parsing API Mar 20, 2026
Copilot AI requested a review from CoderBoyBoy March 20, 2026 03:39
…t code-snippet

When a code block includes `filename=App.tsx` in the fence meta, the
download button now uses "App.tsx" as the download filename instead of
the default "code-snippet.ts".

The remark-code-meta plugin already parsed the filename and stored it
as `data-filename` on the code block HTML element, but the download
handler was ignoring it. Now MarkdownRenderer reads `data-filename`
and passes it to triggerCodeDownload, which prioritizes it over the
fallback code-content scanning logic.

Co-authored-by: CoderBoyBoy <11583532+CoderBoyBoy@users.noreply.github.com>
Copilot AI changed the title feat: lucide-react icons, code block extended attributes with parsing API fix: use code fence filename= attribute as download filename Mar 20, 2026
Previously all TOC items rendered at the same font size (0.8125em).
Now toc-level-1 through toc-level-4 have differentiated font sizes
to provide visual hierarchy matching the body content headings.

Co-authored-by: CoderBoyBoy <11583532+CoderBoyBoy@users.noreply.github.com>
Copilot AI changed the title fix: use code fence filename= attribute as download filename Fix code block download filename from fence meta and add TOC heading font-size hierarchy Mar 20, 2026
@CoderBoyBoy CoderBoyBoy marked this pull request as ready for review March 20, 2026 05:12
Shiki dual-theme generates light-mode colors as default inline `color`
values and stores dark-mode colors in `--shiki-dark` CSS variables.
Without CSS rules to activate these variables, light-theme text colors
(e.g., #24292E, #032F62) showed on dark backgrounds (#161b22), making
code nearly unreadable.

Added CSS rules that switch to `var(--shiki-dark)` in dark theme
contexts (.markdown-theme-dark, .markdown-theme-github-dark, and
.markdown-theme-auto with prefers-color-scheme: dark).

Co-authored-by: CoderBoyBoy <11583532+CoderBoyBoy@users.noreply.github.com>
Copilot AI changed the title Fix code block download filename from fence meta and add TOC heading font-size hierarchy Fix dark theme code block readability and add TOC heading font-size hierarchy Mar 20, 2026
@CoderBoyBoy CoderBoyBoy merged commit c3817ae into main Mar 20, 2026
@CoderBoyBoy CoderBoyBoy deleted the copilot/optimize-markdown-component branch March 20, 2026 11:22
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.

2 participants