@ox-content/vite-plugin 2.86.0 → 2.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +55 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -11
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +59 -11
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +56 -5
- package/dist/index.mjs.map +1 -1
- package/dist/vitepress.cjs +98 -11
- package/dist/vitepress.cjs.map +1 -1
- package/dist/vitepress.mjs +98 -11
- package/dist/vitepress.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -108,6 +108,56 @@ function createMarkdownEnvironment(options) {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
//#endregion
|
|
111
|
+
//#region src/shiki-theme.ts
|
|
112
|
+
/**
|
|
113
|
+
* Name callers pass as `highlightTheme` to render syntax colors as CSS custom
|
|
114
|
+
* properties instead of baked-in hex values.
|
|
115
|
+
*/
|
|
116
|
+
const CSS_VARIABLES_THEME = "css-variables";
|
|
117
|
+
/** Prefix for the emitted properties, matching the rest of the design tokens. */
|
|
118
|
+
const VARIABLE_PREFIX = "--octc-shiki-";
|
|
119
|
+
/**
|
|
120
|
+
* Fallbacks baked into each `var()` so a site with no color scheme installed
|
|
121
|
+
* still renders GitHub Dark colors — the previous default — rather than
|
|
122
|
+
* unstyled text. A `@ox-content/theme-color-*` package overrides them by
|
|
123
|
+
* defining the same properties per mode.
|
|
124
|
+
*/
|
|
125
|
+
const VARIABLE_DEFAULTS = {
|
|
126
|
+
foreground: "#e6edf3",
|
|
127
|
+
background: "#0d1117",
|
|
128
|
+
"token-constant": "#79c0ff",
|
|
129
|
+
"token-string": "#a5d6ff",
|
|
130
|
+
"token-comment": "#8b949e",
|
|
131
|
+
"token-keyword": "#ff7b72",
|
|
132
|
+
"token-parameter": "#ffa657",
|
|
133
|
+
"token-function": "#d2a8ff",
|
|
134
|
+
"token-string-expression": "#a5d6ff",
|
|
135
|
+
"token-punctuation": "#c9d1d9",
|
|
136
|
+
"token-link": "#a5d6ff"
|
|
137
|
+
};
|
|
138
|
+
let cached;
|
|
139
|
+
/**
|
|
140
|
+
* Shiki theme whose every color is a `--octc-shiki-*` custom property.
|
|
141
|
+
*
|
|
142
|
+
* This is what lets syntax highlighting track the active color scheme in both
|
|
143
|
+
* light and dark from a single build: the HTML is generated once, and the
|
|
144
|
+
* properties resolve per mode. A fixed theme like `github-dark` cannot do that,
|
|
145
|
+
* and lands dark token colors on a light code block.
|
|
146
|
+
*/
|
|
147
|
+
function cssVariablesTheme() {
|
|
148
|
+
cached ??= (0, shiki.createCssVariablesTheme)({
|
|
149
|
+
name: CSS_VARIABLES_THEME,
|
|
150
|
+
variablePrefix: VARIABLE_PREFIX,
|
|
151
|
+
variableDefaults: VARIABLE_DEFAULTS,
|
|
152
|
+
fontStyle: true
|
|
153
|
+
});
|
|
154
|
+
return cached;
|
|
155
|
+
}
|
|
156
|
+
/** Resolves the `css-variables` alias; any other value passes through. */
|
|
157
|
+
function resolveHighlightTheme(theme) {
|
|
158
|
+
return theme === "css-variables" ? cssVariablesTheme() : theme;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
111
161
|
//#region src/highlight.ts
|
|
112
162
|
/**
|
|
113
163
|
* Syntax highlighting with Shiki via rehype.
|
|
@@ -160,7 +210,8 @@ async function getHighlighter(theme, customLangs = []) {
|
|
|
160
210
|
}
|
|
161
211
|
return highlighterPromise;
|
|
162
212
|
}
|
|
163
|
-
function normalizeThemeInput(
|
|
213
|
+
function normalizeThemeInput(input) {
|
|
214
|
+
const theme = resolveHighlightTheme(input);
|
|
164
215
|
if (typeof theme === "string") return {
|
|
165
216
|
themeInput: theme,
|
|
166
217
|
themeName: theme
|
|
@@ -269,7 +320,7 @@ function normalizeClassName(className) {
|
|
|
269
320
|
/**
|
|
270
321
|
* Apply syntax highlighting to HTML using Shiki.
|
|
271
322
|
*/
|
|
272
|
-
async function highlightCode(html, theme =
|
|
323
|
+
async function highlightCode(html, theme = CSS_VARIABLES_THEME, langs = []) {
|
|
273
324
|
const result = await (0, unified.unified)().use(rehypeParse$3, { fragment: true }).use(rehypeShikiHighlight, {
|
|
274
325
|
theme,
|
|
275
326
|
langs
|
|
@@ -4877,7 +4928,7 @@ function createFrameworkMarkdownOptions(options) {
|
|
|
4877
4928
|
strikethrough: true,
|
|
4878
4929
|
autolinks: options.gfm,
|
|
4879
4930
|
highlight: false,
|
|
4880
|
-
highlightTheme:
|
|
4931
|
+
highlightTheme: CSS_VARIABLES_THEME,
|
|
4881
4932
|
highlightLangs: [],
|
|
4882
4933
|
mermaid: false,
|
|
4883
4934
|
ogImage: false,
|
|
@@ -6512,7 +6563,7 @@ function resolveOptions(options) {
|
|
|
6512
6563
|
strikethrough: options.strikethrough ?? true,
|
|
6513
6564
|
autolinks: options.autolinks ?? options.gfm ?? true,
|
|
6514
6565
|
highlight: options.highlight ?? false,
|
|
6515
|
-
highlightTheme: options.highlightTheme ?? "
|
|
6566
|
+
highlightTheme: options.highlightTheme ?? "css-variables",
|
|
6516
6567
|
highlightLangs: options.highlightLangs ?? [],
|
|
6517
6568
|
codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),
|
|
6518
6569
|
wikiLinks: resolveWikiLinkOptions(options.wikiLinks, options.base ?? "/"),
|