mikel-markdown 0.20.2 → 0.21.0

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/index.js +7 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -28,6 +28,10 @@ const allExpressions = {
28
28
  regex: /(?:^```(?:[^\n]*)\n([\s\S]*?)\n``` *$)/gm,
29
29
  replace: (args, cn) => render("pre", {class: cn.pre}, escape(args[1])),
30
30
  },
31
+ code: {
32
+ regex: /`([^`]*?)`/g,
33
+ replace: (args, cn) => render("code", {class: cn.code}, escape(args[1])),
34
+ },
31
35
  heading: {
32
36
  regex: /^(#+)\s+(.*)/gm,
33
37
  replace: (args, cn) => render("h" + args[1].length, {class: cn.heading}, args[2]),
@@ -36,10 +40,6 @@ const allExpressions = {
36
40
  regex: /^[\s]*>\s(.*)/gm,
37
41
  replace: (args, cn) => render("blockquote", {class: cn.blockquote}, args[1]),
38
42
  },
39
- code: {
40
- regex: /`([^`]*?)`/g,
41
- replace: (args, cn) => render("code", {class: cn.code}, escape(args[1])),
42
- },
43
43
  image: {
44
44
  regex: /\!\[([^\]]*?)\]\(([^)]*?)\)/g,
45
45
  replace: (args, cn) => render("img", {class: cn.image, alt: args[1], src: args[2]}),
@@ -111,7 +111,7 @@ const allExpressions = {
111
111
  };
112
112
 
113
113
  // @description inline expressions
114
- const inlineExpressions = Object.fromEntries(["link", "strong", "emphasis", "code"].map(key => {
114
+ const inlineExpressions = Object.fromEntries(["code", "link", "strong", "emphasis"].map(key => {
115
115
  return [key, allExpressions[key]];
116
116
  }));
117
117
 
@@ -125,9 +125,9 @@ const parser = (str = "", options = {}) => {
125
125
  Object.keys(expressions).forEach(key => {
126
126
  str = str.replace(expressions[key].regex, (...args) => {
127
127
  const value = expressions[key].replace(args, classNames);
128
- if (key === "pre") {
128
+ if (key === "pre" || key === "code") {
129
129
  ignoredBlocks.push(value);
130
- return `<pre>{IGNORED%${(ignoredBlocks.length - 1)}}</pre>\n`;
130
+ return `<pre>{IGNORED%${(ignoredBlocks.length - 1)}}</pre>`;
131
131
  }
132
132
  // other value --> return the value provided by the renderer
133
133
  return value;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mikel-markdown",
3
3
  "description": "A mikel helper for parsing markdown content.",
4
- "version": "0.20.2",
4
+ "version": "0.21.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {