generate-github-markdown-css
Generate the CSS for github-markdown-css
Get the CSS
See github-markdown-css
How
First the GitHub.com CSS is fetched. Then we walk through all rules that could take effect in Markdown content, and then do a custom cleanup. A rendered Markdown with all possible syntax is fetched from GitHub to check if we've done right.
API
import githubMarkdownCss from 'generate-github-markdown-css';
console.log(await githubMarkdownCss({
light: 'light',
dark: 'dark',
list: false,
preserveVariables: false,
onlyVariables: false,
onlyStyles: false,
rootSelector: '.markdown-body',
}
));
CLI
npm install --global generate-github-markdown-css
$ github-markdown-css --help
Usage
github-markdown-css > <filename>
Options
--list List available themes
Set theme:
--light Light theme name from --list values
--dark Dark theme name from --list values
--theme Theme name: 'auto', light', 'dark', or another from --list values.
'auto' means using the media query (prefers-color-scheme)
to switch between the 'light' and 'dark' theme.
Output options:
--preserve-variables Preserve variables in the output. Only applies if light
and dark themes match or if type is not 'auto'
--only-style Only output the styles, forces --preserve-variables on
--only-variables Only output the variables for the specified themes
--root-selector Specify the root selector when outputting styles, default '.markdown-body'
Examples
$ github-markdown-css --list
light
dark
dark_dimmed
dark_high_contrast
dark_colorblind
light_colorblind
$ github-markdown-css --light=light --dark=dark
[CSS with variable blocks for 'light' and 'dark' themes]
$ github-markdown-css --theme=dark_dimmed --only-variables
[CSS with single variable block for 'dark_dimmed' theme with no element styles]
$ github-markdown-css --only-style
[CSS with only element styles using variables but no variables set.
Use in combination with output from setting --only-variables]