@md-plugins/vite-md-plugin 0.1.0-alpha.27 → 0.1.0-alpha.29
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/index.d.mts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.mjs +14 -50
- package/package.json +13 -13
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import { Options } from 'markdown-it';
|
|
3
|
+
import { MarkdownItEnv } from '@md-plugins/shared';
|
|
3
4
|
import { BlockquotePluginOptions } from '@md-plugins/md-plugin-blockquote';
|
|
4
5
|
import { CodeblockPluginOptions } from '@md-plugins/md-plugin-codeblocks';
|
|
5
6
|
import { FrontmatterPluginOptions } from '@md-plugins/md-plugin-frontmatter';
|
|
@@ -14,14 +15,16 @@ interface MarkdownOptions extends Options {
|
|
|
14
15
|
linkify?: boolean;
|
|
15
16
|
typographer?: boolean;
|
|
16
17
|
breaks?: boolean;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
blockquotePlugin?: BlockquotePluginOptions;
|
|
19
|
+
codeblockPlugin?: CodeblockPluginOptions;
|
|
20
|
+
frontmatterPlugin?: FrontmatterPluginOptions;
|
|
21
|
+
headersPlugin?: HeadersPluginOptions | boolean;
|
|
22
|
+
imagePlugin?: ImagePluginOptions;
|
|
23
|
+
inlineCodePlugin?: InlineCodePluginOptions;
|
|
24
|
+
linkPlugin?: LinkPluginOptions;
|
|
25
|
+
tablePlugin?: TablePluginOptions;
|
|
26
|
+
preProcess?: (env: MarkdownItEnv) => void;
|
|
27
|
+
postProcess?: (env: MarkdownItEnv) => void;
|
|
25
28
|
}
|
|
26
29
|
interface MenuItem {
|
|
27
30
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import { Options } from 'markdown-it';
|
|
3
|
+
import { MarkdownItEnv } from '@md-plugins/shared';
|
|
3
4
|
import { BlockquotePluginOptions } from '@md-plugins/md-plugin-blockquote';
|
|
4
5
|
import { CodeblockPluginOptions } from '@md-plugins/md-plugin-codeblocks';
|
|
5
6
|
import { FrontmatterPluginOptions } from '@md-plugins/md-plugin-frontmatter';
|
|
@@ -14,14 +15,16 @@ interface MarkdownOptions extends Options {
|
|
|
14
15
|
linkify?: boolean;
|
|
15
16
|
typographer?: boolean;
|
|
16
17
|
breaks?: boolean;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
blockquotePlugin?: BlockquotePluginOptions;
|
|
19
|
+
codeblockPlugin?: CodeblockPluginOptions;
|
|
20
|
+
frontmatterPlugin?: FrontmatterPluginOptions;
|
|
21
|
+
headersPlugin?: HeadersPluginOptions | boolean;
|
|
22
|
+
imagePlugin?: ImagePluginOptions;
|
|
23
|
+
inlineCodePlugin?: InlineCodePluginOptions;
|
|
24
|
+
linkPlugin?: LinkPluginOptions;
|
|
25
|
+
tablePlugin?: TablePluginOptions;
|
|
26
|
+
preProcess?: (env: MarkdownItEnv) => void;
|
|
27
|
+
postProcess?: (env: MarkdownItEnv) => void;
|
|
25
28
|
}
|
|
26
29
|
interface MenuItem {
|
|
27
30
|
name: string;
|
package/dist/index.mjs
CHANGED
|
@@ -205,8 +205,8 @@ function createMarkdownRenderer(options = {}) {
|
|
|
205
205
|
html: true,
|
|
206
206
|
linkify: true,
|
|
207
207
|
typographer: true,
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
breaks: true,
|
|
209
|
+
...options
|
|
210
210
|
});
|
|
211
211
|
md.use(frontmatterPlugin, { ...options });
|
|
212
212
|
md.use(importsPlugin);
|
|
@@ -259,75 +259,39 @@ function createMarkdownRenderer(options = {}) {
|
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
function flattenOptions(options) {
|
|
263
|
-
const flattened = { ...options };
|
|
264
|
-
if (options.blockquote) {
|
|
265
|
-
Object.assign(flattened, options.blockquote);
|
|
266
|
-
delete flattened.blockquote;
|
|
267
|
-
}
|
|
268
|
-
if (options.codeblocks) {
|
|
269
|
-
Object.assign(flattened, options.codeblocks);
|
|
270
|
-
delete flattened.codeblocks;
|
|
271
|
-
}
|
|
272
|
-
if (options.frontmatter) {
|
|
273
|
-
Object.assign(flattened, options.frontmatter);
|
|
274
|
-
delete flattened.frontmatter;
|
|
275
|
-
}
|
|
276
|
-
if (options.headers && typeof options.headers === "object") {
|
|
277
|
-
Object.assign(flattened, options.headers);
|
|
278
|
-
delete flattened.headers;
|
|
279
|
-
}
|
|
280
|
-
if (options.image) {
|
|
281
|
-
Object.assign(flattened, options.image);
|
|
282
|
-
delete flattened.image;
|
|
283
|
-
}
|
|
284
|
-
if (options.inlinecode) {
|
|
285
|
-
Object.assign(flattened, options.inlinecode);
|
|
286
|
-
delete flattened.inlinecode;
|
|
287
|
-
}
|
|
288
|
-
if (options.link) {
|
|
289
|
-
Object.assign(flattened, options.link);
|
|
290
|
-
delete flattened.link;
|
|
291
|
-
}
|
|
292
|
-
if (options.table) {
|
|
293
|
-
Object.assign(flattened, options.table);
|
|
294
|
-
delete flattened.table;
|
|
295
|
-
}
|
|
296
|
-
return flattened;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
262
|
const markdownLinkRE = /<MarkdownLink /;
|
|
300
263
|
const markdownApiRE = /<MarkdownApi /;
|
|
301
264
|
const markdownTreeRE = /<MarkdownTree /;
|
|
302
265
|
function mdParse(code, id, prefix, menu, options = {}) {
|
|
303
266
|
const env = {
|
|
304
|
-
frontmatter: {
|
|
305
|
-
id
|
|
306
|
-
},
|
|
267
|
+
frontmatter: { id },
|
|
307
268
|
pageScripts: /* @__PURE__ */ new Set()
|
|
308
269
|
};
|
|
309
270
|
env.pageScripts.add("import MarkdownPage from 'src/.q-press/layouts/MarkdownPage.vue'");
|
|
310
|
-
if (markdownApiRE.test(code)
|
|
271
|
+
if (markdownApiRE.test(code)) {
|
|
311
272
|
env.pageScripts.add("import MarkdownApi from 'src/.q-press/components/MarkdownApi.vue'");
|
|
312
273
|
}
|
|
313
|
-
if (markdownTreeRE.test(code)
|
|
274
|
+
if (markdownTreeRE.test(code)) {
|
|
314
275
|
env.pageScripts.add("import MarkdownTree from 'src/.q-press/components/MarkdownTree.vue'");
|
|
315
276
|
}
|
|
316
|
-
|
|
317
|
-
|
|
277
|
+
if (typeof options.preProcess === "function") {
|
|
278
|
+
options.preProcess(env);
|
|
279
|
+
}
|
|
280
|
+
const md = createMarkdownRenderer(options);
|
|
318
281
|
const results = md.render(code, env);
|
|
319
282
|
if (env.frontmatter.examples !== undefined) {
|
|
320
283
|
env.pageScripts.add(
|
|
321
284
|
"import MarkdownExample from 'src/.q-press/components/MarkdownExample.vue'"
|
|
322
285
|
);
|
|
323
286
|
}
|
|
324
|
-
if (markdownLinkRE.test(code)
|
|
287
|
+
if (markdownLinkRE.test(code)) {
|
|
325
288
|
env.pageScripts.add("import MarkdownLink from 'src/.q-press/components/MarkdownLink.vue'");
|
|
326
289
|
}
|
|
290
|
+
if (typeof options.postProcess === "function") {
|
|
291
|
+
options.postProcess(env);
|
|
292
|
+
}
|
|
327
293
|
const component = getVueComponent(results, code, id, prefix, menu);
|
|
328
|
-
return {
|
|
329
|
-
code: component
|
|
330
|
-
};
|
|
294
|
+
return { code: component };
|
|
331
295
|
}
|
|
332
296
|
|
|
333
297
|
const mdRE = /\.md$/;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/vite-md-plugin",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.29",
|
|
4
4
|
"description": "A very opinionated Vite plugin for @md-plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"markdown-it": "^14.1.0",
|
|
39
|
-
"@md-plugins/md-plugin-
|
|
40
|
-
"@md-plugins/md-plugin-
|
|
41
|
-
"@md-plugins/md-plugin-
|
|
42
|
-
"@md-plugins/md-plugin-
|
|
43
|
-
"@md-plugins/md-plugin-imports": "0.1.0-alpha.
|
|
44
|
-
"@md-plugins/md-plugin-
|
|
45
|
-
"@md-plugins/md-plugin-
|
|
46
|
-
"@md-plugins/md-plugin-
|
|
47
|
-
"@md-plugins/md-plugin-table": "0.1.0-alpha.
|
|
48
|
-
"@md-plugins/md-plugin-link": "0.1.0-alpha.
|
|
49
|
-
"@md-plugins/
|
|
50
|
-
"@md-plugins/
|
|
39
|
+
"@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.29",
|
|
40
|
+
"@md-plugins/md-plugin-blockquote": "0.1.0-alpha.29",
|
|
41
|
+
"@md-plugins/md-plugin-containers": "0.1.0-alpha.29",
|
|
42
|
+
"@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.29",
|
|
43
|
+
"@md-plugins/md-plugin-imports": "0.1.0-alpha.29",
|
|
44
|
+
"@md-plugins/md-plugin-headers": "0.1.0-alpha.29",
|
|
45
|
+
"@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.29",
|
|
46
|
+
"@md-plugins/md-plugin-image": "0.1.0-alpha.29",
|
|
47
|
+
"@md-plugins/md-plugin-table": "0.1.0-alpha.29",
|
|
48
|
+
"@md-plugins/md-plugin-link": "0.1.0-alpha.29",
|
|
49
|
+
"@md-plugins/shared": "0.1.0-alpha.29",
|
|
50
|
+
"@md-plugins/md-plugin-title": "0.1.0-alpha.29"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/markdown-it": "^14.1.2",
|