Skip to content

fix(web): preserve code block text when lowlight auto-detect finds no match - #58

Merged
Coldin04 merged 1 commit into
mainfrom
codex/fix-html-export-auto-highlight-empty
Sep 18, 2026
Merged

Coldin04 merged 1 commit into
mainfrom
codex/fix-html-export-auto-highlight-empty

Conversation

@Coldin04

Copy link
Copy Markdown
Owner

Summary

  • HTML export left <code> empty whenever a code block's language was "Auto" and the text had no strong language signal (e.g. a plain pip install ... line) — lowlight.highlightAuto() returns an empty children array in that case instead of the raw text.
  • highlightCodeForExport now falls back to the escaped source text whenever the highlighter (either the explicit-language or auto-detect path) produces no renderable nodes.

Test plan

  • Create a code block, leave language as "Auto", enter text with no strong language signal (e.g. pip install numpy pandas transformers peft datasets)
  • Export the document to HTML and confirm the code block text is present
  • Confirm code blocks with an explicit language (e.g. bash) still render with syntax highlighting

🤖 Generated with Claude Code

… match

lowlight.highlightAuto() returns an empty children array (not the raw
text wrapped in a text node) when it can't confidently detect a
language, so any code block left on "Auto" whose content has no
strong language signal (e.g. a plain pip install line) exported to
HTML with an empty <code> element. Fall back to the escaped source
text whenever the highlighter produces no renderable nodes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fallback preserves source text while retaining existing syntax highlighting behavior.

Pull request overview

Preserves code text during HTML export when lowlight auto-detection produces no renderable nodes.

Changes:

  • Handles empty sources without invoking highlighting.
  • Falls back to escaped source text when highlighting returns empty output.
File summaries
File Description
packages/web/src/lib/export/documentExport.ts Adds safe fallback behavior for code block highlighting.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Coldin04
Coldin04 merged commit ebcc614 into main Sep 18, 2026
1 check passed
@Coldin04
Coldin04 deleted the codex/fix-html-export-auto-highlight-empty branch September 18, 2026 07:34
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