@nuxtjs/mdc 0.7.1 → 0.8.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/README.md +1 -1
- package/dist/config.d.mts +45 -1
- package/dist/config.d.ts +45 -1
- package/dist/module.d.mts +3 -3
- package/dist/module.d.ts +3 -3
- package/dist/module.json +2 -2
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/MDC.vue +1 -1
- package/dist/runtime/components/MDCRenderer.vue.d.ts +1 -1
- package/dist/runtime/components/prose/ProseH1.vue +1 -1
- package/dist/runtime/components/prose/ProseH2.vue +1 -1
- package/dist/runtime/components/prose/ProseH3.vue +1 -1
- package/dist/runtime/components/prose/ProseH4.vue +1 -1
- package/dist/runtime/components/prose/ProseH5.vue +1 -1
- package/dist/runtime/components/prose/ProseH6.vue +1 -1
- package/dist/runtime/highlighter/rehype-nuxt.d.ts +1 -1
- package/dist/runtime/highlighter/{rehype-nuxt.mjs → rehype-nuxt.js} +1 -1
- package/dist/runtime/highlighter/rehype.d.ts +1 -1
- package/dist/runtime/highlighter/shiki.d.ts +2 -2
- package/dist/runtime/index.d.ts +4 -4
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/parser/compiler.d.ts +1 -1
- package/dist/runtime/parser/{compiler.mjs → compiler.js} +1 -1
- package/dist/runtime/parser/handlers/{code.mjs → code.js} +1 -2
- package/dist/runtime/parser/handlers/{html.mjs → html.js} +1 -1
- package/dist/runtime/parser/handlers/index.d.ts +9 -9
- package/dist/runtime/parser/handlers/index.js +22 -0
- package/dist/runtime/parser/handlers/{paragraph.mjs → paragraph.js} +2 -2
- package/dist/runtime/parser/handlers/{utils.mjs → utils.js} +4 -4
- package/dist/runtime/parser/index.d.ts +1 -1
- package/dist/runtime/parser/{index.mjs → index.js} +5 -5
- package/dist/runtime/parser/options.d.ts +1 -1
- package/dist/runtime/parser/{options.mjs → options.js} +1 -1
- package/dist/runtime/parser/toc.d.ts +1 -1
- package/dist/runtime/parser/{toc.mjs → toc.js} +1 -1
- package/dist/runtime/parser/utils/plugins.d.ts +1 -1
- package/dist/runtime/utils/ast.d.ts +1 -1
- package/dist/runtime/utils/node.d.ts +1 -1
- package/dist/runtime/utils/slot.d.ts +1 -1
- package/dist/runtime/utils/{slot.mjs → slot.js} +1 -1
- package/dist/runtime/utils/{ssrSlot.mjs → ssrSlot.js} +1 -1
- package/dist/shared/mdc.a6f76af4.d.mts +9 -0
- package/dist/shared/mdc.a6f76af4.d.ts +9 -0
- package/dist/types.d.mts +11 -2
- package/dist/types.d.ts +11 -2
- package/package.json +24 -20
- package/dist/runtime/highlighter/types.d.ts +0 -14
- package/dist/runtime/highlighter/types.mjs +0 -0
- package/dist/runtime/index.mjs +0 -4
- package/dist/runtime/parser/handlers/index.mjs +0 -22
- package/dist/runtime/types/config.d.ts +0 -44
- package/dist/runtime/types/config.mjs +0 -0
- package/dist/runtime/types/hast.d.ts +0 -255
- package/dist/runtime/types/hast.mjs +0 -0
- package/dist/runtime/types/index.d.ts +0 -3
- package/dist/runtime/types/index.mjs +0 -3
- package/dist/runtime/types/parser.d.ts +0 -41
- package/dist/runtime/types/parser.mjs +0 -0
- package/dist/runtime/types/toc.d.ts +0 -12
- package/dist/runtime/types/toc.mjs +0 -0
- package/dist/runtime/types/tree.d.ts +0 -23
- package/dist/runtime/types/tree.mjs +0 -0
- package/dist/runtime/types/unist.d.ts +0 -107
- package/dist/runtime/types/unist.mjs +0 -0
- /package/dist/runtime/highlighter/{event-handler.mjs → event-handler.js} +0 -0
- /package/dist/runtime/highlighter/{rehype.mjs → rehype.js} +0 -0
- /package/dist/runtime/highlighter/{shiki.mjs → shiki.js} +0 -0
- /package/dist/runtime/parser/handlers/{containerComponent.mjs → containerComponent.js} +0 -0
- /package/dist/runtime/parser/handlers/{emphasis.mjs → emphasis.js} +0 -0
- /package/dist/runtime/parser/handlers/{image.mjs → image.js} +0 -0
- /package/dist/runtime/parser/handlers/{inlineCode.mjs → inlineCode.js} +0 -0
- /package/dist/runtime/parser/handlers/{link.mjs → link.js} +0 -0
- /package/dist/runtime/parser/handlers/{list.mjs → list.js} +0 -0
- /package/dist/runtime/parser/handlers/{strong.mjs → strong.js} +0 -0
- /package/dist/runtime/parser/utils/{html-tags-list.mjs → html-tags-list.js} +0 -0
- /package/dist/runtime/parser/utils/{plugins.mjs → plugins.js} +0 -0
- /package/dist/runtime/parser/utils/{props.mjs → props.js} +0 -0
- /package/dist/runtime/utils/{ast.mjs → ast.js} +0 -0
- /package/dist/runtime/utils/{node.mjs → node.js} +0 -0
package/README.md
CHANGED
|
@@ -367,7 +367,7 @@ Now import the `useMarkdownParser` composable we just created along with an expo
|
|
|
367
367
|
import { onBeforeMount, ref, watch } from 'vue'
|
|
368
368
|
// Import package exports
|
|
369
369
|
import MDCRenderer from '@nuxtjs/mdc/runtime/components/MDCRenderer.vue'
|
|
370
|
-
import type { MDCParserResult } from '@nuxtjs/mdc
|
|
370
|
+
import type { MDCParserResult } from '@nuxtjs/mdc'
|
|
371
371
|
import useMarkdownParser from './composables/useMarkdownParser';
|
|
372
372
|
|
|
373
373
|
const md = ref(`
|
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Highlighter, ShikiTransformer, HighlighterCore } from 'shiki';
|
|
2
|
+
import { Processor } from 'unified';
|
|
3
|
+
import { M as MdcThemeOptions, H as HighlighterOptions } from './shared/mdc.a6f76af4.mjs';
|
|
4
|
+
|
|
5
|
+
type Awaitable<T> = T | Promise<T>;
|
|
6
|
+
interface MdcConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Hooks for the unified markdown pipeline
|
|
9
|
+
*/
|
|
10
|
+
unified?: {
|
|
11
|
+
/**
|
|
12
|
+
* Custom setup for unified processor before other plugins
|
|
13
|
+
*/
|
|
14
|
+
pre?: (processor: Processor) => Awaitable<void | Processor>;
|
|
15
|
+
/**
|
|
16
|
+
* Custom setup for unified processor after remark but before rehype
|
|
17
|
+
*/
|
|
18
|
+
remark?: (processor: Processor) => Awaitable<void | Processor>;
|
|
19
|
+
/**
|
|
20
|
+
* Custom setup for unified processor after rehype
|
|
21
|
+
*/
|
|
22
|
+
rehype?: (processor: Processor) => Awaitable<void | Processor>;
|
|
23
|
+
/**
|
|
24
|
+
* Custom setup for unified processor after all plugins
|
|
25
|
+
*/
|
|
26
|
+
post?: (processor: Processor) => Awaitable<void | Processor>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Custom hightlighter, available when `highlighter` is set to `custom`
|
|
30
|
+
*/
|
|
31
|
+
highlighter?: Highlighter;
|
|
32
|
+
/**
|
|
33
|
+
* Hooks for shiki
|
|
34
|
+
*/
|
|
35
|
+
shiki?: {
|
|
36
|
+
/**
|
|
37
|
+
* Get transformers for shiki
|
|
38
|
+
*/
|
|
39
|
+
transformers?: ShikiTransformer[] | ((code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Awaitable<ShikiTransformer[]>);
|
|
40
|
+
/**
|
|
41
|
+
* Custom setup for shiki instance, only called once on server or client
|
|
42
|
+
*/
|
|
43
|
+
setup?: (highlighter: HighlighterCore) => Awaitable<void>;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
2
46
|
|
|
3
47
|
declare function defineConfig(config: MdcConfig): MdcConfig;
|
|
4
48
|
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Highlighter, ShikiTransformer, HighlighterCore } from 'shiki';
|
|
2
|
+
import { Processor } from 'unified';
|
|
3
|
+
import { M as MdcThemeOptions, H as HighlighterOptions } from './shared/mdc.a6f76af4.js';
|
|
4
|
+
|
|
5
|
+
type Awaitable<T> = T | Promise<T>;
|
|
6
|
+
interface MdcConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Hooks for the unified markdown pipeline
|
|
9
|
+
*/
|
|
10
|
+
unified?: {
|
|
11
|
+
/**
|
|
12
|
+
* Custom setup for unified processor before other plugins
|
|
13
|
+
*/
|
|
14
|
+
pre?: (processor: Processor) => Awaitable<void | Processor>;
|
|
15
|
+
/**
|
|
16
|
+
* Custom setup for unified processor after remark but before rehype
|
|
17
|
+
*/
|
|
18
|
+
remark?: (processor: Processor) => Awaitable<void | Processor>;
|
|
19
|
+
/**
|
|
20
|
+
* Custom setup for unified processor after rehype
|
|
21
|
+
*/
|
|
22
|
+
rehype?: (processor: Processor) => Awaitable<void | Processor>;
|
|
23
|
+
/**
|
|
24
|
+
* Custom setup for unified processor after all plugins
|
|
25
|
+
*/
|
|
26
|
+
post?: (processor: Processor) => Awaitable<void | Processor>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Custom hightlighter, available when `highlighter` is set to `custom`
|
|
30
|
+
*/
|
|
31
|
+
highlighter?: Highlighter;
|
|
32
|
+
/**
|
|
33
|
+
* Hooks for shiki
|
|
34
|
+
*/
|
|
35
|
+
shiki?: {
|
|
36
|
+
/**
|
|
37
|
+
* Get transformers for shiki
|
|
38
|
+
*/
|
|
39
|
+
transformers?: ShikiTransformer[] | ((code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Awaitable<ShikiTransformer[]>);
|
|
40
|
+
/**
|
|
41
|
+
* Custom setup for shiki instance, only called once on server or client
|
|
42
|
+
*/
|
|
43
|
+
setup?: (highlighter: HighlighterCore) => Awaitable<void>;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
2
46
|
|
|
3
47
|
declare function defineConfig(config: MdcConfig): MdcConfig;
|
|
4
48
|
|
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { BundledLanguage, LanguageRegistration, BundledTheme, ThemeRegistrationAny } from 'shiki';
|
|
3
|
-
import { MdcThemeOptions } from './
|
|
3
|
+
import { M as MdcThemeOptions } from './shared/mdc.a6f76af4.mjs';
|
|
4
4
|
|
|
5
5
|
interface UnistPlugin {
|
|
6
6
|
src?: string;
|
|
@@ -60,7 +60,7 @@ interface ModuleOptions {
|
|
|
60
60
|
headings?: {
|
|
61
61
|
anchorLinks?: {
|
|
62
62
|
[heading in 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6']?: boolean;
|
|
63
|
-
} |
|
|
63
|
+
} | boolean;
|
|
64
64
|
};
|
|
65
65
|
keepComments?: boolean;
|
|
66
66
|
components?: {
|
|
@@ -101,4 +101,4 @@ declare module '@nuxt/schema' {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export { DefaultHighlightLangs, _default as default };
|
|
104
|
+
export { DefaultHighlightLangs, type ModuleOptions, type UnistPlugin, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { BundledLanguage, LanguageRegistration, BundledTheme, ThemeRegistrationAny } from 'shiki';
|
|
3
|
-
import { MdcThemeOptions } from './
|
|
3
|
+
import { M as MdcThemeOptions } from './shared/mdc.a6f76af4.js';
|
|
4
4
|
|
|
5
5
|
interface UnistPlugin {
|
|
6
6
|
src?: string;
|
|
@@ -60,7 +60,7 @@ interface ModuleOptions {
|
|
|
60
60
|
headings?: {
|
|
61
61
|
anchorLinks?: {
|
|
62
62
|
[heading in 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6']?: boolean;
|
|
63
|
-
} |
|
|
63
|
+
} | boolean;
|
|
64
64
|
};
|
|
65
65
|
keepComments?: boolean;
|
|
66
66
|
components?: {
|
|
@@ -101,4 +101,4 @@ declare module '@nuxt/schema' {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export { DefaultHighlightLangs, _default as default };
|
|
104
|
+
export { DefaultHighlightLangs, type ModuleOptions, type UnistPlugin, _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -292,12 +292,12 @@ const module = defineNuxtModule({
|
|
|
292
292
|
options: { configs: mdcConfigs$1 }
|
|
293
293
|
});
|
|
294
294
|
const nitroPreset = nuxt.options.nitro.preset || process.env.NITRO_PRESET || process.env.SERVER_PRESET || "";
|
|
295
|
-
const useWasmAssets = !nuxt.options.dev && (!!nuxt.options.nitro.experimental?.wasm || ["cloudflare-pages", "cloudflare"].includes(nitroPreset));
|
|
295
|
+
const useWasmAssets = !nuxt.options.dev && (!!nuxt.options.nitro.experimental?.wasm || ["cloudflare-pages", "cloudflare-module", "cloudflare"].includes(nitroPreset));
|
|
296
296
|
registerTemplate({
|
|
297
297
|
filename: "mdc-highlighter.mjs",
|
|
298
298
|
getContents: mdcHighlighter,
|
|
299
299
|
options: {
|
|
300
|
-
shikiPath: resolver.resolve("../dist/runtime/highlighter/shiki"),
|
|
300
|
+
shikiPath: resolver.resolve("../dist/runtime/highlighter/shiki.js"),
|
|
301
301
|
options: options.highlight,
|
|
302
302
|
useWasmAssets
|
|
303
303
|
}
|
|
@@ -22,7 +22,7 @@ import { hash } from 'ohash'
|
|
|
22
22
|
import { useAsyncData } from 'nuxt/app'
|
|
23
23
|
import { watch, computed, type PropType } from 'vue'
|
|
24
24
|
import { parseMarkdown } from '../parser'
|
|
25
|
-
import type { MDCParseOptions } from '
|
|
25
|
+
import type { MDCParseOptions } from '../../types'
|
|
26
26
|
|
|
27
27
|
const props = defineProps({
|
|
28
28
|
tag: {
|
|
@@ -16,5 +16,5 @@ import { computed, useRuntimeConfig } from '#imports'
|
|
|
16
16
|
const props = defineProps<{ id?: string }>()
|
|
17
17
|
|
|
18
18
|
const { headings } = useRuntimeConfig().public.mdc
|
|
19
|
-
const generate = computed(() => props.id && headings?.anchorLinks?.h1)
|
|
19
|
+
const generate = computed(() => props.id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h1)))
|
|
20
20
|
</script>
|
|
@@ -16,5 +16,5 @@ import { computed, useRuntimeConfig } from '#imports'
|
|
|
16
16
|
const props = defineProps<{ id?: string }>()
|
|
17
17
|
|
|
18
18
|
const { headings } = useRuntimeConfig().public.mdc
|
|
19
|
-
const generate = computed(() => props.id && headings?.anchorLinks?.h2)
|
|
19
|
+
const generate = computed(() => props.id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h2)))
|
|
20
20
|
</script>
|
|
@@ -16,5 +16,5 @@ import { computed, useRuntimeConfig } from '#imports'
|
|
|
16
16
|
const props = defineProps<{ id?: string }>()
|
|
17
17
|
|
|
18
18
|
const { headings } = useRuntimeConfig().public.mdc
|
|
19
|
-
const generate = computed(() => props.id && headings?.anchorLinks?.h3)
|
|
19
|
+
const generate = computed(() => props.id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h3)))
|
|
20
20
|
</script>
|
|
@@ -16,5 +16,5 @@ import { computed, useRuntimeConfig } from '#imports'
|
|
|
16
16
|
const props = defineProps<{ id?: string }>()
|
|
17
17
|
|
|
18
18
|
const { headings } = useRuntimeConfig().public.mdc
|
|
19
|
-
const generate = computed(() => props.id && headings?.anchorLinks?.h4)
|
|
19
|
+
const generate = computed(() => props.id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h4)))
|
|
20
20
|
</script>
|
|
@@ -16,5 +16,5 @@ import { computed, useRuntimeConfig } from '#imports'
|
|
|
16
16
|
const props = defineProps<{ id?: string }>()
|
|
17
17
|
|
|
18
18
|
const { headings } = useRuntimeConfig().public.mdc
|
|
19
|
-
const generate = computed(() => props.id && headings?.anchorLinks?.h5)
|
|
19
|
+
const generate = computed(() => props.id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h5)))
|
|
20
20
|
</script>
|
|
@@ -16,5 +16,5 @@ import { computed, useRuntimeConfig } from '#imports'
|
|
|
16
16
|
const props = defineProps<{ id?: string }>()
|
|
17
17
|
|
|
18
18
|
const { headings } = useRuntimeConfig().public.mdc
|
|
19
|
-
const generate = computed(() => props.id && headings?.anchorLinks?.h6)
|
|
19
|
+
const generate = computed(() => props.id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h6)))
|
|
20
20
|
</script>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type RehypeHighlightOption } from './rehype';
|
|
1
|
+
import { type RehypeHighlightOption } from './rehype.js';
|
|
2
2
|
export default rehypeHighlight;
|
|
3
3
|
export declare function rehypeHighlight(opts?: Partial<RehypeHighlightOption>): (tree: import("hast").Root) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Root } from 'hast';
|
|
2
|
-
import type { Highlighter, MdcThemeOptions } from '
|
|
2
|
+
import type { Highlighter, MdcThemeOptions } from '../../types/highlighter.js';
|
|
3
3
|
export interface RehypeHighlightOption {
|
|
4
4
|
theme?: MdcThemeOptions;
|
|
5
5
|
highlighter?: Highlighter;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LanguageInput, ThemeInput } from 'shiki';
|
|
2
|
-
import type { MdcConfig } from '
|
|
3
|
-
import type { Highlighter } from '
|
|
2
|
+
import type { MdcConfig } from '../../types/config.js';
|
|
3
|
+
import type { Highlighter } from '../../types/highlighter.js';
|
|
4
4
|
export interface CreateShikiHighlighterOptions {
|
|
5
5
|
themes?: ThemeInput[];
|
|
6
6
|
langs?: LanguageInput[];
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { parseMarkdown, createMarkdownParser } from './parser';
|
|
2
|
-
export { rehypeHighlight } from './highlighter/rehype';
|
|
3
|
-
export { createShikiHighlighter } from './highlighter/shiki';
|
|
4
|
-
export * from './utils/node';
|
|
1
|
+
export { parseMarkdown, createMarkdownParser } from './parser.js';
|
|
2
|
+
export { rehypeHighlight } from './highlighter/rehype.js';
|
|
3
|
+
export { createShikiHighlighter } from './highlighter/shiki.js';
|
|
4
|
+
export * from './utils/node.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MDCParseOptions } from '
|
|
1
|
+
import type { MDCParseOptions } from '../../types.js';
|
|
2
2
|
export declare function compileHast(this: any, options?: MDCParseOptions): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toString } from "hast-util-to-string";
|
|
2
2
|
import Slugger from "github-slugger";
|
|
3
|
-
import { validateProps } from "./utils/props.
|
|
3
|
+
import { validateProps } from "./utils/props.js";
|
|
4
4
|
export function compileHast(options = {}) {
|
|
5
5
|
const slugs = new Slugger();
|
|
6
6
|
function compileToJSON(node, parent) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { detab } from "detab";
|
|
2
|
-
import { parseThematicBlock } from "./utils.
|
|
2
|
+
import { parseThematicBlock } from "./utils.js";
|
|
3
3
|
export default (state, node) => {
|
|
4
4
|
const lang = (node.lang || "") + " " + (node.meta || "");
|
|
5
5
|
const { language, highlights, filename, meta } = parseThematicBlock(lang);
|
|
@@ -12,7 +12,6 @@ export default (state, node) => {
|
|
|
12
12
|
};
|
|
13
13
|
if (meta) {
|
|
14
14
|
result.data = {
|
|
15
|
-
// @ts-expect-error missing types
|
|
16
15
|
meta
|
|
17
16
|
};
|
|
18
17
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import emphasis from './emphasis';
|
|
2
|
-
import html from './html';
|
|
3
|
-
import link from './link';
|
|
4
|
-
import list from './list';
|
|
5
|
-
import paragraph from './paragraph';
|
|
6
|
-
import image from './image';
|
|
7
|
-
import strong from './strong';
|
|
8
|
-
import inlineCode from './inlineCode';
|
|
9
|
-
import containerComponent from './containerComponent';
|
|
1
|
+
import emphasis from './emphasis.js';
|
|
2
|
+
import html from './html.js';
|
|
3
|
+
import link from './link.js';
|
|
4
|
+
import list from './list.js';
|
|
5
|
+
import paragraph from './paragraph.js';
|
|
6
|
+
import image from './image.js';
|
|
7
|
+
import strong from './strong.js';
|
|
8
|
+
import inlineCode from './inlineCode.js';
|
|
9
|
+
import containerComponent from './containerComponent.js';
|
|
10
10
|
declare const _default: {
|
|
11
11
|
emphasis: typeof emphasis;
|
|
12
12
|
code: (state: import("mdast-util-to-hast").State, node: import("mdast").Code) => import("hast").Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import emphasis from "./emphasis.js";
|
|
2
|
+
import code from "./code.js";
|
|
3
|
+
import html from "./html.js";
|
|
4
|
+
import link from "./link.js";
|
|
5
|
+
import list from "./list.js";
|
|
6
|
+
import paragraph from "./paragraph.js";
|
|
7
|
+
import image from "./image.js";
|
|
8
|
+
import strong from "./strong.js";
|
|
9
|
+
import inlineCode from "./inlineCode.js";
|
|
10
|
+
import containerComponent from "./containerComponent.js";
|
|
11
|
+
export default {
|
|
12
|
+
emphasis,
|
|
13
|
+
code,
|
|
14
|
+
link,
|
|
15
|
+
paragraph,
|
|
16
|
+
html,
|
|
17
|
+
list,
|
|
18
|
+
image,
|
|
19
|
+
strong,
|
|
20
|
+
inlineCode,
|
|
21
|
+
containerComponent
|
|
22
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { kebabCase } from "scule";
|
|
2
|
-
import htmlTags from "../utils/html-tags-list.
|
|
3
|
-
import { getTagName } from "./utils.
|
|
2
|
+
import htmlTags from "../utils/html-tags-list.js";
|
|
3
|
+
import { getTagName } from "./utils.js";
|
|
4
4
|
export default function paragraph(state, node) {
|
|
5
5
|
if (node.children && node.children[0] && node.children[0].type === "html") {
|
|
6
6
|
const tagName = kebabCase(getTagName(node.children[0].value) || "div");
|
|
@@ -8,14 +8,14 @@ export function parseThematicBlock(lang) {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
const languageMatches = lang.replace(/[{|[](.+)/, "").match(/^[^ \t]+(?=[ \t]|$)/);
|
|
11
|
-
const highlightTokensMatches = lang.match(
|
|
12
|
-
const filenameMatches = lang.match(/\[((
|
|
11
|
+
const highlightTokensMatches = lang.match(/\{([^}]*)\}/);
|
|
12
|
+
const filenameMatches = lang.match(/\[((\\\]|[^\]])*)\]/);
|
|
13
13
|
const meta = lang.replace(languageMatches?.[0] ?? "", "").replace(highlightTokensMatches?.[0] ?? "", "").replace(filenameMatches?.[0] ?? "", "").trim();
|
|
14
14
|
return {
|
|
15
15
|
language: languageMatches?.[0] || void 0,
|
|
16
16
|
highlights: parseHighlightedLines(highlightTokensMatches?.[1] || void 0),
|
|
17
17
|
// https://github.com/nuxt/content/pull/2169
|
|
18
|
-
filename: filenameMatches?.[1].replace(
|
|
18
|
+
filename: filenameMatches?.[1].replace(/\\\]/g, "]") || void 0,
|
|
19
19
|
meta
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -26,7 +26,7 @@ function parseHighlightedLines(lines) {
|
|
|
26
26
|
});
|
|
27
27
|
return lineArray.length ? lineArray : void 0;
|
|
28
28
|
}
|
|
29
|
-
const TAG_NAME_REGEXP = /^<\/?([
|
|
29
|
+
const TAG_NAME_REGEXP = /^<\/?([\w-]+)(\s[^>]*?)?\/?>/;
|
|
30
30
|
export function getTagName(value) {
|
|
31
31
|
const result = String(value).match(TAG_NAME_REGEXP);
|
|
32
32
|
return result && result[1];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MDCParseOptions, MDCParserResult, MDCRoot } from '
|
|
1
|
+
import type { MDCParseOptions, MDCParserResult, MDCRoot } from '../../types.js';
|
|
2
2
|
export declare const createMarkdownParser: (inlineOptions?: MDCParseOptions) => Promise<(md: string) => Promise<MDCParserResult>>;
|
|
3
3
|
export declare const parseMarkdown: (md: string, inlineOptions?: MDCParseOptions) => Promise<MDCParserResult>;
|
|
4
4
|
export declare function contentHeading(body: MDCRoot): {
|
|
@@ -3,11 +3,11 @@ import remarkParse from "remark-parse";
|
|
|
3
3
|
import remark2rehype from "remark-rehype";
|
|
4
4
|
import { parseFrontMatter } from "remark-mdc";
|
|
5
5
|
import { defu } from "defu";
|
|
6
|
-
import { nodeTextContent } from "../utils/node.
|
|
7
|
-
import { useProcessorPlugins } from "./utils/plugins.
|
|
8
|
-
import { defaults } from "./options.
|
|
9
|
-
import { generateToc } from "./toc.
|
|
10
|
-
import { compileHast } from "./compiler.
|
|
6
|
+
import { nodeTextContent } from "../utils/node.js";
|
|
7
|
+
import { useProcessorPlugins } from "./utils/plugins.js";
|
|
8
|
+
import { defaults } from "./options.js";
|
|
9
|
+
import { generateToc } from "./toc.js";
|
|
10
|
+
import { compileHast } from "./compiler.js";
|
|
11
11
|
let moduleOptions;
|
|
12
12
|
let generatedMdcConfigs;
|
|
13
13
|
export const createMarkdownParser = async (inlineOptions = {}) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MDCParseOptions } from '
|
|
1
|
+
import type { MDCParseOptions } from '../../types.js';
|
|
2
2
|
export declare const defaults: MDCParseOptions;
|
|
@@ -5,7 +5,7 @@ import rehypeExternalLinks from "rehype-external-links";
|
|
|
5
5
|
import rehypeSortAttributeValues from "rehype-sort-attribute-values";
|
|
6
6
|
import rehypeSortAttributes from "rehype-sort-attributes";
|
|
7
7
|
import rehypeRaw from "rehype-raw";
|
|
8
|
-
import handlers from "./handlers/index.
|
|
8
|
+
import handlers from "./handlers/index.js";
|
|
9
9
|
export const defaults = {
|
|
10
10
|
remark: {
|
|
11
11
|
plugins: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { MDCNode, Toc, MDCElement, MDCRoot } from '
|
|
1
|
+
import type { MDCNode, Toc, MDCElement, MDCRoot } from '../../types.js';
|
|
2
2
|
export declare function generateFlatToc(body: MDCNode, options: Toc): Toc;
|
|
3
3
|
export declare function generateToc(body: MDCElement | MDCRoot, options: Toc): Toc;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flattenNode, flattenNodeText } from "../utils/ast.
|
|
1
|
+
import { flattenNode, flattenNodeText } from "../utils/ast.js";
|
|
2
2
|
const TOC_TAGS = ["h2", "h3", "h4", "h5", "h6"];
|
|
3
3
|
const TOC_TAGS_DEPTH = TOC_TAGS.reduce((tags, tag) => {
|
|
4
4
|
tags[tag] = Number(tag.charAt(tag.length - 1));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { MDCParseOptions } from '
|
|
1
|
+
import type { MDCParseOptions } from '../../../types.js';
|
|
2
2
|
export declare const useProcessorPlugins: (processor: Processor, plugins?: Exclude<MDCParseOptions['rehype'] | MDCParseOptions['remark'], undefined>['plugins']) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MDCNode } from '
|
|
1
|
+
import type { MDCNode } from '../../types.js';
|
|
2
2
|
export declare function flattenNodeText(node: MDCNode): string;
|
|
3
3
|
export declare function flattenNode(node: MDCNode, maxDepth?: number, _depth?: number): Array<MDCNode>;
|
|
4
4
|
export declare function setNodeData(node: MDCNode & {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const renderSlot: (slots: Record<string, any>, name: string, props: any, ...rest: any[]) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
1
|
+
export declare const renderSlot: (slots: Record<string, any>, name: string, props: any, ...rest: any[]) => import("vue/dist/vue.js").VNode<import("vue/dist/vue.js").RendererNode, import("vue/dist/vue.js").RendererElement, {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { renderSlot as _renderSlot } from "vue";
|
|
2
|
-
import { flatUnwrap } from "./node.
|
|
2
|
+
import { flatUnwrap } from "./node.js";
|
|
3
3
|
export const renderSlot = (slots, name, props, ...rest) => {
|
|
4
4
|
if (slots[name]) {
|
|
5
5
|
return _renderSlot({ ...slots, [name]: () => flatUnwrap(slots[name](), props?.unwrap) }, name, props, ...rest);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ssrRenderSlot as _ssrRenderSlot } from "vue/server-renderer";
|
|
2
|
-
import { flatUnwrap } from "./node.
|
|
2
|
+
import { flatUnwrap } from "./node.js";
|
|
3
3
|
export const ssrRenderSlot = (slots, name, props, fallbackRenderFn, push, parentComponent, slotScopeId) => {
|
|
4
4
|
if (slots[name]) {
|
|
5
5
|
return _ssrRenderSlot({ ...slots, [name]: () => flatUnwrap(slots[name](), props?.unwrap) }, name, props, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BuiltinTheme } from 'shiki';
|
|
2
|
+
|
|
3
|
+
type MdcThemeOptions = BuiltinTheme | string | Record<string, BuiltinTheme | string>;
|
|
4
|
+
interface HighlighterOptions {
|
|
5
|
+
highlights?: number[];
|
|
6
|
+
meta?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type { HighlighterOptions as H, MdcThemeOptions as M };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BuiltinTheme } from 'shiki';
|
|
2
|
+
|
|
3
|
+
type MdcThemeOptions = BuiltinTheme | string | Record<string, BuiltinTheme | string>;
|
|
4
|
+
interface HighlighterOptions {
|
|
5
|
+
highlights?: number[];
|
|
6
|
+
meta?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type { HighlighterOptions as H, MdcThemeOptions as M };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModuleOptions } from './module.js'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
declare module '@nuxt/schema' {
|
|
7
|
+
interface NuxtConfig { ['mdc']?: Partial<ModuleOptions> }
|
|
8
|
+
interface NuxtOptions { ['mdc']?: ModuleOptions }
|
|
9
|
+
}
|
|
6
10
|
|
|
11
|
+
declare module 'nuxt/schema' {
|
|
12
|
+
interface NuxtConfig { ['mdc']?: Partial<ModuleOptions> }
|
|
13
|
+
interface NuxtOptions { ['mdc']?: ModuleOptions }
|
|
14
|
+
}
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
|
|
17
|
+
export type { DefaultHighlightLangs, ModuleOptions, UnistPlugin, default } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModuleOptions } from './module'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
declare module '@nuxt/schema' {
|
|
7
|
+
interface NuxtConfig { ['mdc']?: Partial<ModuleOptions> }
|
|
8
|
+
interface NuxtOptions { ['mdc']?: ModuleOptions }
|
|
9
|
+
}
|
|
6
10
|
|
|
11
|
+
declare module 'nuxt/schema' {
|
|
12
|
+
interface NuxtConfig { ['mdc']?: Partial<ModuleOptions> }
|
|
13
|
+
interface NuxtOptions { ['mdc']?: ModuleOptions }
|
|
14
|
+
}
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
|
|
17
|
+
export type { DefaultHighlightLangs, ModuleOptions, UnistPlugin, default } from './module'
|