flinker-markdown 1.1.10 → 1.1.12

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/README.md CHANGED
@@ -21,7 +21,7 @@ import { div, TextProps } from "flinker-dom"
21
21
  import { md, MDGrammar, MDParser } from "flinker-markdown"
22
22
 
23
23
  interface MarkdownProps extends TextProps {
24
- absolutePathPrefix?: string
24
+ absolutePathPrefix?: string //it will be added to the relative path of a media file [<a>, <img>, <audio>, <video>]
25
25
  mode: 'md' | 'rawText' | 'rawHtml'
26
26
  }
27
27
 
package/dist/esm/md.js CHANGED
@@ -59,11 +59,11 @@ export class MDGrammar {
59
59
  this.code = new MDInlineGrammarRule();
60
60
  this.code.matcher = [/``([^`]+)``/g, '<code>$1</code>'];
61
61
  this.figure = new MDInlineGrammarRule();
62
- this.figure.matcher = [/\[img:([^, ]+), ?([^\]]+)\]/gm, '<figure><img src="$1"/><figcaption>$2</figcaption></figure>'];
62
+ this.figure.matcher = [/\[img:([^, ]+), ?([^\]]+)\]/g, '<figure><img src="$1"/><figcaption>$2</figcaption></figure>'];
63
63
  this.img = new MDInlineGrammarRule();
64
- this.img.matcher = [/\[img:([^\]]+)\]/gm, '<img src="$1"/>'];
64
+ this.img.matcher = [/\[img:([^\]]+)\]/g, '<img src="$1"/>'];
65
65
  this.link = new MDInlineGrammarRule();
66
- this.link.matcher = [/\[link:([^, ]+),? ?([^\]]*)\]/, (line, url, descr) => {
66
+ this.link.matcher = [/\[link:([^, \]]+),? *([^\]]*)\]/g, (line, url, descr) => {
67
67
  return '<a href="' + url + '">' + (descr || url) + '</a>';
68
68
  }];
69
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];
@@ -106,7 +106,14 @@ export class MDGrammar {
106
106
  this.audio = new MDLineGrammarRule();
107
107
  this.audio.matcher = [/\[audio:([^\]]+)\]/, '<audio controls src="$1"></audio>'];
108
108
  this.video = new MDLineGrammarRule();
109
- this.video.matcher = [/\[video:([^\]]+)\]/, '<video controls src="$1"></video>'];
109
+ const videoReplacer = (_, url, params) => {
110
+ const keyValues = params ? params.split(/, */) : [];
111
+ let res = '<video src="' + url + '"';
112
+ keyValues.forEach(kv => res += kv.replace(/^ *([^:]+):?(.*)$/, (_, key, value) => value ? ` ${key}="${value}"` : ` ${key}`));
113
+ res += '></video>';
114
+ return res;
115
+ };
116
+ this.video.matcher = [/\[video:([^\]]+)\]/, videoReplacer];
110
117
  this.stars = new MDLineGrammarRule();
111
118
  this.stars.matcher = [/^(\*{3,})/, '<p class="md-delim">$1</p>'];
112
119
  this.p = new MDLineGrammarRule();
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.10",
4
+ "version": "1.1.12",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Dittner/FlinkerMD.git"