You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -283,15 +283,62 @@ function applyColors(colors, rules) {
283
283
returnrules;
284
284
}
285
285
286
-
asyncfunctiongetCSS({light ='light', dark ='dark', list =false}={}){
286
+
/**
287
+
* Extract markdown styles from github.com
288
+
*
289
+
* If the `light` and `dark` themes are different the CSS returned will include
290
+
* `prefers-color-scheme` blocks for light and dark that match the specified
291
+
* `light` and `dark` themes (considered "auto" mode). This mode will always
292
+
* `preserveVars` as they are necessary for the `prefers-color-scheme` blocks
293
+
*
294
+
* If the `light` and `dark` themes are equal the output will only contain one
295
+
* theme (considered "single" mode)
296
+
*
297
+
* In "single" mode the output will apply the values of all variables to the
298
+
* rules themselves.The output will not contain any `var(--variable)` statements.
299
+
* You can disable this by setting `preserveVariables` to true
300
+
*
301
+
* @param {Object} options optional options object
302
+
* @param {string} [options.light=light] The theme to use for light theme
303
+
* @param {string} [options.dark=dark] The theme to use for dark theme
304
+
* @param {boolean} [options.list=false] If `true` will return a list of available themes instead of the CSS
305
+
* @param {boolean} [options.preserveVariables=false] If `true` will preserve the block of variables for a given theme even if only exporting one theme. By default variables are applied to the rules themselves and the resulting CSS will not contain any `var(--variable)`
306
+
* @param {boolean} [options.onlyVariables=false] Only output the color variables part of the css. forces `preserveVariables` to be `true`
307
+
* @param {boolean} [options.onlyStyles=false] Only output the style part of the css without any variables. forces `preserveVariables` to be `true` and ignores the theme values. Useful to get the base styles to use multiple themes
308
+
* @param {string} [options.rootSelector=.markdown-body] Set the root selector of the rendered markdown body as it should appear in the output css. Defaults to `.markdown-body`
309
+
*/
310
+
asyncfunctiongetCSS({
311
+
light ='light',
312
+
dark ='dark',
313
+
list =false,
314
+
preserveVariables =false,
315
+
onlyVariables =false,
316
+
onlyStyles =false,
317
+
rootSelector ='.markdown-body',
318
+
}={}){
319
+
if(onlyVariables&&onlyStyles){
320
+
// Would result in an empty output
321
+
thrownewError('May not specify onlyVariables and onlyStyles at the same time');
322
+
}
323
+
324
+
if(rootSelector===''){
325
+
thrownewError('rootSelector may not be an empty string');
0 commit comments