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 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
  [![NPM license](https://img.shields.io/npm/l/vite-plugin-svelte-md.svg)](https://www.npmjs.com/package/vite-plugin-svelte-md)
9
8
  [![NPM version](https://img.shields.io/npm/v/vite-plugin-svelte-md.svg)](https://www.npmjs.com/package/vite-plugin-svelte-md)
10
9
  [![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/vite-plugin-svelte-md&maxAge=3600)](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
  [![NPM downloads](https://img.shields.io/npm/dt/vite-plugin-svelte-md.svg)](http://www.npmtrends.com/vite-plugin-svelte-md)
15
14
  [![Build Status](https://github.com/ota-meshi/vite-plugin-svelte-md/workflows/CI/badge.svg?branch=main)](https://github.com/ota-meshi/vite-plugin-svelte-md/actions?query=workflow%3ACI)
16
15
  [![Coverage Status](https://coveralls.io/repos/github/ota-meshi/vite-plugin-svelte-md/badge.svg?branch=main)](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 === "{" ? "&#123;" : "&#125;");
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 [plugin2, options2] = toArray(e);
225
- markdownIt.use(plugin2, options2);
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 === "{" ? "&#123;" : "&#125;");
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 [plugin2, options2] = toArray(e);
201
- markdownIt.use(plugin2, options2);
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.0",
3
+ "version": "0.1.1",
4
4
  "description": "Vite plugin to convert markdown to svelte template",
5
5
  "files": [
6
6
  "lib"