@md-plugins/md-plugin-inlinecode 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.
Files changed (2) hide show
  1. package/dist/index.mjs +16 -1
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,6 +1,21 @@
1
1
  import { escapeHtml } from 'markdown-it/lib/common/utils.mjs';
2
2
 
3
- const inlinecodePlugin = (md, { inlineCodeClass = "markdown-token" } = {}) => {
3
+ function resolvePluginOptions(options, key, defaults) {
4
+ if (options && typeof options === "object" && key in options) {
5
+ return { ...defaults, ...options[key] };
6
+ }
7
+ return { ...defaults, ...options };
8
+ }
9
+
10
+ const DEFAULT_INLINECODE_PLUGIN_OPTIONS = {
11
+ inlineCodeClass: "markdown-token"
12
+ };
13
+ const inlinecodePlugin = (md, options) => {
14
+ const { inlineCodeClass } = resolvePluginOptions(
15
+ options,
16
+ "inlinecodePlugin",
17
+ DEFAULT_INLINECODE_PLUGIN_OPTIONS
18
+ );
4
19
  md.renderer.rules.code_inline = (tokens, idx, _options, _env, self) => {
5
20
  const token = tokens[idx];
6
21
  if (!token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@md-plugins/md-plugin-inlinecode",
3
- "version": "0.1.0-alpha.28",
3
+ "version": "0.1.0-alpha.29",
4
4
  "description": "A markdown-it plugin for handling inline code.",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -35,7 +35,7 @@
35
35
  "devDependencies": {
36
36
  "markdown-it": "^14.1.0",
37
37
  "@types/markdown-it": "^14.1.2",
38
- "@md-plugins/shared": "0.1.0-alpha.28"
38
+ "@md-plugins/shared": "0.1.0-alpha.29"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "markdown-it": "^14.1.0"