@shikijs/markdown-it 1.1.1 → 1.1.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 CHANGED
@@ -7,6 +7,15 @@ interface MarkdownItShikiExtraOptions {
7
7
  * Return an object to merge with `meta`
8
8
  */
9
9
  parseMetaString?: (metaString: string, code: string, lang: string) => Record<string, any> | undefined | null;
10
+ /**
11
+ * markdown-it's highlight function will add a trailing newline to the code.
12
+ *
13
+ * This integration removes the trailing newline to the code by default,
14
+ * you can turn this off by passing false.
15
+ *
16
+ * @default true
17
+ */
18
+ trimEndingNewline?: boolean;
10
19
  }
11
20
  type MarkdownItShikiSetupOptions = CodeOptionsThemes<BuiltinTheme> & TransformerOptions & CodeOptionsMeta & MarkdownItShikiExtraOptions;
12
21
  declare function setupMarkdownIt(markdownit: MarkdownIt, highlighter: HighlighterGeneric<any, any>, options: MarkdownItShikiSetupOptions): void;
package/dist/core.d.ts CHANGED
@@ -7,6 +7,15 @@ interface MarkdownItShikiExtraOptions {
7
7
  * Return an object to merge with `meta`
8
8
  */
9
9
  parseMetaString?: (metaString: string, code: string, lang: string) => Record<string, any> | undefined | null;
10
+ /**
11
+ * markdown-it's highlight function will add a trailing newline to the code.
12
+ *
13
+ * This integration removes the trailing newline to the code by default,
14
+ * you can turn this off by passing false.
15
+ *
16
+ * @default true
17
+ */
18
+ trimEndingNewline?: boolean;
10
19
  }
11
20
  type MarkdownItShikiSetupOptions = CodeOptionsThemes<BuiltinTheme> & TransformerOptions & CodeOptionsMeta & MarkdownItShikiExtraOptions;
12
21
  declare function setupMarkdownIt(markdownit: MarkdownIt, highlighter: HighlighterGeneric<any, any>, options: MarkdownItShikiSetupOptions): void;
package/dist/core.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  function setupMarkdownIt(markdownit, highlighter, options) {
2
2
  const {
3
- parseMetaString
3
+ parseMetaString,
4
+ trimEndingNewline = true
4
5
  } = options;
5
6
  markdownit.options.highlight = (code, lang = "text", attrs) => {
6
7
  const meta = parseMetaString?.(attrs, code, lang) || {};
@@ -20,6 +21,10 @@ function setupMarkdownIt(markdownit, highlighter, options) {
20
21
  node.properties.class = `language-${lang}`;
21
22
  }
22
23
  });
24
+ if (trimEndingNewline) {
25
+ if (code.endsWith("\n"))
26
+ code = code.slice(0, -1);
27
+ }
23
28
  return highlighter.codeToHtml(
24
29
  code,
25
30
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/markdown-it",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.1.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.0.0",
49
- "shiki": "1.1.1",
50
- "@shikijs/transformers": "1.1.1"
49
+ "shiki": "1.1.2",
50
+ "@shikijs/transformers": "1.1.2"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/markdown-it": "^13.0.7"