Skip to content

M23-B: Integrate SyntaxHighlighter into MdRenderer #346

@bug-ops

Description

@bug-ops

Parent: #344
Depends on: #345

Scope

  • Add code_lang: Option<String> field to MdRenderer
  • Store language tag on Event::Start(Tag::CodeBlock(Fenced(lang)))
  • Clear on Event::End(TagEnd::CodeBlock)
  • In Event::Text when in_code_block && code_lang.is_some(): call SyntaxHighlighter::highlight()
  • If Some(spans) returned, push multiple spans instead of single flat span
  • If None, fall back to theme.code_block (current behavior)
  • Preserve " " prefix indentation for code lines

Acceptance criteria

  • Fenced code blocks with known languages render with multiple colored spans
  • Unknown languages fall back to flat code_block style
  • Unfenced code blocks unchanged
  • Existing tests pass; new test for highlighted code block

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions