@md-plugins/md-plugin-blockquote 0.1.0-alpha.28 → 0.1.0-alpha.29
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/dist/index.mjs +14 -3
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
function resolvePluginOptions(options, key, defaults) {
|
|
2
|
+
if (options && typeof options === "object" && key in options) {
|
|
3
|
+
return { ...defaults, ...options[key] };
|
|
4
|
+
}
|
|
5
|
+
return { ...defaults, ...options };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const DEFAULT_BLOCKQUOTE_OPTIONS = {
|
|
9
|
+
blockquoteClass: "markdown-blockquote"
|
|
10
|
+
};
|
|
11
|
+
const blockquotePlugin = (md, options) => {
|
|
12
|
+
const { blockquoteClass = DEFAULT_BLOCKQUOTE_OPTIONS.blockquoteClass } = resolvePluginOptions(options, "blockquotePlugin", DEFAULT_BLOCKQUOTE_OPTIONS);
|
|
2
13
|
const originalRender = md.renderer.render.bind(md.renderer);
|
|
3
|
-
md.renderer.render = (tokens,
|
|
14
|
+
md.renderer.render = (tokens, options2, env) => {
|
|
4
15
|
tokens.forEach((token) => {
|
|
5
16
|
if (token.tag === "blockquote" && token.type === "blockquote_open") {
|
|
6
17
|
const existingClass = token.attrGet("class") || "";
|
|
@@ -8,7 +19,7 @@ const blockquotePlugin = (md, { blockquoteClass = "markdown-blockquote" } = {})
|
|
|
8
19
|
token.attrSet("class", newClass);
|
|
9
20
|
}
|
|
10
21
|
});
|
|
11
|
-
return originalRender(tokens,
|
|
22
|
+
return originalRender(tokens, options2, env);
|
|
12
23
|
};
|
|
13
24
|
};
|
|
14
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/md-plugin-blockquote",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.29",
|
|
4
4
|
"description": "A markdown-it plugin for Blockquotes with custom styles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/markdown-it": "^14.1.2",
|
|
37
37
|
"markdown-it": "^14.1.0",
|
|
38
|
-
"@md-plugins/shared": "0.1.0-alpha.
|
|
38
|
+
"@md-plugins/shared": "0.1.0-alpha.29"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"markdown-it": "^14.1.0"
|