flinker-markdown 1.1.14 → 1.1.15
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 +6 -1
- package/dist/types/md.d.ts +1 -1
- package/package.json +1 -1
package/dist/esm/md.js
CHANGED
|
@@ -264,10 +264,15 @@ export class MDParser {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
// const parser = new MDParser(new MDGrammar)
|
|
267
|
-
export const md = (parser, text, absolutePathPrefix) => {
|
|
267
|
+
export const md = (parser, text, absolutePathPrefix, mark) => {
|
|
268
268
|
let res = parser.run(text);
|
|
269
269
|
// allow images and links to have a relative path
|
|
270
270
|
if (absolutePathPrefix)
|
|
271
271
|
res = res.replace(/src="((?!https?:)[^"]+)"/gm, 'src="' + absolutePathPrefix + '$1"');
|
|
272
|
+
if (mark)
|
|
273
|
+
res = res.replace(new RegExp('(' + escapeRegExp(mark) + ')', 'gi'), '<mark>$1</mark>');
|
|
272
274
|
return res;
|
|
273
275
|
};
|
|
276
|
+
const escapeRegExp = (value) => {
|
|
277
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
278
|
+
};
|
package/dist/types/md.d.ts
CHANGED
|
@@ -61,4 +61,4 @@ export declare class MDParser {
|
|
|
61
61
|
private parseMultiline;
|
|
62
62
|
private parseLine;
|
|
63
63
|
}
|
|
64
|
-
export declare const md: (parser: MDParser, text: string, absolutePathPrefix?: string) => string;
|
|
64
|
+
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.15",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/Dittner/FlinkerMD.git"
|