flinker-markdown 1.1.6 → 1.1.8
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 +8 -0
- package/dist/esm/md.js +20 -12
- package/dist/types/md.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,14 @@ __FlinkerMD__ (MD) is a TypeScript library for parsing markdown text into html.
|
|
|
7
7
|
npm i flinker-markdown
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
+
## Demo
|
|
11
|
+
```cli
|
|
12
|
+
git clone https://github.com/Dittner/FlinkerMD
|
|
13
|
+
cd FlinkerMD/MarkdownDemo
|
|
14
|
+
npm install
|
|
15
|
+
npm run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
10
18
|
## Example 1
|
|
11
19
|
```ts
|
|
12
20
|
import { md, MDGrammar, MDParser } from "flinker-markdown"
|
package/dist/esm/md.js
CHANGED
|
@@ -81,20 +81,22 @@ export class MDGrammar {
|
|
|
81
81
|
this.quote.matcher = [/^> (.*)$/, '<blockquote><p>$1</p></blockquote>'];
|
|
82
82
|
this.quote.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
83
83
|
this.quote.preProccessing = defLinePreproccessing;
|
|
84
|
+
this.tilde = new MDLineGrammarRule();
|
|
85
|
+
this.tilde.matcher = [/^~ (.*)$/, '<p class="md-tilde">$1</p>'];
|
|
86
|
+
this.tilde.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
87
|
+
this.tilde.preProccessing = defLinePreproccessing;
|
|
88
|
+
this.warn = new MDLineGrammarRule();
|
|
89
|
+
this.warn.matcher = [/^! (.*)$/, '<p class="md-warn">$1</p>'];
|
|
90
|
+
this.warn.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
91
|
+
this.warn.preProccessing = defLinePreproccessing;
|
|
84
92
|
this.alignRight = new MDLineGrammarRule();
|
|
85
|
-
this.alignRight.matcher = [/^==> (.*)$/, '<
|
|
93
|
+
this.alignRight.matcher = [/^==> (.*)$/, '<p class="md-right">$1</p>'];
|
|
86
94
|
this.alignRight.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
87
95
|
this.alignRight.preProccessing = defLinePreproccessing;
|
|
88
96
|
this.alignCenter = new MDLineGrammarRule();
|
|
89
|
-
this.alignCenter.matcher = [/^=> (.*)$/, '<
|
|
97
|
+
this.alignCenter.matcher = [/^=> (.*)$/, '<p class="md-center">$1</p>'];
|
|
90
98
|
this.alignCenter.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
91
99
|
this.alignCenter.preProccessing = defLinePreproccessing;
|
|
92
|
-
this.stars = new MDLineGrammarRule();
|
|
93
|
-
this.stars.matcher = [/^(\*{3,})/, '<p class="md-delim">$1</p>'];
|
|
94
|
-
this.p = new MDLineGrammarRule();
|
|
95
|
-
this.p.matcher = [/^(.*)$/, '<p>$1</p>'];
|
|
96
|
-
this.p.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
97
|
-
this.p.preProccessing = defLinePreproccessing;
|
|
98
100
|
this.br = new MDLineGrammarRule();
|
|
99
101
|
this.br.matcher = [/^\n$/, '<br/>'];
|
|
100
102
|
this.oli = new MDLineGrammarRule();
|
|
@@ -109,7 +111,13 @@ export class MDGrammar {
|
|
|
109
111
|
this.audio.matcher = [/\[audio:([^\]]+)\]/, '<audio controls src="$1"></audio>'];
|
|
110
112
|
this.video = new MDLineGrammarRule();
|
|
111
113
|
this.video.matcher = [/\[video:([^\]]+)\]/, '<video controls src="$1"></video>'];
|
|
112
|
-
this.
|
|
114
|
+
this.stars = new MDLineGrammarRule();
|
|
115
|
+
this.stars.matcher = [/^(\*{3,})/, '<p class="md-delim">$1</p>'];
|
|
116
|
+
this.p = new MDLineGrammarRule();
|
|
117
|
+
this.p.matcher = [/^(.*)$/, '<p>$1</p>'];
|
|
118
|
+
this.p.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
119
|
+
this.p.preProccessing = defLinePreproccessing;
|
|
120
|
+
this.globalRule.childrenLineRules = [this.header, this.quote, this.alignCenter, this.alignRight, this.tilde, this.warn, this.audio, this.video, this.stars, this.br, this.p];
|
|
113
121
|
//
|
|
114
122
|
// MULTILINE GRAMMAR RULES
|
|
115
123
|
//
|
|
@@ -117,12 +125,12 @@ export class MDGrammar {
|
|
|
117
125
|
this.ul = new MDMultilineGrammarRule();
|
|
118
126
|
this.ol.startMatcher = [/^```ol *$/, '<ol>'];
|
|
119
127
|
this.ol.endMatcher = [/^``` *$/, '</ol>'];
|
|
120
|
-
this.ol.childrenLineRules = [this.oli, this.br, this.p];
|
|
128
|
+
this.ol.childrenLineRules = [this.oli, this.tilde, this.warn, this.br, this.p];
|
|
121
129
|
this.ol.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
122
130
|
this.ol.childrenMultilineRules = [this.ol, this.ul];
|
|
123
131
|
this.ul.startMatcher = [/^```ul *$/, '<ul>'];
|
|
124
132
|
this.ul.endMatcher = [/^``` *$/, '</ul>'];
|
|
125
|
-
this.ul.childrenLineRules = [this.uli, this.br, this.p];
|
|
133
|
+
this.ul.childrenLineRules = [this.uli, this.tilde, this.warn, this.br, this.p];
|
|
126
134
|
this.ul.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
127
135
|
this.ul.childrenMultilineRules = [this.ol, this.ul];
|
|
128
136
|
this.table = new MDMultilineGrammarRule();
|
|
@@ -139,7 +147,7 @@ export class MDGrammar {
|
|
|
139
147
|
this.div.startMatcher = [/^```([a-zA-Z]+) */, '<div class="$1"><div>'];
|
|
140
148
|
this.div.endMatcher = [/^``` *$/, '</div></div>'];
|
|
141
149
|
this.div.childrenInlineRules = this.globalRule.childrenInlineRules;
|
|
142
|
-
this.div.childrenLineRules = [this.quote, this.alignCenter, this.alignRight, this.br, this.p];
|
|
150
|
+
this.div.childrenLineRules = [this.quote, this.alignCenter, this.alignRight, this.tilde, this.warn, this.br, this.p];
|
|
143
151
|
this.div.childrenMultilineRules = [this.div];
|
|
144
152
|
this.globalRule.childrenMultilineRules = [this.ol, this.ul, this.table, this.div];
|
|
145
153
|
}
|
package/dist/types/md.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export declare class MDGrammar {
|
|
|
38
38
|
readonly header: MDLineGrammarRule;
|
|
39
39
|
readonly quote: MDLineGrammarRule;
|
|
40
40
|
readonly alignRight: MDLineGrammarRule;
|
|
41
|
+
readonly tilde: MDLineGrammarRule;
|
|
42
|
+
readonly warn: MDLineGrammarRule;
|
|
41
43
|
readonly alignCenter: MDLineGrammarRule;
|
|
42
44
|
readonly stars: MDLineGrammarRule;
|
|
43
45
|
readonly p: 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.
|
|
4
|
+
"version": "1.1.8",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/Dittner/FlinkerMD.git"
|