@md-plugins/md-plugin-codeblocks 0.1.0-alpha.2 → 0.1.0-alpha.20

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
@@ -38,8 +38,8 @@ md.use(codeblocksPlugin, {
38
38
  copyButtonComponent: '<MarkdownCopyButton',
39
39
  preClass: 'markdown-code',
40
40
  pageScripts: [
41
- "import MarkdownPrerender from 'src/components/md/MarkdownPrerender'",
42
- "import MarkdownCopyButton from 'src/components/md/MarkdownCopyButton.vue'",
41
+ "import MarkdownPrerender from 'src/.q-press/components/MarkdownPrerender'",
42
+ "import MarkdownCopyButton from 'src/.q-press/components/MarkdownCopyButton.vue'",
43
43
  ],
44
44
  })
45
45
  ```
@@ -90,12 +90,14 @@ The `md-plugin-codeblocks` plugin supports the following options:
90
90
 
91
91
  The plugin supports magic comments for inline annotations:
92
92
 
93
+ ````markup
93
94
  ```js [numbered]
94
95
  // All lines will be numbered
95
96
  console.log('Line 1')
96
97
  console.log('Line 2')
97
98
  console.log('Line 3')
98
99
  ```
100
+ ````
99
101
 
100
102
  ### Line Highlighting and Annotations
101
103
 
@@ -110,8 +112,7 @@ console.log('Line 3')
110
112
  ````markup
111
113
  ```js
112
114
  console.log('Line 1')
113
- console.log('Line 2')
114
- ;[[highlight]] // This line will be highlighted
115
+ console.log('Line 2') [[highlight]] // This line will be highlighted
115
116
  console.log('Line 3')
116
117
  ```
117
118
  ````
@@ -172,6 +173,10 @@ Run the unit tests with `Vitest`:
172
173
  pnpm test
173
174
  ```
174
175
 
176
+ ## Documentation
177
+
178
+ In case this README falls out of date, please refer to the [documentation](https://md-plugins.netlify.app/md-plugins/codeblocks/overview) for the latest information.
179
+
175
180
  ## License
176
181
 
177
182
  This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
package/dist/index.mjs CHANGED
@@ -25,9 +25,9 @@ const codeblocksPlugin = (md, {
25
25
  tabPanelTagName = "q-tab-panel",
26
26
  tabPanelTagClass = "q-pa-none",
27
27
  pageScripts = [
28
- "import MarkdownPrerender from 'src/components/md/MarkdownPrerender'",
28
+ "import MarkdownPrerender from 'src/.q-press/components/MarkdownPrerender'",
29
29
  // ts file
30
- "import MarkdownCopyButton from 'src/components/md/MarkdownCopyButton.vue'"
30
+ "import MarkdownCopyButton from 'src/.q-press/components/MarkdownCopyButton.vue'"
31
31
  ],
32
32
  langList = defaultLangList
33
33
  } = {}) => {
@@ -76,13 +76,13 @@ const codeblocksPlugin = (md, {
76
76
  function extractCodeLineProps(lines, attrs) {
77
77
  const acc = {};
78
78
  for (const type of magicCommentList) {
79
- acc[type] = attrs[type] !== void 0 ? attrs[type].split(",") : [];
79
+ acc[type] = attrs[type] !== undefined ? attrs[type].split(",") : [];
80
80
  }
81
81
  lines.forEach((line, lineIndex) => {
82
82
  const match = line.match(magicCommentRE);
83
83
  if (match !== null) {
84
84
  const type = match.groups?.type;
85
- if (type !== void 0) {
85
+ if (type !== undefined) {
86
86
  acc[type].push("" + (lineIndex + 1));
87
87
  }
88
88
  }
@@ -104,7 +104,7 @@ const codeblocksPlugin = (md, {
104
104
  const target = props[type];
105
105
  for (const value of target) {
106
106
  let [from, to] = value.split("-").map((i) => parseInt(i, 10));
107
- if (to === void 0) to = from;
107
+ if (to === undefined) to = from;
108
108
  for (let i = from; i <= to; i++) {
109
109
  acc[i - 1].classList.push(`line-${type}`);
110
110
  }
@@ -142,10 +142,12 @@ const codeblocksPlugin = (md, {
142
142
  lineHtml += line;
143
143
  return lineHtml;
144
144
  }).join("\n");
145
- const langClass = lang === "css" ? " language-css" : ` language-${lang}`;
146
- const preAttrs = maxheight !== void 0 ? ` style="max-height:${maxheight}"` : "";
145
+ const preAttrs = maxheight !== undefined ? ` style="max-height:${maxheight}"` : "";
147
146
  const langProp = customCopyLangList.includes(lang) === true ? ` lang="${lang}"` : "";
148
- return `<pre v-pre class="${preClass}${langClass}"${preAttrs}>` + renderCodeBlock(html, codeClass) + `</pre><${copyButtonComponent}${langProp} />`;
147
+ return (
148
+ // `<pre v-pre class="${preClass}${langClass}"${preAttrs}>` +
149
+ `<pre v-pre class="${preClass}"${preAttrs}>` + renderCodeBlock(html, codeClass) + `</pre><${copyButtonComponent}${langProp} />`
150
+ );
149
151
  }
150
152
  function parseAttrs(rawAttrs) {
151
153
  if (rawAttrs === null) return {};
@@ -191,7 +193,7 @@ const codeblocksPlugin = (md, {
191
193
  }
192
194
  }
193
195
  const attrs = parseDefinitionLine(token);
194
- return `<${containerComponent}${attrs.title !== null ? ` title="${attrs.title}"` : ""}${attrs.tabs !== void 0 ? ` :tabs="${attrs.tabs.param}"` : ""}>` + (attrs.tabs !== void 0 ? attrs.tabs.content : getHighlightedContent(token.content, attrs)) + `</${containerComponent}>`;
196
+ return `<${containerComponent}${attrs.title !== null ? ` title="${attrs.title}"` : ""}${attrs.tabs !== undefined ? ` :tabs="${attrs.tabs.param}"` : ""}>` + (attrs.tabs !== undefined ? attrs.tabs.content : getHighlightedContent(token.content, attrs)) + `</${containerComponent}>`;
195
197
  };
196
198
  };
197
199
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@md-plugins/md-plugin-codeblocks",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.20",
4
4
  "description": "A markdown-it plugin for code blocks.",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -32,17 +32,19 @@
32
32
  "files": [
33
33
  "./dist"
34
34
  ],
35
- "dependencies": {
36
- "markdown-it": "^14.1.0",
37
- "prismjs": "^1.29.0",
38
- "@md-plugins/shared": "0.1.0-alpha.2"
39
- },
40
35
  "publishConfig": {
41
36
  "access": "public"
42
37
  },
43
38
  "devDependencies": {
39
+ "markdown-it": "^14.1.0",
40
+ "prismjs": "^1.29.0",
44
41
  "@types/markdown-it": "^14.1.2",
45
- "@types/prismjs": "^1.26.5"
42
+ "@types/prismjs": "^1.26.5",
43
+ "@md-plugins/shared": "0.1.0-alpha.20"
44
+ },
45
+ "peerDependencies": {
46
+ "markdown-it": "^14.1.0",
47
+ "prismjs": "^1.29.0"
46
48
  },
47
49
  "scripts": {
48
50
  "build": "unbuild",