@vuepress/markdown 2.0.0-beta.42 → 2.0.0-beta.43

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.
@@ -21,9 +21,18 @@ export interface CodePluginOptions {
21
21
  */
22
22
  preWrapper?: boolean;
23
23
  /**
24
- * Add `v-pre` directive to `<pre>` tag or not
24
+ * Add `v-pre` directive or not
25
25
  */
26
- vPre?: boolean;
26
+ vPre?: {
27
+ /**
28
+ * Add `v-pre` directive to `<pre>` tag of code block or not
29
+ */
30
+ block?: boolean;
31
+ /**
32
+ * Add `v-pre` directive to `<code>` tag of inline code or not
33
+ */
34
+ inline?: boolean;
35
+ };
27
36
  }
28
37
  /**
29
38
  * Code plugin
@@ -8,7 +8,7 @@ const resolveVPre_1 = require("./resolveVPre");
8
8
  /**
9
9
  * Code plugin
10
10
  */
11
- const codePlugin = (md, { highlightLines = true, lineNumbers = true, preWrapper = true, vPre = true, } = {}) => {
11
+ const codePlugin = (md, { highlightLines = true, lineNumbers = true, preWrapper = true, vPre: { block: vPreBlock = true, inline: vPreInline = true } = {}, } = {}) => {
12
12
  // override default fence renderer
13
13
  md.renderer.rules.fence = (tokens, idx, options, env, slf) => {
14
14
  const token = tokens[idx];
@@ -25,7 +25,7 @@ const codePlugin = (md, { highlightLines = true, lineNumbers = true, preWrapper
25
25
  ? code
26
26
  : `<pre class="${languageClass}"><code>${code}</code></pre>`;
27
27
  // resolve v-pre mark from token info
28
- const useVPre = (0, resolveVPre_1.resolveVPre)(info) ?? vPre;
28
+ const useVPre = (0, resolveVPre_1.resolveVPre)(info) ?? vPreBlock;
29
29
  if (useVPre) {
30
30
  result = `<pre v-pre${result.slice('<pre'.length)}`;
31
31
  }
@@ -67,5 +67,12 @@ const codePlugin = (md, { highlightLines = true, lineNumbers = true, preWrapper
67
67
  result = `<div class="${languageClass} ext-${language.ext}${useLineNumbers ? ' line-numbers-mode' : ''}">${result}</div>`;
68
68
  return result;
69
69
  };
70
+ if (vPreInline) {
71
+ const rawInlineCodeRule = md.renderer.rules.code_inline;
72
+ md.renderer.rules.code_inline = (tokens, idx, options, env, slf) => {
73
+ const result = rawInlineCodeRule(tokens, idx, options, env, slf);
74
+ return `<code v-pre${result.slice('<code'.length)}`;
75
+ };
76
+ }
70
77
  };
71
78
  exports.codePlugin = codePlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/markdown",
3
- "version": "2.0.0-beta.42",
3
+ "version": "2.0.0-beta.43",
4
4
  "description": "Markdown package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -23,8 +23,8 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@types/markdown-it": "^12.2.3",
26
- "@vuepress/shared": "2.0.0-beta.42",
27
- "@vuepress/utils": "2.0.0-beta.42",
26
+ "@vuepress/shared": "2.0.0-beta.43",
27
+ "@vuepress/utils": "2.0.0-beta.43",
28
28
  "markdown-it": "^13.0.0",
29
29
  "markdown-it-anchor": "^8.4.1",
30
30
  "markdown-it-emoji": "^2.0.0",