@astrojs/markdown-remark 4.3.0 → 4.3.1
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/highlight.d.ts +3 -1
- package/dist/highlight.js +2 -1
- package/dist/shiki.d.ts +4 -0
- package/dist/shiki.js +4 -0
- package/package.json +1 -1
package/dist/highlight.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Root } from 'hast';
|
|
2
|
-
type Highlighter = (code: string, language: string
|
|
2
|
+
type Highlighter = (code: string, language: string, options?: {
|
|
3
|
+
meta?: string;
|
|
4
|
+
}) => string;
|
|
3
5
|
/**
|
|
4
6
|
* A hast utility to syntax highlight code blocks with a given syntax highlighter.
|
|
5
7
|
*
|
package/dist/highlight.js
CHANGED
|
@@ -30,8 +30,9 @@ function highlightCodeBlocks(tree, highlighter) {
|
|
|
30
30
|
if (languageMatch?.[1] === "math") {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
+
const meta = node.data?.meta ?? node.properties.metastring ?? void 0;
|
|
33
34
|
const code = toText(node, { whitespace: "pre" });
|
|
34
|
-
const html = highlighter(code, languageMatch?.[1] || "plaintext");
|
|
35
|
+
const html = highlighter(code, languageMatch?.[1] || "plaintext", { meta });
|
|
35
36
|
const replacement = fromHtml(html, { fragment: true }).children[0];
|
|
36
37
|
removePosition(replacement);
|
|
37
38
|
const grandParent = ancestors.at(-2);
|
package/dist/shiki.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export interface ShikiHighlighter {
|
|
|
3
3
|
highlight(code: string, lang?: string, options?: {
|
|
4
4
|
inline?: boolean;
|
|
5
5
|
attributes?: Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Raw `meta` information to be used by Shiki transformers
|
|
8
|
+
*/
|
|
9
|
+
meta?: string;
|
|
6
10
|
}): string;
|
|
7
11
|
}
|
|
8
12
|
export declare function createShikiHighlighter({ langs, theme, themes, wrap, transformers, }?: ShikiConfig): Promise<ShikiHighlighter>;
|
package/dist/shiki.js
CHANGED
|
@@ -34,6 +34,10 @@ async function createShikiHighlighter({
|
|
|
34
34
|
return highlighter.codeToHtml(code, {
|
|
35
35
|
...themeOptions,
|
|
36
36
|
lang,
|
|
37
|
+
// NOTE: while we can spread `options.attributes` here so that Shiki can auto-serialize this as rendered
|
|
38
|
+
// attributes on the top-level tag, it's not clear whether it is fine to pass all attributes as meta, as
|
|
39
|
+
// they're technically not meta, nor parsed from Shiki's `parseMetaString` API.
|
|
40
|
+
meta: options?.meta ? { __raw: options?.meta } : void 0,
|
|
37
41
|
transformers: [
|
|
38
42
|
{
|
|
39
43
|
pre(node) {
|