flinker-markdown 1.1.13 → 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 CHANGED
@@ -114,13 +114,15 @@ export class MDGrammar {
114
114
  return res;
115
115
  };
116
116
  this.video.matcher = [/^\[video:([^, \]]+),? *([^\]]*)\]/, videoReplacer];
117
+ this.horRule = new MDLineGrammarRule();
118
+ this.horRule.matcher = [/^---$/, '<hr/>'];
117
119
  this.stars = new MDLineGrammarRule();
118
120
  this.stars.matcher = [/^(\*{3,})/, '<p class="md-delim">$1</p>'];
119
121
  this.p = new MDLineGrammarRule();
120
122
  this.p.matcher = [/^(.*)$/, '<p>$1</p>'];
121
123
  this.p.childrenInlineRules = this.globalRule.childrenInlineRules;
122
124
  this.p.preProccessing = defLinePreproccessing;
123
- this.globalRule.childrenLineRules = [this.header, this.quote, this.alignCenter, this.alignRight, this.tilde, this.audio, this.video, this.stars, this.br, this.p];
125
+ this.globalRule.childrenLineRules = [this.header, this.quote, this.alignCenter, this.alignRight, this.tilde, this.audio, this.video, this.horRule, this.stars, this.br, this.p];
124
126
  //
125
127
  // MULTILINE GRAMMAR RULES
126
128
  //
@@ -150,7 +152,7 @@ export class MDGrammar {
150
152
  this.div.startMatcher = [/^```([a-zA-Z]+) */, '<div class="$1"><div>'];
151
153
  this.div.endMatcher = [/^``` *$/, '</div></div>'];
152
154
  this.div.childrenInlineRules = this.globalRule.childrenInlineRules;
153
- this.div.childrenLineRules = [this.quote, this.alignCenter, this.alignRight, this.tilde, this.br, this.p];
155
+ this.div.childrenLineRules = [this.quote, this.alignCenter, this.alignRight, this.tilde, this.horRule, this.br, this.p];
154
156
  this.div.childrenMultilineRules = [this.div];
155
157
  this.globalRule.childrenMultilineRules = [this.ol, this.ul, this.table, this.div];
156
158
  }
@@ -262,10 +264,15 @@ export class MDParser {
262
264
  }
263
265
  }
264
266
  // const parser = new MDParser(new MDGrammar)
265
- export const md = (parser, text, absolutePathPrefix) => {
267
+ export const md = (parser, text, absolutePathPrefix, mark) => {
266
268
  let res = parser.run(text);
267
269
  // allow images and links to have a relative path
268
270
  if (absolutePathPrefix)
269
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>');
270
274
  return res;
271
275
  };
276
+ const escapeRegExp = (value) => {
277
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
278
+ };
@@ -40,6 +40,7 @@ export declare class MDGrammar {
40
40
  readonly alignRight: MDLineGrammarRule;
41
41
  readonly tilde: MDLineGrammarRule;
42
42
  readonly alignCenter: MDLineGrammarRule;
43
+ readonly horRule: MDLineGrammarRule;
43
44
  readonly stars: MDLineGrammarRule;
44
45
  readonly p: MDLineGrammarRule;
45
46
  readonly br: MDLineGrammarRule;
@@ -60,4 +61,4 @@ export declare class MDParser {
60
61
  private parseMultiline;
61
62
  private parseLine;
62
63
  }
63
- 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.13",
4
+ "version": "1.1.15",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Dittner/FlinkerMD.git"