@shikijs/markdown-it 1.6.1 → 1.6.2
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/core.d.mts +11 -1
- package/dist/core.d.ts +11 -1
- package/dist/core.mjs +10 -1
- package/package.json +3 -3
package/dist/core.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MarkdownIt from 'markdown-it';
|
|
2
|
-
import { CodeOptionsThemes, BuiltinTheme, TransformerOptions, CodeOptionsMeta, HighlighterGeneric } from 'shiki';
|
|
2
|
+
import { LanguageInput, BuiltinLanguage, CodeOptionsThemes, BuiltinTheme, TransformerOptions, CodeOptionsMeta, HighlighterGeneric } from 'shiki';
|
|
3
3
|
|
|
4
4
|
interface MarkdownItShikiExtraOptions {
|
|
5
5
|
/**
|
|
@@ -16,6 +16,16 @@ interface MarkdownItShikiExtraOptions {
|
|
|
16
16
|
* @default true
|
|
17
17
|
*/
|
|
18
18
|
trimEndingNewline?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* When lang of code block is empty string, it will work.
|
|
21
|
+
*
|
|
22
|
+
* @default 'text'
|
|
23
|
+
*/
|
|
24
|
+
defaultLanguage?: LanguageInput | BuiltinLanguage;
|
|
25
|
+
/**
|
|
26
|
+
* When lang of code block is not included in langs of options, it will be as a fallback lang.
|
|
27
|
+
*/
|
|
28
|
+
fallbackLanguage?: LanguageInput | BuiltinLanguage;
|
|
19
29
|
}
|
|
20
30
|
type MarkdownItShikiSetupOptions = CodeOptionsThemes<BuiltinTheme> & TransformerOptions & CodeOptionsMeta & MarkdownItShikiExtraOptions;
|
|
21
31
|
declare function setupMarkdownIt(markdownit: MarkdownIt, highlighter: HighlighterGeneric<any, any>, options: MarkdownItShikiSetupOptions): void;
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MarkdownIt from 'markdown-it';
|
|
2
|
-
import { CodeOptionsThemes, BuiltinTheme, TransformerOptions, CodeOptionsMeta, HighlighterGeneric } from 'shiki';
|
|
2
|
+
import { LanguageInput, BuiltinLanguage, CodeOptionsThemes, BuiltinTheme, TransformerOptions, CodeOptionsMeta, HighlighterGeneric } from 'shiki';
|
|
3
3
|
|
|
4
4
|
interface MarkdownItShikiExtraOptions {
|
|
5
5
|
/**
|
|
@@ -16,6 +16,16 @@ interface MarkdownItShikiExtraOptions {
|
|
|
16
16
|
* @default true
|
|
17
17
|
*/
|
|
18
18
|
trimEndingNewline?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* When lang of code block is empty string, it will work.
|
|
21
|
+
*
|
|
22
|
+
* @default 'text'
|
|
23
|
+
*/
|
|
24
|
+
defaultLanguage?: LanguageInput | BuiltinLanguage;
|
|
25
|
+
/**
|
|
26
|
+
* When lang of code block is not included in langs of options, it will be as a fallback lang.
|
|
27
|
+
*/
|
|
28
|
+
fallbackLanguage?: LanguageInput | BuiltinLanguage;
|
|
19
29
|
}
|
|
20
30
|
type MarkdownItShikiSetupOptions = CodeOptionsThemes<BuiltinTheme> & TransformerOptions & CodeOptionsMeta & MarkdownItShikiExtraOptions;
|
|
21
31
|
declare function setupMarkdownIt(markdownit: MarkdownIt, highlighter: HighlighterGeneric<any, any>, options: MarkdownItShikiSetupOptions): void;
|
package/dist/core.mjs
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
function setupMarkdownIt(markdownit, highlighter, options) {
|
|
2
2
|
const {
|
|
3
3
|
parseMetaString,
|
|
4
|
-
trimEndingNewline = true
|
|
4
|
+
trimEndingNewline = true,
|
|
5
|
+
defaultLanguage = "text",
|
|
6
|
+
fallbackLanguage
|
|
5
7
|
} = options;
|
|
8
|
+
const langs = highlighter.getLoadedLanguages();
|
|
6
9
|
markdownit.options.highlight = (code, lang = "text", attrs) => {
|
|
10
|
+
if (lang === "") {
|
|
11
|
+
lang = defaultLanguage;
|
|
12
|
+
}
|
|
13
|
+
if (fallbackLanguage && !langs.includes(lang)) {
|
|
14
|
+
lang = fallbackLanguage;
|
|
15
|
+
}
|
|
7
16
|
const meta = parseMetaString?.(attrs, code, lang) || {};
|
|
8
17
|
const codeOptions = {
|
|
9
18
|
...options,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/markdown-it",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.2",
|
|
5
5
|
"description": "markdown-it integration for shiki",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"markdown-it": "^14.1.0",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
49
|
+
"@shikijs/transformers": "1.6.2",
|
|
50
|
+
"shiki": "1.6.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/markdown-it": "^14.1.1"
|