vite-plugin-svelte-md 0.1.0 → 0.1.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 +0 -2
- package/lib/index.js +22 -3
- package/lib/index.mjs +22 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@ Markdown with Svelte for Vite
|
|
|
4
4
|
|
|
5
5
|
_`vite-plugin-svelte-md` is heavily inspired by [vite-plugin-md](https://github.com/antfu/vite-plugin-md) package._
|
|
6
6
|
|
|
7
|
-
<!--
|
|
8
7
|
[](https://www.npmjs.com/package/vite-plugin-svelte-md)
|
|
9
8
|
[](https://www.npmjs.com/package/vite-plugin-svelte-md)
|
|
10
9
|
[](http://www.npmtrends.com/vite-plugin-svelte-md)
|
|
@@ -14,7 +13,6 @@ _`vite-plugin-svelte-md` is heavily inspired by [vite-plugin-md](https://github.
|
|
|
14
13
|
[](http://www.npmtrends.com/vite-plugin-svelte-md)
|
|
15
14
|
[](https://github.com/ota-meshi/vite-plugin-svelte-md/actions?query=workflow%3ACI)
|
|
16
15
|
[](https://coveralls.io/github/ota-meshi/vite-plugin-svelte-md?branch=main)
|
|
17
|
-
-->
|
|
18
16
|
|
|
19
17
|
## 📛 Features
|
|
20
18
|
|
package/lib/index.js
CHANGED
|
@@ -69,6 +69,25 @@ function plugin(md) {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// src/markdown-it-svelte-curly-braces-escape/index.ts
|
|
73
|
+
function plugin2(md) {
|
|
74
|
+
const originalCodeBlock = md.renderer.rules.code_block;
|
|
75
|
+
md.renderer.rules.code_block = (...args) => {
|
|
76
|
+
return escape(originalCodeBlock(...args));
|
|
77
|
+
};
|
|
78
|
+
const originalCodeInline = md.renderer.rules.code_inline;
|
|
79
|
+
md.renderer.rules.code_inline = (...args) => {
|
|
80
|
+
return escape(originalCodeInline(...args));
|
|
81
|
+
};
|
|
82
|
+
const originalFence = md.renderer.rules.fence;
|
|
83
|
+
md.renderer.rules.fence = (...args) => {
|
|
84
|
+
return escape(originalFence(...args));
|
|
85
|
+
};
|
|
86
|
+
function escape(test) {
|
|
87
|
+
return test.replace(/[{}]/g, (c) => c === "{" ? "{" : "}");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
// src/utils.ts
|
|
73
92
|
function toArray(n) {
|
|
74
93
|
if (!Array.isArray(n))
|
|
@@ -219,10 +238,10 @@ function createMarkdownProcessor(options) {
|
|
|
219
238
|
}
|
|
220
239
|
return !IS_SVELTE_TAG_NAME_RE.test(url);
|
|
221
240
|
};
|
|
222
|
-
markdownIt.use(plugin);
|
|
241
|
+
markdownIt.use(plugin).use(plugin2);
|
|
223
242
|
options.markdownItUses.forEach((e) => {
|
|
224
|
-
const [
|
|
225
|
-
markdownIt.use(
|
|
243
|
+
const [plugin3, options2] = toArray(e);
|
|
244
|
+
markdownIt.use(plugin3, options2);
|
|
226
245
|
});
|
|
227
246
|
return (id, text) => {
|
|
228
247
|
var _a, _b;
|
package/lib/index.mjs
CHANGED
|
@@ -45,6 +45,25 @@ function plugin(md) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// src/markdown-it-svelte-curly-braces-escape/index.ts
|
|
49
|
+
function plugin2(md) {
|
|
50
|
+
const originalCodeBlock = md.renderer.rules.code_block;
|
|
51
|
+
md.renderer.rules.code_block = (...args) => {
|
|
52
|
+
return escape(originalCodeBlock(...args));
|
|
53
|
+
};
|
|
54
|
+
const originalCodeInline = md.renderer.rules.code_inline;
|
|
55
|
+
md.renderer.rules.code_inline = (...args) => {
|
|
56
|
+
return escape(originalCodeInline(...args));
|
|
57
|
+
};
|
|
58
|
+
const originalFence = md.renderer.rules.fence;
|
|
59
|
+
md.renderer.rules.fence = (...args) => {
|
|
60
|
+
return escape(originalFence(...args));
|
|
61
|
+
};
|
|
62
|
+
function escape(test) {
|
|
63
|
+
return test.replace(/[{}]/g, (c) => c === "{" ? "{" : "}");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
// src/utils.ts
|
|
49
68
|
function toArray(n) {
|
|
50
69
|
if (!Array.isArray(n))
|
|
@@ -195,10 +214,10 @@ function createMarkdownProcessor(options) {
|
|
|
195
214
|
}
|
|
196
215
|
return !IS_SVELTE_TAG_NAME_RE.test(url);
|
|
197
216
|
};
|
|
198
|
-
markdownIt.use(plugin);
|
|
217
|
+
markdownIt.use(plugin).use(plugin2);
|
|
199
218
|
options.markdownItUses.forEach((e) => {
|
|
200
|
-
const [
|
|
201
|
-
markdownIt.use(
|
|
219
|
+
const [plugin3, options2] = toArray(e);
|
|
220
|
+
markdownIt.use(plugin3, options2);
|
|
202
221
|
});
|
|
203
222
|
return (id, text) => {
|
|
204
223
|
var _a, _b;
|