Add stylesInline option to embed user CSS as inline <style> tags#427
Open
isida3 wants to merge 1 commit into
Open
Add stylesInline option to embed user CSS as inline <style> tags#427isida3 wants to merge 1 commit into
isida3 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
markdown-pdf.stylesInlineis set totrue, 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
markdown-pdf.stylesInline(default:false)makeCss()function to read CSS file contents and wrap them in<style>tagsUsage
{ "markdown-pdf.styles": ["/path/to/custom.css"], "markdown-pdf.stylesInline": true }All existing unit tests pass (282 tests, 0 failures).