marked 7.0.0 → 7.0.2
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/lib/marked.cjs +2541 -2180
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.ts +692 -591
- package/lib/marked.esm.js +2522 -2136
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +2566 -2179
- package/lib/marked.umd.js.map +1 -1
- package/marked.min.js +3 -3
- package/package.json +14 -13
- package/lib/marked.d.cts +0 -624
- package/src/Hooks.ts +0 -29
- package/src/Instance.ts +0 -381
- package/src/Lexer.ts +0 -517
- package/src/MarkedOptions.ts +0 -212
- package/src/Parser.ts +0 -291
- package/src/Renderer.ts +0 -167
- package/src/Slugger.ts +0 -51
- package/src/TextRenderer.ts +0 -42
- package/src/Tokenizer.ts +0 -810
- package/src/Tokens.ts +0 -199
- package/src/defaults.ts +0 -35
- package/src/helpers.ts +0 -264
- package/src/marked.ts +0 -144
- package/src/rules.ts +0 -380
package/src/rules.ts
DELETED
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
noopTest,
|
|
3
|
-
edit
|
|
4
|
-
} from './helpers.ts';
|
|
5
|
-
|
|
6
|
-
export type Rule = RegExp | string;
|
|
7
|
-
|
|
8
|
-
export interface Rules {
|
|
9
|
-
[ruleName: string]: Pick<RegExp, 'exec'> | Rule | Rules;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type BlockRuleNames =
|
|
13
|
-
| 'newline'
|
|
14
|
-
| 'code'
|
|
15
|
-
| 'fences'
|
|
16
|
-
| 'hr'
|
|
17
|
-
| 'heading'
|
|
18
|
-
| 'blockquote'
|
|
19
|
-
| 'list'
|
|
20
|
-
| 'html'
|
|
21
|
-
| 'def'
|
|
22
|
-
| 'lheading'
|
|
23
|
-
| '_paragraph'
|
|
24
|
-
| 'text'
|
|
25
|
-
| '_label'
|
|
26
|
-
| '_title'
|
|
27
|
-
| 'bullet'
|
|
28
|
-
| 'listItemStart'
|
|
29
|
-
| '_tag'
|
|
30
|
-
| '_comment'
|
|
31
|
-
| 'paragraph'
|
|
32
|
-
| 'uote' ;
|
|
33
|
-
|
|
34
|
-
type BlockSubRuleNames = 'normal' | 'gfm' | 'pedantic';
|
|
35
|
-
|
|
36
|
-
type InlineRuleNames =
|
|
37
|
-
| 'escape'
|
|
38
|
-
| 'autolink'
|
|
39
|
-
| 'tag'
|
|
40
|
-
| 'link'
|
|
41
|
-
| 'reflink'
|
|
42
|
-
| 'nolink'
|
|
43
|
-
| 'reflinkSearch'
|
|
44
|
-
| 'code'
|
|
45
|
-
| 'br'
|
|
46
|
-
| 'text'
|
|
47
|
-
| '_punctuation'
|
|
48
|
-
| 'punctuation'
|
|
49
|
-
| 'blockSkip'
|
|
50
|
-
| 'escapedEmSt'
|
|
51
|
-
| '_comment'
|
|
52
|
-
| '_escapes'
|
|
53
|
-
| '_scheme'
|
|
54
|
-
| '_email'
|
|
55
|
-
| '_attribute'
|
|
56
|
-
| '_label'
|
|
57
|
-
| '_href'
|
|
58
|
-
| '_title'
|
|
59
|
-
| 'strong'
|
|
60
|
-
| '_extended_email'
|
|
61
|
-
| '_backpedal';
|
|
62
|
-
|
|
63
|
-
type InlineSubRuleNames = 'gfm' | 'emStrong' | 'normal' | 'pedantic'| 'breaks';
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Block-Level Grammar
|
|
67
|
-
*/
|
|
68
|
-
// Not all rules are defined in the object literal
|
|
69
|
-
// @ts-expect-error
|
|
70
|
-
export const block: Record<BlockRuleNames, Rule> & Record<BlockSubRuleNames, Rules> & Rules = {
|
|
71
|
-
newline: /^(?: *(?:\n|$))+/,
|
|
72
|
-
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
73
|
-
fences: /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
74
|
-
hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
75
|
-
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
76
|
-
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
77
|
-
list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
|
|
78
|
-
html: '^ {0,3}(?:' // optional indentation
|
|
79
|
-
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
80
|
-
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
81
|
-
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
82
|
-
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
83
|
-
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
84
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
85
|
-
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
86
|
-
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
87
|
-
+ ')',
|
|
88
|
-
def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
|
|
89
|
-
table: noopTest,
|
|
90
|
-
lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
91
|
-
// regex template, placeholders will be replaced according to different paragraph
|
|
92
|
-
// interruption rules of commonmark and the original markdown spec:
|
|
93
|
-
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
94
|
-
text: /^[^\n]+/
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
98
|
-
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
99
|
-
block.def = edit(block.def)
|
|
100
|
-
.replace('label', block._label)
|
|
101
|
-
.replace('title', block._title)
|
|
102
|
-
.getRegex();
|
|
103
|
-
|
|
104
|
-
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
105
|
-
block.listItemStart = edit(/^( *)(bull) */)
|
|
106
|
-
.replace('bull', block.bullet)
|
|
107
|
-
.getRegex();
|
|
108
|
-
|
|
109
|
-
block.list = edit(block.list)
|
|
110
|
-
.replace(/bull/g, block.bullet)
|
|
111
|
-
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
112
|
-
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
113
|
-
.getRegex();
|
|
114
|
-
|
|
115
|
-
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
116
|
-
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
|
117
|
-
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
|
118
|
-
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
|
119
|
-
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
|
120
|
-
+ '|track|ul';
|
|
121
|
-
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
122
|
-
block.html = edit(block.html, 'i')
|
|
123
|
-
.replace('comment', block._comment)
|
|
124
|
-
.replace('tag', block._tag)
|
|
125
|
-
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
|
126
|
-
.getRegex();
|
|
127
|
-
|
|
128
|
-
block.lheading = edit(block.lheading)
|
|
129
|
-
.replace(/bull/g, block.bullet) // lists can interrupt
|
|
130
|
-
.getRegex();
|
|
131
|
-
|
|
132
|
-
block.paragraph = edit(block._paragraph)
|
|
133
|
-
.replace('hr', block.hr)
|
|
134
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
135
|
-
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
136
|
-
.replace('|table', '')
|
|
137
|
-
.replace('blockquote', ' {0,3}>')
|
|
138
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
139
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
140
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
141
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
142
|
-
.getRegex();
|
|
143
|
-
|
|
144
|
-
block.blockquote = edit(block.blockquote)
|
|
145
|
-
.replace('paragraph', block.paragraph)
|
|
146
|
-
.getRegex();
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Normal Block Grammar
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
block.normal = { ...block };
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* GFM Block Grammar
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
block.gfm = {
|
|
159
|
-
...block.normal,
|
|
160
|
-
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
161
|
-
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
162
|
-
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
block.gfm.table = edit(block.gfm.table as Rule)
|
|
166
|
-
.replace('hr', block.hr)
|
|
167
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
168
|
-
.replace('blockquote', ' {0,3}>')
|
|
169
|
-
.replace('code', ' {4}[^\\n]')
|
|
170
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
171
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
172
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
173
|
-
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
174
|
-
.getRegex();
|
|
175
|
-
|
|
176
|
-
block.gfm.paragraph = edit(block._paragraph)
|
|
177
|
-
.replace('hr', block.hr)
|
|
178
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
179
|
-
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
180
|
-
.replace('table', block.gfm.table as RegExp) // interrupt paragraphs with table
|
|
181
|
-
.replace('blockquote', ' {0,3}>')
|
|
182
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
183
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
184
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
185
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
186
|
-
.getRegex();
|
|
187
|
-
/**
|
|
188
|
-
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
|
-
block.pedantic = {
|
|
192
|
-
...block.normal,
|
|
193
|
-
html: edit(
|
|
194
|
-
'^ *(?:comment *(?:\\n|\\s*$)'
|
|
195
|
-
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
196
|
-
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
197
|
-
.replace('comment', block._comment)
|
|
198
|
-
.replace(/tag/g, '(?!(?:'
|
|
199
|
-
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
200
|
-
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
201
|
-
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
|
202
|
-
.getRegex(),
|
|
203
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
204
|
-
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
205
|
-
fences: noopTest, // fences not supported
|
|
206
|
-
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
207
|
-
paragraph: edit(block.normal._paragraph as Rule)
|
|
208
|
-
.replace('hr', block.hr)
|
|
209
|
-
.replace('heading', ' *#{1,6} *[^\n]')
|
|
210
|
-
.replace('lheading', block.lheading)
|
|
211
|
-
.replace('blockquote', ' {0,3}>')
|
|
212
|
-
.replace('|fences', '')
|
|
213
|
-
.replace('|list', '')
|
|
214
|
-
.replace('|html', '')
|
|
215
|
-
.getRegex()
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Inline-Level Grammar
|
|
220
|
-
*/
|
|
221
|
-
// Not all rules are defined in the object literal
|
|
222
|
-
// @ts-expect-error
|
|
223
|
-
export const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules = {
|
|
224
|
-
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
225
|
-
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
226
|
-
url: noopTest,
|
|
227
|
-
tag: '^comment'
|
|
228
|
-
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
229
|
-
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
230
|
-
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
231
|
-
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
232
|
-
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
|
|
233
|
-
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
234
|
-
reflink: /^!?\[(label)\]\[(ref)\]/,
|
|
235
|
-
nolink: /^!?\[(ref)\](?:\[\])?/,
|
|
236
|
-
reflinkSearch: 'reflink|nolink(?!\\()',
|
|
237
|
-
emStrong: {
|
|
238
|
-
lDelim: /^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,
|
|
239
|
-
// (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
|
|
240
|
-
// | Skip orphan inside strong | Consume to delim | (1) #*** | (2) a***#, a*** | (3) #***a, ***a | (4) ***# | (5) #***# | (6) a***a
|
|
241
|
-
rDelimAst: /^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,
|
|
242
|
-
rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/ // ^- Not allowed for _
|
|
243
|
-
},
|
|
244
|
-
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
245
|
-
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
246
|
-
del: noopTest,
|
|
247
|
-
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
248
|
-
punctuation: /^((?![*_])[\spunctuation])/
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
// list of unicode punctuation marks, plus any missing characters from CommonMark spec
|
|
252
|
-
inline._punctuation = '\\p{P}$+<=>`^|~';
|
|
253
|
-
inline.punctuation = edit(inline.punctuation, 'u').replace(/punctuation/g, inline._punctuation).getRegex();
|
|
254
|
-
|
|
255
|
-
// sequences em should skip over [title](link), `code`, <html>
|
|
256
|
-
inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
|
|
257
|
-
inline.anyPunctuation = /\\[punct]/g;
|
|
258
|
-
inline._escapes = /\\([punct])/g;
|
|
259
|
-
|
|
260
|
-
inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
261
|
-
|
|
262
|
-
inline.emStrong.lDelim = edit(inline.emStrong.lDelim as Rule, 'u')
|
|
263
|
-
.replace(/punct/g, inline._punctuation)
|
|
264
|
-
.getRegex();
|
|
265
|
-
|
|
266
|
-
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst as Rule, 'gu')
|
|
267
|
-
.replace(/punct/g, inline._punctuation)
|
|
268
|
-
.getRegex();
|
|
269
|
-
|
|
270
|
-
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd as Rule, 'gu')
|
|
271
|
-
.replace(/punct/g, inline._punctuation)
|
|
272
|
-
.getRegex();
|
|
273
|
-
|
|
274
|
-
inline.anyPunctuation = edit(inline.anyPunctuation as Rule, 'gu')
|
|
275
|
-
.replace(/punct/g, inline._punctuation)
|
|
276
|
-
.getRegex();
|
|
277
|
-
|
|
278
|
-
inline._escapes = edit(inline._escapes, 'gu')
|
|
279
|
-
.replace(/punct/g, inline._punctuation)
|
|
280
|
-
.getRegex();
|
|
281
|
-
|
|
282
|
-
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
283
|
-
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
284
|
-
inline.autolink = edit(inline.autolink)
|
|
285
|
-
.replace('scheme', inline._scheme)
|
|
286
|
-
.replace('email', inline._email)
|
|
287
|
-
.getRegex();
|
|
288
|
-
|
|
289
|
-
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
290
|
-
|
|
291
|
-
inline.tag = edit(inline.tag)
|
|
292
|
-
.replace('comment', inline._comment)
|
|
293
|
-
.replace('attribute', inline._attribute)
|
|
294
|
-
.getRegex();
|
|
295
|
-
|
|
296
|
-
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
297
|
-
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
298
|
-
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
299
|
-
|
|
300
|
-
inline.link = edit(inline.link)
|
|
301
|
-
.replace('label', inline._label)
|
|
302
|
-
.replace('href', inline._href)
|
|
303
|
-
.replace('title', inline._title)
|
|
304
|
-
.getRegex();
|
|
305
|
-
|
|
306
|
-
inline.reflink = edit(inline.reflink)
|
|
307
|
-
.replace('label', inline._label)
|
|
308
|
-
.replace('ref', block._label)
|
|
309
|
-
.getRegex();
|
|
310
|
-
|
|
311
|
-
inline.nolink = edit(inline.nolink)
|
|
312
|
-
.replace('ref', block._label)
|
|
313
|
-
.getRegex();
|
|
314
|
-
|
|
315
|
-
inline.reflinkSearch = edit(inline.reflinkSearch, 'g')
|
|
316
|
-
.replace('reflink', inline.reflink)
|
|
317
|
-
.replace('nolink', inline.nolink)
|
|
318
|
-
.getRegex();
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Normal Inline Grammar
|
|
322
|
-
*/
|
|
323
|
-
|
|
324
|
-
inline.normal = { ...inline };
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Pedantic Inline Grammar
|
|
328
|
-
*/
|
|
329
|
-
|
|
330
|
-
inline.pedantic = {
|
|
331
|
-
...inline.normal,
|
|
332
|
-
strong: {
|
|
333
|
-
start: /^__|\*\*/,
|
|
334
|
-
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
335
|
-
endAst: /\*\*(?!\*)/g,
|
|
336
|
-
endUnd: /__(?!_)/g
|
|
337
|
-
},
|
|
338
|
-
em: {
|
|
339
|
-
start: /^_|\*/,
|
|
340
|
-
middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
|
341
|
-
endAst: /\*(?!\*)/g,
|
|
342
|
-
endUnd: /_(?!_)/g
|
|
343
|
-
},
|
|
344
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
345
|
-
.replace('label', inline._label)
|
|
346
|
-
.getRegex(),
|
|
347
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
348
|
-
.replace('label', inline._label)
|
|
349
|
-
.getRegex()
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* GFM Inline Grammar
|
|
354
|
-
*/
|
|
355
|
-
|
|
356
|
-
inline.gfm = {
|
|
357
|
-
...inline.normal,
|
|
358
|
-
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
359
|
-
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
360
|
-
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
361
|
-
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
362
|
-
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
363
|
-
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
inline.gfm.url = edit(inline.gfm.url as Rule, 'i')
|
|
367
|
-
.replace('email', inline.gfm._extended_email as RegExp)
|
|
368
|
-
.getRegex();
|
|
369
|
-
/**
|
|
370
|
-
* GFM + Line Breaks Inline Grammar
|
|
371
|
-
*/
|
|
372
|
-
|
|
373
|
-
inline.breaks = {
|
|
374
|
-
...inline.gfm,
|
|
375
|
-
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
376
|
-
text: edit(inline.gfm.text as Rule)
|
|
377
|
-
.replace('\\b_', '\\b_| {2,}\\n')
|
|
378
|
-
.replace(/\{2,\}/g, '*')
|
|
379
|
-
.getRegex()
|
|
380
|
-
};
|