Skip to content

Add stylesInline option to embed user CSS as inline <style> tags#427

Open
isida3 wants to merge 1 commit into
yzane:masterfrom
isida3:feature/styles-inline
Open

Add stylesInline option to embed user CSS as inline <style> tags#427
isida3 wants to merge 1 commit into
yzane:masterfrom
isida3:feature/styles-inline

Conversation

@isida3
Copy link
Copy Markdown

@isida3 isida3 commented Apr 13, 2026

Summary

When markdown-pdf.stylesInline is set to true, user-specified CSS files (markdown-pdf.styles) are embedded as inline <style> tags instead of <link> references in the HTML output.

Problem

When generating HTML in a WSL environment and opening it in a Windows browser, the file:///home/... paths in <link> tags cannot be resolved. This makes user-specified CSS effectively invisible in the HTML output, even though it works fine for PDF output (where Puppeteer can access local files).

Solution

  • Added a new boolean setting markdown-pdf.stylesInline (default: false)
  • When enabled, reuses the existing makeCss() function to read CSS file contents and wrap them in <style> tags
  • No change in behavior when disabled — fully backward compatible

Usage

{
  "markdown-pdf.styles": ["/path/to/custom.css"],
  "markdown-pdf.stylesInline": true
}

All existing unit tests pass (282 tests, 0 failures).

Note: This addresses the same use case as #319, updated for the v2.0.0 TypeScript codebase with unit tests.

When markdown-pdf.stylesInline is set to true, user-specified CSS files
(markdown-pdf.styles) are embedded as inline <style> tags instead of
<link> references. This is useful when opening HTML output on a different
OS than where it was generated (e.g. WSL to Windows), where file:///
paths in <link> tags cannot be resolved by the browser.

The default is false, preserving existing behavior.
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