flinker-markdown 1.1.14 → 1.1.16
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/esm/md.js +9 -2
- package/dist/types/md.d.ts +2 -1
- package/package.json +1 -1
package/dist/esm/md.js
CHANGED
|
@@ -58,6 +58,8 @@ export class MDGrammar {
|
|
|
58
58
|
this.em.childrenInlineRules = [this.strong, this.boldItalic, this.bold, this.italic];
|
|
59
59
|
this.code = new MDInlineGrammarRule();
|
|
60
60
|
this.code.matcher = [/``([^`]+)``/g, '<code>$1</code>'];
|
|
61
|
+
this.icon = new MDInlineGrammarRule();
|
|
62
|
+
this.icon.matcher = [/#([^ ]+)/g, '<span class="md-icon">$1</span>'];
|
|
61
63
|
this.figure = new MDInlineGrammarRule();
|
|
62
64
|
this.figure.matcher = [/\[img:([^, ]+), ?([^\]]+)\]/g, '<figure><img src="$1"/><figcaption>$2</figcaption></figure>'];
|
|
63
65
|
this.img = new MDInlineGrammarRule();
|
|
@@ -66,7 +68,7 @@ export class MDGrammar {
|
|
|
66
68
|
this.link.matcher = [/\[link:([^, \]]+),? *([^\]]*)\]/g, (line, url, descr) => {
|
|
67
69
|
return '<a href="' + url + '">' + (descr || url) + '</a>';
|
|
68
70
|
}];
|
|
69
|
-
this.globalRule.childrenInlineRules = [this.code, this.figure, this.img, this.link, this.sub, this.sup, this.strong, this.boldItalic, this.bold, this.em, this.italic];
|
|
71
|
+
this.globalRule.childrenInlineRules = [this.code, this.figure, this.img, this.link, this.icon, this.sub, this.sup, this.strong, this.boldItalic, this.bold, this.em, this.italic];
|
|
70
72
|
//
|
|
71
73
|
// LINE GRAMMAR RULES
|
|
72
74
|
//
|
|
@@ -264,10 +266,15 @@ export class MDParser {
|
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
268
|
// const parser = new MDParser(new MDGrammar)
|
|
267
|
-
export const md = (parser, text, absolutePathPrefix) => {
|
|
269
|
+
export const md = (parser, text, absolutePathPrefix, mark) => {
|
|
268
270
|
let res = parser.run(text);
|
|
269
271
|
// allow images and links to have a relative path
|
|
270
272
|
if (absolutePathPrefix)
|
|
271
273
|
res = res.replace(/src="((?!https?:)[^"]+)"/gm, 'src="' + absolutePathPrefix + '$1"');
|
|
274
|
+
if (mark)
|
|
275
|
+
res = res.replace(new RegExp('(' + escapeRegExp(mark) + ')', 'gi'), '<mark>$1</mark>');
|
|
272
276
|
return res;
|
|
273
277
|
};
|
|
278
|
+
const escapeRegExp = (value) => {
|
|
279
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
280
|
+
};
|
package/dist/types/md.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare class MDGrammar {
|
|
|
32
32
|
readonly boldItalic: MDInlineGrammarRule;
|
|
33
33
|
readonly em: MDInlineGrammarRule;
|
|
34
34
|
readonly code: MDInlineGrammarRule;
|
|
35
|
+
readonly icon: MDInlineGrammarRule;
|
|
35
36
|
readonly figure: MDInlineGrammarRule;
|
|
36
37
|
readonly img: MDInlineGrammarRule;
|
|
37
38
|
readonly link: MDInlineGrammarRule;
|
|
@@ -61,4 +62,4 @@ export declare class MDParser {
|
|
|
61
62
|
private parseMultiline;
|
|
62
63
|
private parseLine;
|
|
63
64
|
}
|
|
64
|
-
export declare const md: (parser: MDParser, text: string, absolutePathPrefix?: string) => string;
|
|
65
|
+
export declare const md: (parser: MDParser, text: string, absolutePathPrefix?: string, mark?: string) => string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flinker-markdown",
|
|
3
3
|
"description": "Free TypeScript library for parsing markdown text (customisable, not standardized).",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.16",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/Dittner/FlinkerMD.git"
|