do11y 0.2.13 → 0.2.15
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/docs/plugins/highlight/highlight.js +5 -3
- package/dist/docs/plugins/markdown.d.ts +5 -0
- package/dist/docs/plugins/markdown.js +2 -1
- package/dist/docs/plugins/meta/meta.js +3 -1
- package/dist/docs/plugins/options.d.ts +9 -1
- package/dist/docs/plugins/routes.js +13 -1
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ export const highlightCode = (code, lang) => {
|
|
|
21
21
|
transformerNotationErrorLevel(),
|
|
22
22
|
...do11yOptions.highlighter.transformers,
|
|
23
23
|
{
|
|
24
|
-
name: "do11y",
|
|
24
|
+
name: "do11y:postprocess",
|
|
25
25
|
postprocess(html) {
|
|
26
26
|
if (do11yOptions.highlighter.postprocess) {
|
|
27
27
|
const jsdom = new JSDOM(html);
|
|
@@ -32,7 +32,7 @@ export const highlightCode = (code, lang) => {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
name: "remove-unwanted-comments",
|
|
35
|
+
name: "do11y:remove-unwanted-comments",
|
|
36
36
|
tokens(tokens) {
|
|
37
37
|
const filter = do11yOptions.highlighter.removeComments;
|
|
38
38
|
if (filter === false) {
|
|
@@ -41,7 +41,6 @@ export const highlightCode = (code, lang) => {
|
|
|
41
41
|
const result = [];
|
|
42
42
|
let previousLineWasRemoved = false;
|
|
43
43
|
for (const line of tokens) {
|
|
44
|
-
previousLineWasRemoved = false;
|
|
45
44
|
const filteredLine = [];
|
|
46
45
|
let hasComment = false;
|
|
47
46
|
for (const token of line) {
|
|
@@ -72,6 +71,9 @@ export const highlightCode = (code, lang) => {
|
|
|
72
71
|
continue;
|
|
73
72
|
}
|
|
74
73
|
}
|
|
74
|
+
else {
|
|
75
|
+
previousLineWasRemoved = false;
|
|
76
|
+
}
|
|
75
77
|
result.push(filteredLine);
|
|
76
78
|
}
|
|
77
79
|
return result;
|
|
@@ -6,6 +6,11 @@ export interface MarkdownPluginOptions {
|
|
|
6
6
|
* Additional markdown-it setup.
|
|
7
7
|
*/
|
|
8
8
|
markdownSetup?: PluginSimple;
|
|
9
|
+
/**
|
|
10
|
+
* The callback function for rendering code blocks.
|
|
11
|
+
* Will default return the highlighted code generated by Shiki directly.
|
|
12
|
+
*/
|
|
13
|
+
renderCodeBlock?: (highlightedCode: string) => string;
|
|
9
14
|
}
|
|
10
15
|
export interface MarkdownItEnv {
|
|
11
16
|
/**
|
|
@@ -13,7 +13,8 @@ export default (options) => {
|
|
|
13
13
|
const md = markdown({
|
|
14
14
|
html: true,
|
|
15
15
|
highlight(code, lang) {
|
|
16
|
-
|
|
16
|
+
const highlightedCode = highlightCode(code, lang);
|
|
17
|
+
return options?.renderCodeBlock ? options.renderCodeBlock(highlightedCode) : highlightedCode;
|
|
17
18
|
},
|
|
18
19
|
});
|
|
19
20
|
md.use(frontmatterPlugin);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
import type { App, Component } from "vue";
|
|
3
|
-
import type { Router } from "vue-router";
|
|
3
|
+
import type { Router, RouteRecordRaw } from "vue-router";
|
|
4
4
|
import type { BundledTheme, ShikiTransformer, StringLiteralUnion, ThemeInput } from "shiki";
|
|
5
5
|
import type { MarkdownPluginOptions } from "./markdown.js";
|
|
6
6
|
export interface Options extends MarkdownPluginOptions {
|
|
@@ -28,6 +28,14 @@ export interface Options extends MarkdownPluginOptions {
|
|
|
28
28
|
* Custom wrapper component for `.vue.sandbox` imports.
|
|
29
29
|
*/
|
|
30
30
|
SandboxIframe?: () => Promise<Component>;
|
|
31
|
+
/**
|
|
32
|
+
* Custom additional routes.
|
|
33
|
+
*/
|
|
34
|
+
routes?: (RouteRecordRaw & {
|
|
35
|
+
meta: {
|
|
36
|
+
title: string;
|
|
37
|
+
};
|
|
38
|
+
})[];
|
|
31
39
|
/**
|
|
32
40
|
* The code highlighter.
|
|
33
41
|
* - Markdown code blocks
|
|
@@ -42,13 +42,25 @@ export default () => {
|
|
|
42
42
|
return `
|
|
43
43
|
import options from 'do11y:options';
|
|
44
44
|
|
|
45
|
+
import { RouterView } from 'vue-router';
|
|
46
|
+
|
|
45
47
|
const home = {
|
|
46
48
|
path: "/",
|
|
47
49
|
meta: ${JSON.stringify(homeMeta)},
|
|
48
50
|
component: options.Home
|
|
49
51
|
};
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
const customRoutes = (options.routes ?? []).map(page => ({
|
|
54
|
+
...page,
|
|
55
|
+
|
|
56
|
+
meta: {
|
|
57
|
+
slug: page.path,
|
|
58
|
+
|
|
59
|
+
...page.meta,
|
|
60
|
+
}
|
|
61
|
+
}))
|
|
62
|
+
|
|
63
|
+
export default [home, ...customRoutes, ${stringifiedRoutes.join(",\n")}];
|
|
52
64
|
`;
|
|
53
65
|
}
|
|
54
66
|
},
|