Skip to content

Add Format-Specific Code Highlighting Stylesnew change#409

Open
LuHC409 wants to merge 1 commit intoyzane:masterfrom
LuHC409:HaochengLu
Open

Add Format-Specific Code Highlighting Stylesnew change#409
LuHC409 wants to merge 1 commit intoyzane:masterfrom
LuHC409:HaochengLu

Conversation

@LuHC409
Copy link

@LuHC409 LuHC409 commented May 7, 2025

Add Format-Specific Code Highlighting Styles

Description

Added the ability to specify different code highlighting styles for different output formats (pdf, html, png, jpeg). For example, users can now use light themes for PDF files (for printing) and dark themes for HTML files.

Changes

  1. Modified the readStyles function in extension.js to support format-specific code highlighting styles
  2. Updated the markdown-pdf.highlightStyle configuration in package.json to support object-type configuration

Configuration Example

Users can now configure different highlighting styles for different formats:

{
  "markdown-pdf.highlightStyle": {
    "pdf": "github.css",     // Light theme for PDF files
    "html": "monokai.css",   // Dark theme for HTML files
    "default": "github.css"  // Default style for other formats
  }
}

Or continue using a single highlighting style:

{
  "markdown-pdf.highlightStyle": "github.css"
}

Backward Compatibility

  • Maintains backward compatibility with single string configuration
  • Provides default style fallback mechanism
  • All available styles can be previewed at highlight.js demo

Testing

  • Tested code highlighting for PDF output format
  • Tested code highlighting for HTML output format
  • Tested backward compatibility with default configuration
  • Tested switching between different highlighting styles

Related Issue

Closes #398

Additional Notes

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.

[Feature Request]

1 participant