npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tofrankie/github-markdown-css

v0.0.5

Published

GitHub Flavored Markdown CSS bundles

Downloads

675

Readme

@tofrankie/github-markdown-css

基于 @primer/css@primer/primitives 构建的 GitHub Flavored Markdown CSS,旨在让其他 Markdown 渲染工具也有 GitHub Flavored Markdown 一致的表现。

[!IMPORTANT] 在 1.0.0 之前,不排除可能会有重大变更,在升级前请阅读 CHANGELOG

快速开始

你可以根据喜好选择任一主题。

/* 浅色主题 */
@import '@tofrankie/github-markdown-css/light.css';

/* 深色主题 */
@import '@tofrankie/github-markdown-css/dark.css';

/* 根据 prefers-color-scheme 自动切换浅色、深色主题 */
@import '@tofrankie/github-markdown-css/auto.css';

浅色主题:

  • light:GitHub 标准浅色主题,适合默认阅读场景。
  • light-colorblind:浅色主题的色觉友好变体,适合红绿区分更敏感的场景。
  • light-high-contrast:浅色高对比主题,适合需要更强视觉边界的场景。
  • light-tritanopia:浅色主题的蓝黄/蓝绿区分友好变体。
  • light-colorblind-high-contrast:浅色色觉友好加高对比变体。
  • light-tritanopia-high-contrast:浅色蓝黄友好加高对比变体。

深色主题:

  • dark:GitHub 标准深色主题,适合常规夜间阅读。
  • dark-dimmed:更柔和的深色主题,适合低亮度环境长时间阅读。
  • dark-high-contrast:深色高对比主题,适合需要更强视觉分隔的场景。
  • dark-colorblind:深色主题的色觉友好变体,适合红绿区分更敏感的场景。
  • dark-tritanopia:深色主题的蓝黄/蓝绿区分友好变体。
  • dark-colorblind-high-contrast:深色色觉友好加高对比变体。
  • dark-dimmed-high-contrast:更柔和的深色高对比变体。
  • dark-tritanopia-high-contrast:深色蓝黄友好加高对比变体。

自动切换主题:

  • auto:在 lightdark 之间切换。
  • auto-colorblind:在 light-colorblinddark-colorblind 之间切换。
  • auto-high-contrast:在 light-high-contrastdark-high-contrast 之间切换。
  • auto-tritanopia:在 light-tritanopiadark-tritanopia 之间切换。
  • auto-colorblind-high-contrast:在 light-colorblind-high-contrastdark-colorblind-high-contrast 之间切换。
  • auto-tritanopia-high-contrast:在 light-tritanopia-high-contrastdark-tritanopia-high-contrast 之间切换。
  • auto-dimmed:在 lightdark-dimmed 之间切换。
  • auto-dimmed-high-contrast:在 light-high-contrastdark-dimmed-high-contrast 之间切换。

进阶用法

前面 @tofrankie/github-markdown-css/auto.css 是基于 prefers-color-scheme 来切换主题。但这样不太灵活,因为很多网站或 UI 库是基于不同方案实现深浅模式切换的。

这里提供了一些解决方案:

  1. 使用内置方案
  2. 使用仅包含 Markdown CSS 规则的 @tofrankie/github-markdown-css/pure.css,自行设置 CSS 变量
  3. 如果要接入的 Markdown 渲染器未使用 .markdown-body 容器,像 Obsidian 的 .markdown-rendered 容器,你可以使用 SCSS 方案,允许自定义 Selector。

内置方案

primer

适配 Primer,基于其 ThemeProvider 方案来切换主题。

@import '@tofrankie/github-markdown-css/primer/light.css';
@import '@tofrankie/github-markdown-css/primer/dark.css';
@import '@tofrankie/github-markdown-css/primer/auto.css';

vscode

适配 VS Code WebView Extension,基于其 body[data-vscode-theme-kind='vscode-light']body[data-vscode-theme-kind='vscode-dark'] 方案来切换主题。

@import '@tofrankie/github-markdown-css/vscode/light.css';
@import '@tofrankie/github-markdown-css/vscode/dark.css';
@import '@tofrankie/github-markdown-css/vscode/auto.css';

定制化 CSS 方案

如果你想要定制化,可以选择仅包含 Markdown CSS 规则,不含任何 CSS 变量定义的产物,你可以完全自定义 CSS 变量实现定制。

@import '@tofrankie/github-markdown-css/pure.css';

.markdown-body {
  --fgColor-accent: #0969da;
  /* 更多 CSS 变量 artifacts/published/generic/light.css */
}

SCSS 方案

上述方案都有一个特点,限定了 Markdown 渲染容器元素的 className 是 .markdown-body {},但有些工具(如 Obsidian 的 .markdown-rendered {})的渲染容器不是它,所以不适用。因此提供了 SCSS 方案,支持更加自由的用法。

仅含 Markdown CSS 规则

@use '@tofrankie/github-markdown-css/scss' as markdown;

@include markdown.render-rules(
  (
    container: '.markdown-rendered',
  )
);

结果类似这样:

.markdown-rendered a {
  color: var(--fgColor-accent);
}
/* other markdown rules... */

单色主题

@use '@tofrankie/github-markdown-css/scss' as markdown;

@include markdown.render-theme-tokens(
  (
    container: '.markdown-rendered',
    modes: (
      light: (
        selectors: ('body.theme-light .markdown-rendered'),
        tokens: 'light',
      ),
    ),
  )
);

@include markdown.render-rules(
  (
    container: '.markdown-rendered',
  )
);

它对应的结构语义类似:

.markdown-rendered {
  --base-size-16: 1rem;
}

body.theme-light .markdown-rendered {
  --fgColor-accent: #0969da;
}

@media (prefers-color-scheme: dark) {
  body.theme-light .markdown-rendered {
    --fgColor-accent: #0969da;
  }
}

.markdown-rendered a {
  color: var(--fgColor-accent);
}
/* other markdown rules... */

双色主题

@use '@tofrankie/github-markdown-css/scss' as markdown;

@include markdown.render-theme-tokens(
  (
    container: '.markdown-rendered',
    modes: (
      light: (
        selectors: ('body.theme-light .markdown-rendered'),
        tokens: 'light',
      ),
      dark: (
        selectors: ('body.theme-dark .markdown-rendered'),
        tokens: 'dark',
      ),
    ),
  )
);

@include markdown.render-rules(
  (
    container: '.markdown-rendered',
  )
);

它对应的结构语义类似:

.markdown-rendered {
  --base-size-16: 1rem;
}

body.theme-light .markdown-rendered {
  --fgColor-accent: #0969da;
}

@media (prefers-color-scheme: light) {
  body.theme-light .markdown-rendered {
    --fgColor-accent: #0969da;
  }
}

body.theme-dark .markdown-rendered {
  --fgColor-accent: #4493f8;
}

@media (prefers-color-scheme: dark) {
  body.theme-dark .markdown-rendered {
    --fgColor-accent: #4493f8;
  }
}

.markdown-rendered a {
  color: var(--fgColor-accent);
}
/* other markdown rules... */

Credits

License

MIT License © Frankie