@descope/escape-markdown 0.1.6 → 0.1.7

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.
@@ -1,2 +1,2 @@
1
- "use strict";const e=["*","#","/","(",")","[","]","_","<",">","`"],r=r=>{const s=e.map((e=>`${r}${e}`)).join("|");return new RegExp(`(${s})`,"g")};exports.escapeMarkdown=e=>"string"!=typeof e?e:e.replace(r("\\"),"\\$1"),exports.unescapeMarkdown=e=>"string"!=typeof e?e:e.replace(r("\\\\"),(e=>e.slice(1)));
1
+ "use strict";const e=/[\\*#/()[\]_<>`]/g,r=/\\([\\*#/()[\]_<>`])/g;exports.escapeMarkdown=r=>"string"!=typeof r?r:r.replace(e,"\\$&"),exports.unescapeMarkdown=e=>"string"!=typeof e?e:e.replace(r,"$1");
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../src/escapeMarkdown.ts"],"sourcesContent":["const mdChars = ['*', '#', '/', '(', ')', '[', ']', '_', '<', '>', '`'];\n\nconst createRegexp = (prefix: string) => {\n const regex = mdChars.map((char) => `${prefix}${char}`).join('|');\n return new RegExp(`(${regex})`, 'g');\n};\n\nexport const escapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(createRegexp('\\\\'), '\\\\$1');\n};\n\nexport const unescapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(createRegexp('\\\\\\\\'), (match) => match.slice(1));\n};\n"],"names":["mdChars","createRegexp","prefix","regex","map","char","join","RegExp","s","replace","match","slice"],"mappings":"aAAA,MAAMA,EAAU,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAE7DC,EAAgBC,IACpB,MAAMC,EAAQH,EAAQI,KAAKC,GAAS,GAAGH,IAASG,MAAQC,KAAK,KAC7D,OAAO,IAAIC,OAAO,IAAIJ,KAAU,IAAI,yBAGPK,GACZ,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQR,EAAa,MAAO,iCAGNO,GACd,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQR,EAAa,SAAUS,GAAUA,EAAMC,MAAM"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../../src/escapeMarkdown.ts"],"sourcesContent":["// Markdown characters escaped in values, the backslash included.\n// `.`, `@`, `-` and `&` are left as is, so emails and links keep working.\nconst escapeRegexp = /[\\\\*#/()[\\]_<>`]/g;\nconst unescapeRegexp = /\\\\([\\\\*#/()[\\]_<>`])/g;\n\nexport const escapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(escapeRegexp, '\\\\$&');\n};\n\nexport const unescapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(unescapeRegexp, '$1');\n};\n"],"names":["escapeRegexp","unescapeRegexp","s","replace"],"mappings":"aAEA,MAAMA,EAAe,oBACfC,EAAiB,+CAEQC,GACZ,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQH,EAAc,iCAGAE,GACd,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQF,EAAgB"}
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- const e=["*","#","/","(",")","[","]","_","<",">","`"],t=t=>{const n=e.map((e=>`${t}${e}`)).join("|");return new RegExp(`(${n})`,"g")},n=e=>"string"!=typeof e?e:e.replace(t("\\"),"\\$1"),p=e=>"string"!=typeof e?e:e.replace(t("\\\\"),(e=>e.slice(1)));export{n as escapeMarkdown,p as unescapeMarkdown};
1
+ const e=/[\\*#/()[\]_<>`]/g,t=/\\([\\*#/()[\]_<>`])/g,p=t=>"string"!=typeof t?t:t.replace(e,"\\$&"),r=e=>"string"!=typeof e?e:e.replace(t,"$1");export{p as escapeMarkdown,r as unescapeMarkdown};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/escapeMarkdown.ts"],"sourcesContent":["const mdChars = ['*', '#', '/', '(', ')', '[', ']', '_', '<', '>', '`'];\n\nconst createRegexp = (prefix: string) => {\n const regex = mdChars.map((char) => `${prefix}${char}`).join('|');\n return new RegExp(`(${regex})`, 'g');\n};\n\nexport const escapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(createRegexp('\\\\'), '\\\\$1');\n};\n\nexport const unescapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(createRegexp('\\\\\\\\'), (match) => match.slice(1));\n};\n"],"names":["mdChars","createRegexp","prefix","regex","map","char","join","RegExp","escapeMarkdown","s","replace","unescapeMarkdown","match","slice"],"mappings":"AAAA,MAAMA,EAAU,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAE7DC,EAAgBC,IACpB,MAAMC,EAAQH,EAAQI,KAAKC,GAAS,GAAGH,IAASG,MAAQC,KAAK,KAC7D,OAAO,IAAIC,OAAO,IAAIJ,KAAU,IAAI,EAGzBK,EAAkBC,GACZ,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQT,EAAa,MAAO,QAG1BU,EAAoBF,GACd,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQT,EAAa,SAAUW,GAAUA,EAAMC,MAAM"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/escapeMarkdown.ts"],"sourcesContent":["// Markdown characters escaped in values, the backslash included.\n// `.`, `@`, `-` and `&` are left as is, so emails and links keep working.\nconst escapeRegexp = /[\\\\*#/()[\\]_<>`]/g;\nconst unescapeRegexp = /\\\\([\\\\*#/()[\\]_<>`])/g;\n\nexport const escapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(escapeRegexp, '\\\\$&');\n};\n\nexport const unescapeMarkdown = (s: string) => {\n if (typeof s !== 'string') return s;\n return s.replace(unescapeRegexp, '$1');\n};\n"],"names":["escapeRegexp","unescapeRegexp","escapeMarkdown","s","replace","unescapeMarkdown"],"mappings":"AAEA,MAAMA,EAAe,oBACfC,EAAiB,wBAEVC,EAAkBC,GACZ,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQJ,EAAc,QAGpBK,EAAoBF,GACd,iBAANA,EAAuBA,EAC3BA,EAAEC,QAAQH,EAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/escape-markdown",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {