vite-plugin-svelte-md 0.1.0 → 0.1.4
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 -3
- package/lib/index.js +38 -13
- package/lib/index.mjs +23 -4
- package/package.json +6 -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
|
|
|
@@ -91,10 +89,10 @@ import svelteMd from "vite-plugin-svelte-md";
|
|
|
91
89
|
|
|
92
90
|
export default defineConfig({
|
|
93
91
|
plugins: [
|
|
92
|
+
svelteMd(), // <--
|
|
94
93
|
svelte({
|
|
95
94
|
extensions: [".svelte", ".md"], // <--
|
|
96
95
|
}),
|
|
97
|
-
svelteMd(), // <--
|
|
98
96
|
],
|
|
99
97
|
});
|
|
100
98
|
```
|
package/lib/index.js
CHANGED
|
@@ -23,31 +23,36 @@ var __spreadValues = (a, b) => {
|
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
25
|
var __export = (target, all) => {
|
|
26
|
-
__markAsModule(target);
|
|
27
26
|
for (var name in all)
|
|
28
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
29
28
|
};
|
|
30
|
-
var __reExport = (target, module2, desc) => {
|
|
29
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
31
30
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
32
31
|
for (let key of __getOwnPropNames(module2))
|
|
33
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
32
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
34
33
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
35
34
|
}
|
|
36
35
|
return target;
|
|
37
36
|
};
|
|
38
|
-
var
|
|
39
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default",
|
|
37
|
+
var __toESM = (module2, isNodeMode) => {
|
|
38
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
40
39
|
};
|
|
40
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
+
return (module2, temp) => {
|
|
42
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
+
};
|
|
44
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
41
45
|
|
|
42
46
|
// src/index.ts
|
|
43
|
-
|
|
47
|
+
var src_exports = {};
|
|
48
|
+
__export(src_exports, {
|
|
44
49
|
default: () => src_default
|
|
45
50
|
});
|
|
46
|
-
var import_pluginutils =
|
|
51
|
+
var import_pluginutils = require("@rollup/pluginutils");
|
|
47
52
|
|
|
48
53
|
// src/markdown.ts
|
|
49
|
-
var import_markdown_it =
|
|
50
|
-
var import_gray_matter =
|
|
54
|
+
var import_markdown_it = __toESM(require("markdown-it"));
|
|
55
|
+
var import_gray_matter = __toESM(require("gray-matter"));
|
|
51
56
|
|
|
52
57
|
// src/markdown-it-svelte-tags/index.ts
|
|
53
58
|
var SVELTE_TAGS_RE = /^(?:<svelte:[a-z][^>]*>|<\/svelte:[a-z]+>)/u;
|
|
@@ -75,6 +80,25 @@ function toArray(n) {
|
|
|
75
80
|
return [n];
|
|
76
81
|
return n;
|
|
77
82
|
}
|
|
83
|
+
function escapeBraces(test) {
|
|
84
|
+
return test.replace(/[{}]/g, (c) => c === "{" ? "{" : "}");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/markdown-it-svelte-curly-braces-escape/index.ts
|
|
88
|
+
function plugin2(md) {
|
|
89
|
+
const originalCodeBlock = md.renderer.rules.code_block;
|
|
90
|
+
md.renderer.rules.code_block = (...args) => {
|
|
91
|
+
return escapeBraces(originalCodeBlock(...args));
|
|
92
|
+
};
|
|
93
|
+
const originalCodeInline = md.renderer.rules.code_inline;
|
|
94
|
+
md.renderer.rules.code_inline = (...args) => {
|
|
95
|
+
return escapeBraces(originalCodeInline(...args));
|
|
96
|
+
};
|
|
97
|
+
const originalFence = md.renderer.rules.fence;
|
|
98
|
+
md.renderer.rules.fence = (...args) => {
|
|
99
|
+
return escapeBraces(originalFence(...args));
|
|
100
|
+
};
|
|
101
|
+
}
|
|
78
102
|
|
|
79
103
|
// src/head.ts
|
|
80
104
|
var headProperties = [
|
|
@@ -144,7 +168,7 @@ function headObjToTags(obj) {
|
|
|
144
168
|
}
|
|
145
169
|
}
|
|
146
170
|
}
|
|
147
|
-
return tags;
|
|
171
|
+
return tags.map(escapeBraces);
|
|
148
172
|
function attrs(o) {
|
|
149
173
|
return Object.entries(o).map(([k, v]) => `${k}="${`${v}`.replace(/"/gu, """)}"`).join(" ");
|
|
150
174
|
}
|
|
@@ -219,10 +243,10 @@ function createMarkdownProcessor(options) {
|
|
|
219
243
|
}
|
|
220
244
|
return !IS_SVELTE_TAG_NAME_RE.test(url);
|
|
221
245
|
};
|
|
222
|
-
markdownIt.use(plugin);
|
|
246
|
+
markdownIt.use(plugin).use(plugin2);
|
|
223
247
|
options.markdownItUses.forEach((e) => {
|
|
224
|
-
const [
|
|
225
|
-
markdownIt.use(
|
|
248
|
+
const [plugin3, ...options2] = toArray(e);
|
|
249
|
+
markdownIt.use(plugin3, ...options2);
|
|
226
250
|
});
|
|
227
251
|
return (id, text) => {
|
|
228
252
|
var _a, _b;
|
|
@@ -300,5 +324,6 @@ function src_default(options = {}) {
|
|
|
300
324
|
}
|
|
301
325
|
};
|
|
302
326
|
}
|
|
327
|
+
module.exports = __toCommonJS(src_exports);
|
|
303
328
|
// Annotate the CommonJS export names for ESM import in node:
|
|
304
329
|
0 && (module.exports = {});
|
package/lib/index.mjs
CHANGED
|
@@ -51,6 +51,25 @@ function toArray(n) {
|
|
|
51
51
|
return [n];
|
|
52
52
|
return n;
|
|
53
53
|
}
|
|
54
|
+
function escapeBraces(test) {
|
|
55
|
+
return test.replace(/[{}]/g, (c) => c === "{" ? "{" : "}");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/markdown-it-svelte-curly-braces-escape/index.ts
|
|
59
|
+
function plugin2(md) {
|
|
60
|
+
const originalCodeBlock = md.renderer.rules.code_block;
|
|
61
|
+
md.renderer.rules.code_block = (...args) => {
|
|
62
|
+
return escapeBraces(originalCodeBlock(...args));
|
|
63
|
+
};
|
|
64
|
+
const originalCodeInline = md.renderer.rules.code_inline;
|
|
65
|
+
md.renderer.rules.code_inline = (...args) => {
|
|
66
|
+
return escapeBraces(originalCodeInline(...args));
|
|
67
|
+
};
|
|
68
|
+
const originalFence = md.renderer.rules.fence;
|
|
69
|
+
md.renderer.rules.fence = (...args) => {
|
|
70
|
+
return escapeBraces(originalFence(...args));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
54
73
|
|
|
55
74
|
// src/head.ts
|
|
56
75
|
var headProperties = [
|
|
@@ -120,7 +139,7 @@ function headObjToTags(obj) {
|
|
|
120
139
|
}
|
|
121
140
|
}
|
|
122
141
|
}
|
|
123
|
-
return tags;
|
|
142
|
+
return tags.map(escapeBraces);
|
|
124
143
|
function attrs(o) {
|
|
125
144
|
return Object.entries(o).map(([k, v]) => `${k}="${`${v}`.replace(/"/gu, """)}"`).join(" ");
|
|
126
145
|
}
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-svelte-md",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Vite plugin to convert markdown to svelte template",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -56,13 +56,16 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@ota-meshi/eslint-plugin": "^0.10.0",
|
|
58
58
|
"@types/chai": "^4.2.22",
|
|
59
|
+
"@types/escape-html": "^1.0.1",
|
|
59
60
|
"@types/estree": "0.0.50",
|
|
60
61
|
"@types/markdown-it": "^12.2.3",
|
|
61
62
|
"@types/mocha": "^9.0.0",
|
|
62
63
|
"@types/node": "^16.11.11",
|
|
64
|
+
"@types/prismjs": "^1.16.6",
|
|
63
65
|
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
64
66
|
"@typescript-eslint/parser": "^5.5.0",
|
|
65
67
|
"chai": "^4.3.4",
|
|
68
|
+
"escape-html": "^1.0.3",
|
|
66
69
|
"eslint": "^8.3.0",
|
|
67
70
|
"eslint-config-prettier": "^8.3.0",
|
|
68
71
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
@@ -77,6 +80,8 @@
|
|
|
77
80
|
"nyc": "^15.1.0",
|
|
78
81
|
"prettier": "^2.5.0",
|
|
79
82
|
"prettier-plugin-svelte": "^2.5.0",
|
|
83
|
+
"prism-svelte": "^0.4.7",
|
|
84
|
+
"prismjs": "^1.25.0",
|
|
80
85
|
"rimraf": "^3.0.2",
|
|
81
86
|
"svelte": "^3.44.2",
|
|
82
87
|
"ts-node": "^10.4.0",
|