svedocs 0.1.0-beta.10 → 0.1.0-beta.11
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/mdx/code.d.ts.map +1 -1
- package/dist/mdx/code.js +29 -1
- package/dist/theme/base.css +1 -0
- package/dist/theme/styles.css +21 -17
- package/package.json +1 -1
package/dist/mdx/code.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/mdx/code.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAY1E,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,eAAe,EACf,WAAW,GAAG,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,CAC1F,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,EAAE,CA6BtE;AAED,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,gBAAgB,EAAO,IAC1D,MAAM,OAAO,UAwBtB;AAED,wBAAgB,uBAAuB,CACrC,UAAU,GAAE,gBAAgB,EAAO,EACnC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAA;CAAO,IAErM,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/mdx/code.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAY1E,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,eAAe,EACf,WAAW,GAAG,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,CAC1F,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,EAAE,CA6BtE;AAED,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,gBAAgB,EAAO,IAC1D,MAAM,OAAO,UAwBtB;AAED,wBAAgB,uBAAuB,CACrC,UAAU,GAAE,gBAAgB,EAAO,EACnC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAA;CAAO,IAErM,MAAM,OAAO,mBAgE5B"}
|
package/dist/mdx/code.js
CHANGED
|
@@ -84,6 +84,10 @@ export function remarkSvedocsCodeBlocks(codeBlocks = [], options = {}) {
|
|
|
84
84
|
const useDualTheme = Boolean(themes?.light && themes?.dark);
|
|
85
85
|
const renderLineNumbers = showLineNumbers && !block.noLineNumbers;
|
|
86
86
|
const wrapLines = typeof block.wrap === 'boolean' ? block.wrap : globalWrap;
|
|
87
|
+
const transformers = [
|
|
88
|
+
...(options.transformers ?? []),
|
|
89
|
+
forceShikiTextColorTransformer
|
|
90
|
+
];
|
|
87
91
|
transforms.push(shiki
|
|
88
92
|
.codeToHtml(node.value, {
|
|
89
93
|
lang: normalizeShikiLanguage(block.language),
|
|
@@ -93,7 +97,7 @@ export function remarkSvedocsCodeBlocks(codeBlocks = [], options = {}) {
|
|
|
93
97
|
defaultColor: false
|
|
94
98
|
}
|
|
95
99
|
: { theme: options.theme ?? themes?.dark ?? 'github-dark' }),
|
|
96
|
-
|
|
100
|
+
transformers: transformers
|
|
97
101
|
})
|
|
98
102
|
.then((html) => {
|
|
99
103
|
parent.children[childIndex] = {
|
|
@@ -116,6 +120,30 @@ export function remarkSvedocsCodeBlocks(codeBlocks = [], options = {}) {
|
|
|
116
120
|
await Promise.all(transforms);
|
|
117
121
|
};
|
|
118
122
|
}
|
|
123
|
+
const forceShikiTextColorTransformer = {
|
|
124
|
+
name: 'svedocs:force-text-color',
|
|
125
|
+
pre(node) {
|
|
126
|
+
protectShikiTextColor(node.properties);
|
|
127
|
+
},
|
|
128
|
+
span(node) {
|
|
129
|
+
protectShikiTextColor(node.properties);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
function protectShikiTextColor(properties) {
|
|
133
|
+
if (!properties || typeof properties.style !== 'string')
|
|
134
|
+
return;
|
|
135
|
+
const style = properties.style;
|
|
136
|
+
properties.style = style
|
|
137
|
+
.split(';')
|
|
138
|
+
.map((declaration) => {
|
|
139
|
+
const separator = declaration.indexOf(':');
|
|
140
|
+
if (separator < 0 || declaration.slice(0, separator).trim().toLowerCase() !== 'color') {
|
|
141
|
+
return declaration;
|
|
142
|
+
}
|
|
143
|
+
return /!important\s*$/i.test(declaration) ? declaration : `${declaration} !important`;
|
|
144
|
+
})
|
|
145
|
+
.join(';');
|
|
146
|
+
}
|
|
119
147
|
function parseCodeInfo(info) {
|
|
120
148
|
const [languageToken = 'text', ...rest] = info.split(/\s+/).filter(Boolean);
|
|
121
149
|
const language = languageToken || 'text';
|
package/dist/theme/base.css
CHANGED
package/dist/theme/styles.css
CHANGED
|
@@ -50,7 +50,7 @@ html:has(.sd-root[data-theme="dark"]),
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
html {
|
|
53
|
-
scroll-behavior:
|
|
53
|
+
scroll-behavior: smooth;
|
|
54
54
|
background: var(--sd-bg);
|
|
55
55
|
color: var(--sd-ink);
|
|
56
56
|
overflow-y: auto;
|
|
@@ -2793,22 +2793,24 @@ body.sd-is-window-scrolling::-webkit-scrollbar-thumb,
|
|
|
2793
2793
|
.sd-code.shiki,
|
|
2794
2794
|
.sd-prose pre.shiki {
|
|
2795
2795
|
background-color: #fbfbfa !important;
|
|
2796
|
-
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
.sd-code.shiki[style*="--shiki-light:"],
|
|
2799
|
+
.sd-prose pre.shiki[style*="--shiki-light:"] {
|
|
2800
|
+
color: var(--shiki-light) !important;
|
|
2797
2801
|
}
|
|
2798
2802
|
|
|
2799
2803
|
.sd-code.shiki code,
|
|
2800
2804
|
.sd-prose pre.shiki code {
|
|
2801
|
-
color: inherit;
|
|
2805
|
+
color: inherit !important;
|
|
2802
2806
|
}
|
|
2803
2807
|
|
|
2804
|
-
.sd-code.shiki
|
|
2805
|
-
.sd-prose pre.shiki
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
font-weight: var(--shiki-light-font-weight, inherit);
|
|
2811
|
-
text-decoration: var(--shiki-light-text-decoration, none);
|
|
2808
|
+
.sd-code.shiki [style*="--shiki-light:"],
|
|
2809
|
+
.sd-prose pre.shiki [style*="--shiki-light:"] {
|
|
2810
|
+
color: var(--shiki-light) !important;
|
|
2811
|
+
font-style: var(--shiki-light-font-style, normal) !important;
|
|
2812
|
+
font-weight: var(--shiki-light-font-weight, inherit) !important;
|
|
2813
|
+
text-decoration: var(--shiki-light-text-decoration, none) !important;
|
|
2812
2814
|
}
|
|
2813
2815
|
|
|
2814
2816
|
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-code,
|
|
@@ -2821,14 +2823,16 @@ body.sd-is-window-scrolling::-webkit-scrollbar-thumb,
|
|
|
2821
2823
|
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-code.shiki,
|
|
2822
2824
|
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-prose pre.shiki {
|
|
2823
2825
|
background-color: #1e1e1e !important;
|
|
2824
|
-
color: var(--shiki-dark, #d4d4d4) !important;
|
|
2825
2826
|
}
|
|
2826
2827
|
|
|
2827
|
-
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-code.shiki
|
|
2828
|
-
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-prose pre.shiki
|
|
2829
|
-
:
|
|
2830
|
-
|
|
2831
|
-
|
|
2828
|
+
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-code.shiki[style*="--shiki-dark:"],
|
|
2829
|
+
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-prose pre.shiki[style*="--shiki-dark:"] {
|
|
2830
|
+
color: var(--shiki-dark) !important;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-code.shiki [style*="--shiki-dark:"],
|
|
2834
|
+
:is(:root[data-theme="dark"], html:has(.sd-root[data-theme="dark"])) .sd-prose pre.shiki [style*="--shiki-dark:"] {
|
|
2835
|
+
color: var(--shiki-dark) !important;
|
|
2832
2836
|
font-style: var(--shiki-dark-font-style, normal) !important;
|
|
2833
2837
|
font-weight: var(--shiki-dark-font-weight, inherit) !important;
|
|
2834
2838
|
text-decoration: var(--shiki-dark-text-decoration, none) !important;
|