Spaces:
Paused
Paused
Include updated package-lock.json (part 4)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/micromark-core-commonmark/dev/index.d.ts +23 -0
- node_modules/micromark-core-commonmark/dev/index.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/index.js +22 -0
- node_modules/micromark-core-commonmark/dev/lib/attention.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/attention.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/attention.js +300 -0
- node_modules/micromark-core-commonmark/dev/lib/autolink.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/autolink.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/autolink.js +269 -0
- node_modules/micromark-core-commonmark/dev/lib/blank-line.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/blank-line.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/blank-line.js +62 -0
- node_modules/micromark-core-commonmark/dev/lib/block-quote.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/block-quote.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/block-quote.js +162 -0
- node_modules/micromark-core-commonmark/dev/lib/character-escape.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/character-escape.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/character-escape.js +69 -0
- node_modules/micromark-core-commonmark/dev/lib/character-reference.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/character-reference.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/character-reference.js +166 -0
- node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +514 -0
- node_modules/micromark-core-commonmark/dev/lib/code-indented.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/code-indented.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/code-indented.js +202 -0
- node_modules/micromark-core-commonmark/dev/lib/code-text.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/code-text.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/code-text.js +257 -0
- node_modules/micromark-core-commonmark/dev/lib/content.d.ts +7 -0
- node_modules/micromark-core-commonmark/dev/lib/content.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/content.js +185 -0
- node_modules/micromark-core-commonmark/dev/lib/definition.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/definition.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/definition.js +295 -0
- node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.js +65 -0
- node_modules/micromark-core-commonmark/dev/lib/heading-atx.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/heading-atx.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +233 -0
- node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/html-flow.js +989 -0
- node_modules/micromark-core-commonmark/dev/lib/html-text.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/html-text.d.ts.map +1 -0
- node_modules/micromark-core-commonmark/dev/lib/html-text.js +783 -0
- node_modules/micromark-core-commonmark/dev/lib/label-end.d.ts +4 -0
- node_modules/micromark-core-commonmark/dev/lib/label-end.d.ts.map +1 -0
node_modules/micromark-core-commonmark/dev/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { attention } from "./lib/attention.js";
|
| 2 |
+
export { autolink } from "./lib/autolink.js";
|
| 3 |
+
export { blankLine } from "./lib/blank-line.js";
|
| 4 |
+
export { blockQuote } from "./lib/block-quote.js";
|
| 5 |
+
export { characterEscape } from "./lib/character-escape.js";
|
| 6 |
+
export { characterReference } from "./lib/character-reference.js";
|
| 7 |
+
export { codeFenced } from "./lib/code-fenced.js";
|
| 8 |
+
export { codeIndented } from "./lib/code-indented.js";
|
| 9 |
+
export { codeText } from "./lib/code-text.js";
|
| 10 |
+
export { content } from "./lib/content.js";
|
| 11 |
+
export { definition } from "./lib/definition.js";
|
| 12 |
+
export { hardBreakEscape } from "./lib/hard-break-escape.js";
|
| 13 |
+
export { headingAtx } from "./lib/heading-atx.js";
|
| 14 |
+
export { htmlFlow } from "./lib/html-flow.js";
|
| 15 |
+
export { htmlText } from "./lib/html-text.js";
|
| 16 |
+
export { labelEnd } from "./lib/label-end.js";
|
| 17 |
+
export { labelStartImage } from "./lib/label-start-image.js";
|
| 18 |
+
export { labelStartLink } from "./lib/label-start-link.js";
|
| 19 |
+
export { lineEnding } from "./lib/line-ending.js";
|
| 20 |
+
export { list } from "./lib/list.js";
|
| 21 |
+
export { setextUnderline } from "./lib/setext-underline.js";
|
| 22 |
+
export { thematicBreak } from "./lib/thematic-break.js";
|
| 23 |
+
//# sourceMappingURL=index.d.ts.map
|
node_modules/micromark-core-commonmark/dev/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|
node_modules/micromark-core-commonmark/dev/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export {attention} from './lib/attention.js'
|
| 2 |
+
export {autolink} from './lib/autolink.js'
|
| 3 |
+
export {blankLine} from './lib/blank-line.js'
|
| 4 |
+
export {blockQuote} from './lib/block-quote.js'
|
| 5 |
+
export {characterEscape} from './lib/character-escape.js'
|
| 6 |
+
export {characterReference} from './lib/character-reference.js'
|
| 7 |
+
export {codeFenced} from './lib/code-fenced.js'
|
| 8 |
+
export {codeIndented} from './lib/code-indented.js'
|
| 9 |
+
export {codeText} from './lib/code-text.js'
|
| 10 |
+
export {content} from './lib/content.js'
|
| 11 |
+
export {definition} from './lib/definition.js'
|
| 12 |
+
export {hardBreakEscape} from './lib/hard-break-escape.js'
|
| 13 |
+
export {headingAtx} from './lib/heading-atx.js'
|
| 14 |
+
export {htmlFlow} from './lib/html-flow.js'
|
| 15 |
+
export {htmlText} from './lib/html-text.js'
|
| 16 |
+
export {labelEnd} from './lib/label-end.js'
|
| 17 |
+
export {labelStartImage} from './lib/label-start-image.js'
|
| 18 |
+
export {labelStartLink} from './lib/label-start-link.js'
|
| 19 |
+
export {lineEnding} from './lib/line-ending.js'
|
| 20 |
+
export {list} from './lib/list.js'
|
| 21 |
+
export {setextUnderline} from './lib/setext-underline.js'
|
| 22 |
+
export {thematicBreak} from './lib/thematic-break.js'
|
node_modules/micromark-core-commonmark/dev/lib/attention.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const attention: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=attention.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/attention.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"attention.d.ts","sourceRoot":"","sources":["attention.js"],"names":[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izeContext,
|
| 10 |
+
* Tokenizer,
|
| 11 |
+
* Token
|
| 12 |
+
* } from 'micromark-util-types'
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
import {ok as assert} from 'devlop'
|
| 16 |
+
import {push, splice} from 'micromark-util-chunked'
|
| 17 |
+
import {classifyCharacter} from 'micromark-util-classify-character'
|
| 18 |
+
import {resolveAll} from 'micromark-util-resolve-all'
|
| 19 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 20 |
+
|
| 21 |
+
/** @type {Construct} */
|
| 22 |
+
export const attention = {
|
| 23 |
+
name: 'attention',
|
| 24 |
+
resolveAll: resolveAllAttention,
|
| 25 |
+
tokenize: tokenizeAttention
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Take all events and resolve attention to emphasis or strong.
|
| 30 |
+
*
|
| 31 |
+
* @type {Resolver}
|
| 32 |
+
*/
|
| 33 |
+
// eslint-disable-next-line complexity
|
| 34 |
+
function resolveAllAttention(events, context) {
|
| 35 |
+
let index = -1
|
| 36 |
+
/** @type {number} */
|
| 37 |
+
let open
|
| 38 |
+
/** @type {Token} */
|
| 39 |
+
let group
|
| 40 |
+
/** @type {Token} */
|
| 41 |
+
let text
|
| 42 |
+
/** @type {Token} */
|
| 43 |
+
let openingSequence
|
| 44 |
+
/** @type {Token} */
|
| 45 |
+
let closingSequence
|
| 46 |
+
/** @type {number} */
|
| 47 |
+
let use
|
| 48 |
+
/** @type {Array<Event>} */
|
| 49 |
+
let nextEvents
|
| 50 |
+
/** @type {number} */
|
| 51 |
+
let offset
|
| 52 |
+
|
| 53 |
+
// Walk through all events.
|
| 54 |
+
//
|
| 55 |
+
// Note: performance of this is fine on an mb of normal markdown, but it’s
|
| 56 |
+
// a bottleneck for malicious stuff.
|
| 57 |
+
while (++index < events.length) {
|
| 58 |
+
// Find a token that can close.
|
| 59 |
+
if (
|
| 60 |
+
events[index][0] === 'enter' &&
|
| 61 |
+
events[index][1].type === 'attentionSequence' &&
|
| 62 |
+
events[index][1]._close
|
| 63 |
+
) {
|
| 64 |
+
open = index
|
| 65 |
+
|
| 66 |
+
// Now walk back to find an opener.
|
| 67 |
+
while (open--) {
|
| 68 |
+
// Find a token that can open the closer.
|
| 69 |
+
if (
|
| 70 |
+
events[open][0] === 'exit' &&
|
| 71 |
+
events[open][1].type === 'attentionSequence' &&
|
| 72 |
+
events[open][1]._open &&
|
| 73 |
+
// If the markers are the same:
|
| 74 |
+
context.sliceSerialize(events[open][1]).charCodeAt(0) ===
|
| 75 |
+
context.sliceSerialize(events[index][1]).charCodeAt(0)
|
| 76 |
+
) {
|
| 77 |
+
// If the opening can close or the closing can open,
|
| 78 |
+
// and the close size *is not* a multiple of three,
|
| 79 |
+
// but the sum of the opening and closing size *is* multiple of three,
|
| 80 |
+
// then don’t match.
|
| 81 |
+
if (
|
| 82 |
+
(events[open][1]._close || events[index][1]._open) &&
|
| 83 |
+
(events[index][1].end.offset - events[index][1].start.offset) % 3 &&
|
| 84 |
+
!(
|
| 85 |
+
(events[open][1].end.offset -
|
| 86 |
+
events[open][1].start.offset +
|
| 87 |
+
events[index][1].end.offset -
|
| 88 |
+
events[index][1].start.offset) %
|
| 89 |
+
3
|
| 90 |
+
)
|
| 91 |
+
) {
|
| 92 |
+
continue
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
// Number of markers to use from the sequence.
|
| 96 |
+
use =
|
| 97 |
+
events[open][1].end.offset - events[open][1].start.offset > 1 &&
|
| 98 |
+
events[index][1].end.offset - events[index][1].start.offset > 1
|
| 99 |
+
? 2
|
| 100 |
+
: 1
|
| 101 |
+
|
| 102 |
+
const start = {...events[open][1].end}
|
| 103 |
+
const end = {...events[index][1].start}
|
| 104 |
+
movePoint(start, -use)
|
| 105 |
+
movePoint(end, use)
|
| 106 |
+
|
| 107 |
+
openingSequence = {
|
| 108 |
+
type: use > 1 ? types.strongSequence : types.emphasisSequence,
|
| 109 |
+
start,
|
| 110 |
+
end: {...events[open][1].end}
|
| 111 |
+
}
|
| 112 |
+
closingSequence = {
|
| 113 |
+
type: use > 1 ? types.strongSequence : types.emphasisSequence,
|
| 114 |
+
start: {...events[index][1].start},
|
| 115 |
+
end
|
| 116 |
+
}
|
| 117 |
+
text = {
|
| 118 |
+
type: use > 1 ? types.strongText : types.emphasisText,
|
| 119 |
+
start: {...events[open][1].end},
|
| 120 |
+
end: {...events[index][1].start}
|
| 121 |
+
}
|
| 122 |
+
group = {
|
| 123 |
+
type: use > 1 ? types.strong : types.emphasis,
|
| 124 |
+
start: {...openingSequence.start},
|
| 125 |
+
end: {...closingSequence.end}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
events[open][1].end = {...openingSequence.start}
|
| 129 |
+
events[index][1].start = {...closingSequence.end}
|
| 130 |
+
|
| 131 |
+
nextEvents = []
|
| 132 |
+
|
| 133 |
+
// If there are more markers in the opening, add them before.
|
| 134 |
+
if (events[open][1].end.offset - events[open][1].start.offset) {
|
| 135 |
+
nextEvents = push(nextEvents, [
|
| 136 |
+
['enter', events[open][1], context],
|
| 137 |
+
['exit', events[open][1], context]
|
| 138 |
+
])
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
// Opening.
|
| 142 |
+
nextEvents = push(nextEvents, [
|
| 143 |
+
['enter', group, context],
|
| 144 |
+
['enter', openingSequence, context],
|
| 145 |
+
['exit', openingSequence, context],
|
| 146 |
+
['enter', text, context]
|
| 147 |
+
])
|
| 148 |
+
|
| 149 |
+
// Always populated by defaults.
|
| 150 |
+
assert(
|
| 151 |
+
context.parser.constructs.insideSpan.null,
|
| 152 |
+
'expected `insideSpan` to be populated'
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
// Between.
|
| 156 |
+
nextEvents = push(
|
| 157 |
+
nextEvents,
|
| 158 |
+
resolveAll(
|
| 159 |
+
context.parser.constructs.insideSpan.null,
|
| 160 |
+
events.slice(open + 1, index),
|
| 161 |
+
context
|
| 162 |
+
)
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
// Closing.
|
| 166 |
+
nextEvents = push(nextEvents, [
|
| 167 |
+
['exit', text, context],
|
| 168 |
+
['enter', closingSequence, context],
|
| 169 |
+
['exit', closingSequence, context],
|
| 170 |
+
['exit', group, context]
|
| 171 |
+
])
|
| 172 |
+
|
| 173 |
+
// If there are more markers in the closing, add them after.
|
| 174 |
+
if (events[index][1].end.offset - events[index][1].start.offset) {
|
| 175 |
+
offset = 2
|
| 176 |
+
nextEvents = push(nextEvents, [
|
| 177 |
+
['enter', events[index][1], context],
|
| 178 |
+
['exit', events[index][1], context]
|
| 179 |
+
])
|
| 180 |
+
} else {
|
| 181 |
+
offset = 0
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
splice(events, open - 1, index - open + 3, nextEvents)
|
| 185 |
+
|
| 186 |
+
index = open + nextEvents.length - offset - 2
|
| 187 |
+
break
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
// Remove remaining sequences.
|
| 194 |
+
index = -1
|
| 195 |
+
|
| 196 |
+
while (++index < events.length) {
|
| 197 |
+
if (events[index][1].type === 'attentionSequence') {
|
| 198 |
+
events[index][1].type = 'data'
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
return events
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
* @this {TokenizeContext}
|
| 207 |
+
* Context.
|
| 208 |
+
* @type {Tokenizer}
|
| 209 |
+
*/
|
| 210 |
+
function tokenizeAttention(effects, ok) {
|
| 211 |
+
const attentionMarkers = this.parser.constructs.attentionMarkers.null
|
| 212 |
+
const previous = this.previous
|
| 213 |
+
const before = classifyCharacter(previous)
|
| 214 |
+
|
| 215 |
+
/** @type {NonNullable<Code>} */
|
| 216 |
+
let marker
|
| 217 |
+
|
| 218 |
+
return start
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Before a sequence.
|
| 222 |
+
*
|
| 223 |
+
* ```markdown
|
| 224 |
+
* > | **
|
| 225 |
+
* ^
|
| 226 |
+
* ```
|
| 227 |
+
*
|
| 228 |
+
* @type {State}
|
| 229 |
+
*/
|
| 230 |
+
function start(code) {
|
| 231 |
+
assert(
|
| 232 |
+
code === codes.asterisk || code === codes.underscore,
|
| 233 |
+
'expected asterisk or underscore'
|
| 234 |
+
)
|
| 235 |
+
marker = code
|
| 236 |
+
effects.enter('attentionSequence')
|
| 237 |
+
return inside(code)
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* In a sequence.
|
| 242 |
+
*
|
| 243 |
+
* ```markdown
|
| 244 |
+
* > | **
|
| 245 |
+
* ^^
|
| 246 |
+
* ```
|
| 247 |
+
*
|
| 248 |
+
* @type {State}
|
| 249 |
+
*/
|
| 250 |
+
function inside(code) {
|
| 251 |
+
if (code === marker) {
|
| 252 |
+
effects.consume(code)
|
| 253 |
+
return inside
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
const token = effects.exit('attentionSequence')
|
| 257 |
+
|
| 258 |
+
// To do: next major: move this to resolver, just like `markdown-rs`.
|
| 259 |
+
const after = classifyCharacter(code)
|
| 260 |
+
|
| 261 |
+
// Always populated by defaults.
|
| 262 |
+
assert(attentionMarkers, 'expected `attentionMarkers` to be populated')
|
| 263 |
+
|
| 264 |
+
const open =
|
| 265 |
+
!after ||
|
| 266 |
+
(after === constants.characterGroupPunctuation && before) ||
|
| 267 |
+
attentionMarkers.includes(code)
|
| 268 |
+
const close =
|
| 269 |
+
!before ||
|
| 270 |
+
(before === constants.characterGroupPunctuation && after) ||
|
| 271 |
+
attentionMarkers.includes(previous)
|
| 272 |
+
|
| 273 |
+
token._open = Boolean(
|
| 274 |
+
marker === codes.asterisk ? open : open && (before || !close)
|
| 275 |
+
)
|
| 276 |
+
token._close = Boolean(
|
| 277 |
+
marker === codes.asterisk ? close : close && (after || !open)
|
| 278 |
+
)
|
| 279 |
+
return ok(code)
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
* Move a point a bit.
|
| 285 |
+
*
|
| 286 |
+
* Note: `move` only works inside lines! It’s not possible to move past other
|
| 287 |
+
* chunks (replacement characters, tabs, or line endings).
|
| 288 |
+
*
|
| 289 |
+
* @param {Point} point
|
| 290 |
+
* Point.
|
| 291 |
+
* @param {number} offset
|
| 292 |
+
* Amount to move.
|
| 293 |
+
* @returns {undefined}
|
| 294 |
+
* Nothing.
|
| 295 |
+
*/
|
| 296 |
+
function movePoint(point, offset) {
|
| 297 |
+
point.column += offset
|
| 298 |
+
point.offset += offset
|
| 299 |
+
point._bufferIndex += offset
|
| 300 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/autolink.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const autolink: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=autolink.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/autolink.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"autolink.d.ts","sourceRoot":"","sources":["autolink.js"],"names":[],"mappings":"AAkBA,wBAAwB;AACxB,uBADW,SAAS,CACkD;+BAb5D,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/autolink.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* State,
|
| 5 |
+
* TokenizeContext,
|
| 6 |
+
* Tokenizer
|
| 7 |
+
* } from 'micromark-util-types'
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import {ok as assert} from 'devlop'
|
| 11 |
+
import {
|
| 12 |
+
asciiAlphanumeric,
|
| 13 |
+
asciiAlpha,
|
| 14 |
+
asciiAtext,
|
| 15 |
+
asciiControl
|
| 16 |
+
} from 'micromark-util-character'
|
| 17 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 18 |
+
|
| 19 |
+
/** @type {Construct} */
|
| 20 |
+
export const autolink = {name: 'autolink', tokenize: tokenizeAutolink}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* @this {TokenizeContext}
|
| 24 |
+
* Context.
|
| 25 |
+
* @type {Tokenizer}
|
| 26 |
+
*/
|
| 27 |
+
function tokenizeAutolink(effects, ok, nok) {
|
| 28 |
+
let size = 0
|
| 29 |
+
|
| 30 |
+
return start
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Start of an autolink.
|
| 34 |
+
*
|
| 35 |
+
* ```markdown
|
| 36 |
+
* > | a<https://example.com>b
|
| 37 |
+
* ^
|
| 38 |
+
* > | a<user@example.com>b
|
| 39 |
+
* ^
|
| 40 |
+
* ```
|
| 41 |
+
*
|
| 42 |
+
* @type {State}
|
| 43 |
+
*/
|
| 44 |
+
function start(code) {
|
| 45 |
+
assert(code === codes.lessThan, 'expected `<`')
|
| 46 |
+
effects.enter(types.autolink)
|
| 47 |
+
effects.enter(types.autolinkMarker)
|
| 48 |
+
effects.consume(code)
|
| 49 |
+
effects.exit(types.autolinkMarker)
|
| 50 |
+
effects.enter(types.autolinkProtocol)
|
| 51 |
+
return open
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* After `<`, at protocol or atext.
|
| 56 |
+
*
|
| 57 |
+
* ```markdown
|
| 58 |
+
* > | a<https://example.com>b
|
| 59 |
+
* ^
|
| 60 |
+
* > | a<user@example.com>b
|
| 61 |
+
* ^
|
| 62 |
+
* ```
|
| 63 |
+
*
|
| 64 |
+
* @type {State}
|
| 65 |
+
*/
|
| 66 |
+
function open(code) {
|
| 67 |
+
if (asciiAlpha(code)) {
|
| 68 |
+
effects.consume(code)
|
| 69 |
+
return schemeOrEmailAtext
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if (code === codes.atSign) {
|
| 73 |
+
return nok(code)
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
return emailAtext(code)
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* At second byte of protocol or atext.
|
| 81 |
+
*
|
| 82 |
+
* ```markdown
|
| 83 |
+
* > | a<https://example.com>b
|
| 84 |
+
* ^
|
| 85 |
+
* > | a<user@example.com>b
|
| 86 |
+
* ^
|
| 87 |
+
* ```
|
| 88 |
+
*
|
| 89 |
+
* @type {State}
|
| 90 |
+
*/
|
| 91 |
+
function schemeOrEmailAtext(code) {
|
| 92 |
+
// ASCII alphanumeric and `+`, `-`, and `.`.
|
| 93 |
+
if (
|
| 94 |
+
code === codes.plusSign ||
|
| 95 |
+
code === codes.dash ||
|
| 96 |
+
code === codes.dot ||
|
| 97 |
+
asciiAlphanumeric(code)
|
| 98 |
+
) {
|
| 99 |
+
// Count the previous alphabetical from `open` too.
|
| 100 |
+
size = 1
|
| 101 |
+
return schemeInsideOrEmailAtext(code)
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
return emailAtext(code)
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* In ambiguous protocol or atext.
|
| 109 |
+
*
|
| 110 |
+
* ```markdown
|
| 111 |
+
* > | a<https://example.com>b
|
| 112 |
+
* ^
|
| 113 |
+
* > | a<user@example.com>b
|
| 114 |
+
* ^
|
| 115 |
+
* ```
|
| 116 |
+
*
|
| 117 |
+
* @type {State}
|
| 118 |
+
*/
|
| 119 |
+
function schemeInsideOrEmailAtext(code) {
|
| 120 |
+
if (code === codes.colon) {
|
| 121 |
+
effects.consume(code)
|
| 122 |
+
size = 0
|
| 123 |
+
return urlInside
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// ASCII alphanumeric and `+`, `-`, and `.`.
|
| 127 |
+
if (
|
| 128 |
+
(code === codes.plusSign ||
|
| 129 |
+
code === codes.dash ||
|
| 130 |
+
code === codes.dot ||
|
| 131 |
+
asciiAlphanumeric(code)) &&
|
| 132 |
+
size++ < constants.autolinkSchemeSizeMax
|
| 133 |
+
) {
|
| 134 |
+
effects.consume(code)
|
| 135 |
+
return schemeInsideOrEmailAtext
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
size = 0
|
| 139 |
+
return emailAtext(code)
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* After protocol, in URL.
|
| 144 |
+
*
|
| 145 |
+
* ```markdown
|
| 146 |
+
* > | a<https://example.com>b
|
| 147 |
+
* ^
|
| 148 |
+
* ```
|
| 149 |
+
*
|
| 150 |
+
* @type {State}
|
| 151 |
+
*/
|
| 152 |
+
function urlInside(code) {
|
| 153 |
+
if (code === codes.greaterThan) {
|
| 154 |
+
effects.exit(types.autolinkProtocol)
|
| 155 |
+
effects.enter(types.autolinkMarker)
|
| 156 |
+
effects.consume(code)
|
| 157 |
+
effects.exit(types.autolinkMarker)
|
| 158 |
+
effects.exit(types.autolink)
|
| 159 |
+
return ok
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// ASCII control, space, or `<`.
|
| 163 |
+
if (
|
| 164 |
+
code === codes.eof ||
|
| 165 |
+
code === codes.space ||
|
| 166 |
+
code === codes.lessThan ||
|
| 167 |
+
asciiControl(code)
|
| 168 |
+
) {
|
| 169 |
+
return nok(code)
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
effects.consume(code)
|
| 173 |
+
return urlInside
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* In email atext.
|
| 178 |
+
*
|
| 179 |
+
* ```markdown
|
| 180 |
+
* > | a<user.name@example.com>b
|
| 181 |
+
* ^
|
| 182 |
+
* ```
|
| 183 |
+
*
|
| 184 |
+
* @type {State}
|
| 185 |
+
*/
|
| 186 |
+
function emailAtext(code) {
|
| 187 |
+
if (code === codes.atSign) {
|
| 188 |
+
effects.consume(code)
|
| 189 |
+
return emailAtSignOrDot
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
if (asciiAtext(code)) {
|
| 193 |
+
effects.consume(code)
|
| 194 |
+
return emailAtext
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
return nok(code)
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* In label, after at-sign or dot.
|
| 202 |
+
*
|
| 203 |
+
* ```markdown
|
| 204 |
+
* > | a<user.name@example.com>b
|
| 205 |
+
* ^ ^
|
| 206 |
+
* ```
|
| 207 |
+
*
|
| 208 |
+
* @type {State}
|
| 209 |
+
*/
|
| 210 |
+
function emailAtSignOrDot(code) {
|
| 211 |
+
return asciiAlphanumeric(code) ? emailLabel(code) : nok(code)
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* In label, where `.` and `>` are allowed.
|
| 216 |
+
*
|
| 217 |
+
* ```markdown
|
| 218 |
+
* > | a<user.name@example.com>b
|
| 219 |
+
* ^
|
| 220 |
+
* ```
|
| 221 |
+
*
|
| 222 |
+
* @type {State}
|
| 223 |
+
*/
|
| 224 |
+
function emailLabel(code) {
|
| 225 |
+
if (code === codes.dot) {
|
| 226 |
+
effects.consume(code)
|
| 227 |
+
size = 0
|
| 228 |
+
return emailAtSignOrDot
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
if (code === codes.greaterThan) {
|
| 232 |
+
// Exit, then change the token type.
|
| 233 |
+
effects.exit(types.autolinkProtocol).type = types.autolinkEmail
|
| 234 |
+
effects.enter(types.autolinkMarker)
|
| 235 |
+
effects.consume(code)
|
| 236 |
+
effects.exit(types.autolinkMarker)
|
| 237 |
+
effects.exit(types.autolink)
|
| 238 |
+
return ok
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
return emailValue(code)
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* In label, where `.` and `>` are *not* allowed.
|
| 246 |
+
*
|
| 247 |
+
* Though, this is also used in `emailLabel` to parse other values.
|
| 248 |
+
*
|
| 249 |
+
* ```markdown
|
| 250 |
+
* > | a<user.name@ex-ample.com>b
|
| 251 |
+
* ^
|
| 252 |
+
* ```
|
| 253 |
+
*
|
| 254 |
+
* @type {State}
|
| 255 |
+
*/
|
| 256 |
+
function emailValue(code) {
|
| 257 |
+
// ASCII alphanumeric or `-`.
|
| 258 |
+
if (
|
| 259 |
+
(code === codes.dash || asciiAlphanumeric(code)) &&
|
| 260 |
+
size++ < constants.autolinkDomainSizeMax
|
| 261 |
+
) {
|
| 262 |
+
const next = code === codes.dash ? emailValue : emailLabel
|
| 263 |
+
effects.consume(code)
|
| 264 |
+
return next
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
return nok(code)
|
| 268 |
+
}
|
| 269 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/blank-line.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const blankLine: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=blank-line.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/blank-line.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"blank-line.d.ts","sourceRoot":"","sources":["blank-line.js"],"names":[],"mappings":"AAaA,wBAAwB;AACxB,wBADW,SAAS,CACiD;+BAR3D,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/blank-line.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* State,
|
| 5 |
+
* TokenizeContext,
|
| 6 |
+
* Tokenizer
|
| 7 |
+
* } from 'micromark-util-types'
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 11 |
+
import {markdownLineEnding, markdownSpace} from 'micromark-util-character'
|
| 12 |
+
import {codes, types} from 'micromark-util-symbol'
|
| 13 |
+
|
| 14 |
+
/** @type {Construct} */
|
| 15 |
+
export const blankLine = {partial: true, tokenize: tokenizeBlankLine}
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @this {TokenizeContext}
|
| 19 |
+
* Context.
|
| 20 |
+
* @type {Tokenizer}
|
| 21 |
+
*/
|
| 22 |
+
function tokenizeBlankLine(effects, ok, nok) {
|
| 23 |
+
return start
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Start of blank line.
|
| 27 |
+
*
|
| 28 |
+
* > 👉 **Note**: `␠` represents a space character.
|
| 29 |
+
*
|
| 30 |
+
* ```markdown
|
| 31 |
+
* > | ␠␠␊
|
| 32 |
+
* ^
|
| 33 |
+
* > | ␊
|
| 34 |
+
* ^
|
| 35 |
+
* ```
|
| 36 |
+
*
|
| 37 |
+
* @type {State}
|
| 38 |
+
*/
|
| 39 |
+
function start(code) {
|
| 40 |
+
return markdownSpace(code)
|
| 41 |
+
? factorySpace(effects, after, types.linePrefix)(code)
|
| 42 |
+
: after(code)
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* At eof/eol, after optional whitespace.
|
| 47 |
+
*
|
| 48 |
+
* > 👉 **Note**: `␠` represents a space character.
|
| 49 |
+
*
|
| 50 |
+
* ```markdown
|
| 51 |
+
* > | ␠␠␊
|
| 52 |
+
* ^
|
| 53 |
+
* > | ␊
|
| 54 |
+
* ^
|
| 55 |
+
* ```
|
| 56 |
+
*
|
| 57 |
+
* @type {State}
|
| 58 |
+
*/
|
| 59 |
+
function after(code) {
|
| 60 |
+
return code === codes.eof || markdownLineEnding(code) ? ok(code) : nok(code)
|
| 61 |
+
}
|
| 62 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/block-quote.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const blockQuote: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=block-quote.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/block-quote.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"block-quote.d.ts","sourceRoot":"","sources":["block-quote.js"],"names":[],"mappings":"AAeA,wBAAwB;AACxB,yBADW,SAAS,CAMnB;+BAdS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/block-quote.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* Exiter,
|
| 5 |
+
* State,
|
| 6 |
+
* TokenizeContext,
|
| 7 |
+
* Tokenizer
|
| 8 |
+
* } from 'micromark-util-types'
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
import {ok as assert} from 'devlop'
|
| 12 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 13 |
+
import {markdownSpace} from 'micromark-util-character'
|
| 14 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 15 |
+
|
| 16 |
+
/** @type {Construct} */
|
| 17 |
+
export const blockQuote = {
|
| 18 |
+
continuation: {tokenize: tokenizeBlockQuoteContinuation},
|
| 19 |
+
exit,
|
| 20 |
+
name: 'blockQuote',
|
| 21 |
+
tokenize: tokenizeBlockQuoteStart
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @this {TokenizeContext}
|
| 26 |
+
* Context.
|
| 27 |
+
* @type {Tokenizer}
|
| 28 |
+
*/
|
| 29 |
+
function tokenizeBlockQuoteStart(effects, ok, nok) {
|
| 30 |
+
const self = this
|
| 31 |
+
|
| 32 |
+
return start
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Start of block quote.
|
| 36 |
+
*
|
| 37 |
+
* ```markdown
|
| 38 |
+
* > | > a
|
| 39 |
+
* ^
|
| 40 |
+
* ```
|
| 41 |
+
*
|
| 42 |
+
* @type {State}
|
| 43 |
+
*/
|
| 44 |
+
function start(code) {
|
| 45 |
+
if (code === codes.greaterThan) {
|
| 46 |
+
const state = self.containerState
|
| 47 |
+
|
| 48 |
+
assert(state, 'expected `containerState` to be defined in container')
|
| 49 |
+
|
| 50 |
+
if (!state.open) {
|
| 51 |
+
effects.enter(types.blockQuote, {_container: true})
|
| 52 |
+
state.open = true
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
effects.enter(types.blockQuotePrefix)
|
| 56 |
+
effects.enter(types.blockQuoteMarker)
|
| 57 |
+
effects.consume(code)
|
| 58 |
+
effects.exit(types.blockQuoteMarker)
|
| 59 |
+
return after
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return nok(code)
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* After `>`, before optional whitespace.
|
| 67 |
+
*
|
| 68 |
+
* ```markdown
|
| 69 |
+
* > | > a
|
| 70 |
+
* ^
|
| 71 |
+
* ```
|
| 72 |
+
*
|
| 73 |
+
* @type {State}
|
| 74 |
+
*/
|
| 75 |
+
function after(code) {
|
| 76 |
+
if (markdownSpace(code)) {
|
| 77 |
+
effects.enter(types.blockQuotePrefixWhitespace)
|
| 78 |
+
effects.consume(code)
|
| 79 |
+
effects.exit(types.blockQuotePrefixWhitespace)
|
| 80 |
+
effects.exit(types.blockQuotePrefix)
|
| 81 |
+
return ok
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
effects.exit(types.blockQuotePrefix)
|
| 85 |
+
return ok(code)
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Start of block quote continuation.
|
| 91 |
+
*
|
| 92 |
+
* ```markdown
|
| 93 |
+
* | > a
|
| 94 |
+
* > | > b
|
| 95 |
+
* ^
|
| 96 |
+
* ```
|
| 97 |
+
*
|
| 98 |
+
* @this {TokenizeContext}
|
| 99 |
+
* Context.
|
| 100 |
+
* @type {Tokenizer}
|
| 101 |
+
*/
|
| 102 |
+
function tokenizeBlockQuoteContinuation(effects, ok, nok) {
|
| 103 |
+
const self = this
|
| 104 |
+
|
| 105 |
+
return contStart
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Start of block quote continuation.
|
| 109 |
+
*
|
| 110 |
+
* Also used to parse the first block quote opening.
|
| 111 |
+
*
|
| 112 |
+
* ```markdown
|
| 113 |
+
* | > a
|
| 114 |
+
* > | > b
|
| 115 |
+
* ^
|
| 116 |
+
* ```
|
| 117 |
+
*
|
| 118 |
+
* @type {State}
|
| 119 |
+
*/
|
| 120 |
+
function contStart(code) {
|
| 121 |
+
if (markdownSpace(code)) {
|
| 122 |
+
// Always populated by defaults.
|
| 123 |
+
assert(
|
| 124 |
+
self.parser.constructs.disable.null,
|
| 125 |
+
'expected `disable.null` to be populated'
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
return factorySpace(
|
| 129 |
+
effects,
|
| 130 |
+
contBefore,
|
| 131 |
+
types.linePrefix,
|
| 132 |
+
self.parser.constructs.disable.null.includes('codeIndented')
|
| 133 |
+
? undefined
|
| 134 |
+
: constants.tabSize
|
| 135 |
+
)(code)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
return contBefore(code)
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* At `>`, after optional whitespace.
|
| 143 |
+
*
|
| 144 |
+
* Also used to parse the first block quote opening.
|
| 145 |
+
*
|
| 146 |
+
* ```markdown
|
| 147 |
+
* | > a
|
| 148 |
+
* > | > b
|
| 149 |
+
* ^
|
| 150 |
+
* ```
|
| 151 |
+
*
|
| 152 |
+
* @type {State}
|
| 153 |
+
*/
|
| 154 |
+
function contBefore(code) {
|
| 155 |
+
return effects.attempt(blockQuote, ok, nok)(code)
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/** @type {Exiter} */
|
| 160 |
+
function exit(effects) {
|
| 161 |
+
effects.exit(types.blockQuote)
|
| 162 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/character-escape.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const characterEscape: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=character-escape.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/character-escape.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"character-escape.d.ts","sourceRoot":"","sources":["character-escape.js"],"names":[],"mappings":"AAaA,wBAAwB;AACxB,8BADW,SAAS,CAInB;+BAXS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/character-escape.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* State,
|
| 5 |
+
* TokenizeContext,
|
| 6 |
+
* Tokenizer
|
| 7 |
+
* } from 'micromark-util-types'
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import {ok as assert} from 'devlop'
|
| 11 |
+
import {asciiPunctuation} from 'micromark-util-character'
|
| 12 |
+
import {codes, types} from 'micromark-util-symbol'
|
| 13 |
+
|
| 14 |
+
/** @type {Construct} */
|
| 15 |
+
export const characterEscape = {
|
| 16 |
+
name: 'characterEscape',
|
| 17 |
+
tokenize: tokenizeCharacterEscape
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* @this {TokenizeContext}
|
| 22 |
+
* Context.
|
| 23 |
+
* @type {Tokenizer}
|
| 24 |
+
*/
|
| 25 |
+
function tokenizeCharacterEscape(effects, ok, nok) {
|
| 26 |
+
return start
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Start of character escape.
|
| 30 |
+
*
|
| 31 |
+
* ```markdown
|
| 32 |
+
* > | a\*b
|
| 33 |
+
* ^
|
| 34 |
+
* ```
|
| 35 |
+
*
|
| 36 |
+
* @type {State}
|
| 37 |
+
*/
|
| 38 |
+
function start(code) {
|
| 39 |
+
assert(code === codes.backslash, 'expected `\\`')
|
| 40 |
+
effects.enter(types.characterEscape)
|
| 41 |
+
effects.enter(types.escapeMarker)
|
| 42 |
+
effects.consume(code)
|
| 43 |
+
effects.exit(types.escapeMarker)
|
| 44 |
+
return inside
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* After `\`, at punctuation.
|
| 49 |
+
*
|
| 50 |
+
* ```markdown
|
| 51 |
+
* > | a\*b
|
| 52 |
+
* ^
|
| 53 |
+
* ```
|
| 54 |
+
*
|
| 55 |
+
* @type {State}
|
| 56 |
+
*/
|
| 57 |
+
function inside(code) {
|
| 58 |
+
// ASCII punctuation.
|
| 59 |
+
if (asciiPunctuation(code)) {
|
| 60 |
+
effects.enter(types.characterEscapeValue)
|
| 61 |
+
effects.consume(code)
|
| 62 |
+
effects.exit(types.characterEscapeValue)
|
| 63 |
+
effects.exit(types.characterEscape)
|
| 64 |
+
return ok
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
return nok(code)
|
| 68 |
+
}
|
| 69 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/character-reference.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const characterReference: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=character-reference.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/character-reference.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"character-reference.d.ts","sourceRoot":"","sources":["character-reference.js"],"names":[],"mappings":"AAmBA,wBAAwB;AACxB,iCADW,SAAS,CAInB;+BAhBS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/character-reference.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Code,
|
| 4 |
+
* Construct,
|
| 5 |
+
* State,
|
| 6 |
+
* TokenizeContext,
|
| 7 |
+
* Tokenizer
|
| 8 |
+
* } from 'micromark-util-types'
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
import {ok as assert} from 'devlop'
|
| 12 |
+
import {decodeNamedCharacterReference} from 'decode-named-character-reference'
|
| 13 |
+
import {
|
| 14 |
+
asciiAlphanumeric,
|
| 15 |
+
asciiDigit,
|
| 16 |
+
asciiHexDigit
|
| 17 |
+
} from 'micromark-util-character'
|
| 18 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 19 |
+
|
| 20 |
+
/** @type {Construct} */
|
| 21 |
+
export const characterReference = {
|
| 22 |
+
name: 'characterReference',
|
| 23 |
+
tokenize: tokenizeCharacterReference
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @this {TokenizeContext}
|
| 28 |
+
* Context.
|
| 29 |
+
* @type {Tokenizer}
|
| 30 |
+
*/
|
| 31 |
+
function tokenizeCharacterReference(effects, ok, nok) {
|
| 32 |
+
const self = this
|
| 33 |
+
let size = 0
|
| 34 |
+
/** @type {number} */
|
| 35 |
+
let max
|
| 36 |
+
/** @type {(code: Code) => boolean} */
|
| 37 |
+
let test
|
| 38 |
+
|
| 39 |
+
return start
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Start of character reference.
|
| 43 |
+
*
|
| 44 |
+
* ```markdown
|
| 45 |
+
* > | a&b
|
| 46 |
+
* ^
|
| 47 |
+
* > | a{b
|
| 48 |
+
* ^
|
| 49 |
+
* > | a	b
|
| 50 |
+
* ^
|
| 51 |
+
* ```
|
| 52 |
+
*
|
| 53 |
+
* @type {State}
|
| 54 |
+
*/
|
| 55 |
+
function start(code) {
|
| 56 |
+
assert(code === codes.ampersand, 'expected `&`')
|
| 57 |
+
effects.enter(types.characterReference)
|
| 58 |
+
effects.enter(types.characterReferenceMarker)
|
| 59 |
+
effects.consume(code)
|
| 60 |
+
effects.exit(types.characterReferenceMarker)
|
| 61 |
+
return open
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* After `&`, at `#` for numeric references or alphanumeric for named
|
| 66 |
+
* references.
|
| 67 |
+
*
|
| 68 |
+
* ```markdown
|
| 69 |
+
* > | a&b
|
| 70 |
+
* ^
|
| 71 |
+
* > | a{b
|
| 72 |
+
* ^
|
| 73 |
+
* > | a	b
|
| 74 |
+
* ^
|
| 75 |
+
* ```
|
| 76 |
+
*
|
| 77 |
+
* @type {State}
|
| 78 |
+
*/
|
| 79 |
+
function open(code) {
|
| 80 |
+
if (code === codes.numberSign) {
|
| 81 |
+
effects.enter(types.characterReferenceMarkerNumeric)
|
| 82 |
+
effects.consume(code)
|
| 83 |
+
effects.exit(types.characterReferenceMarkerNumeric)
|
| 84 |
+
return numeric
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
effects.enter(types.characterReferenceValue)
|
| 88 |
+
max = constants.characterReferenceNamedSizeMax
|
| 89 |
+
test = asciiAlphanumeric
|
| 90 |
+
return value(code)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* After `#`, at `x` for hexadecimals or digit for decimals.
|
| 95 |
+
*
|
| 96 |
+
* ```markdown
|
| 97 |
+
* > | a{b
|
| 98 |
+
* ^
|
| 99 |
+
* > | a	b
|
| 100 |
+
* ^
|
| 101 |
+
* ```
|
| 102 |
+
*
|
| 103 |
+
* @type {State}
|
| 104 |
+
*/
|
| 105 |
+
function numeric(code) {
|
| 106 |
+
if (code === codes.uppercaseX || code === codes.lowercaseX) {
|
| 107 |
+
effects.enter(types.characterReferenceMarkerHexadecimal)
|
| 108 |
+
effects.consume(code)
|
| 109 |
+
effects.exit(types.characterReferenceMarkerHexadecimal)
|
| 110 |
+
effects.enter(types.characterReferenceValue)
|
| 111 |
+
max = constants.characterReferenceHexadecimalSizeMax
|
| 112 |
+
test = asciiHexDigit
|
| 113 |
+
return value
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
effects.enter(types.characterReferenceValue)
|
| 117 |
+
max = constants.characterReferenceDecimalSizeMax
|
| 118 |
+
test = asciiDigit
|
| 119 |
+
return value(code)
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* After markers (`&#x`, `&#`, or `&`), in value, before `;`.
|
| 124 |
+
*
|
| 125 |
+
* The character reference kind defines what and how many characters are
|
| 126 |
+
* allowed.
|
| 127 |
+
*
|
| 128 |
+
* ```markdown
|
| 129 |
+
* > | a&b
|
| 130 |
+
* ^^^
|
| 131 |
+
* > | a{b
|
| 132 |
+
* ^^^
|
| 133 |
+
* > | a	b
|
| 134 |
+
* ^
|
| 135 |
+
* ```
|
| 136 |
+
*
|
| 137 |
+
* @type {State}
|
| 138 |
+
*/
|
| 139 |
+
function value(code) {
|
| 140 |
+
if (code === codes.semicolon && size) {
|
| 141 |
+
const token = effects.exit(types.characterReferenceValue)
|
| 142 |
+
|
| 143 |
+
if (
|
| 144 |
+
test === asciiAlphanumeric &&
|
| 145 |
+
!decodeNamedCharacterReference(self.sliceSerialize(token))
|
| 146 |
+
) {
|
| 147 |
+
return nok(code)
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
// To do: `markdown-rs` uses a different name:
|
| 151 |
+
// `CharacterReferenceMarkerSemi`.
|
| 152 |
+
effects.enter(types.characterReferenceMarker)
|
| 153 |
+
effects.consume(code)
|
| 154 |
+
effects.exit(types.characterReferenceMarker)
|
| 155 |
+
effects.exit(types.characterReference)
|
| 156 |
+
return ok
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
if (test(code) && size++ < max) {
|
| 160 |
+
effects.consume(code)
|
| 161 |
+
return value
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
return nok(code)
|
| 165 |
+
}
|
| 166 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const codeFenced: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=code-fenced.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"code-fenced.d.ts","sourceRoot":"","sources":["code-fenced.js"],"names":[],"mappings":"AAqBA,wBAAwB;AACxB,yBADW,SAAS,CAKnB;+BAnBS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/code-fenced.js
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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devlop'
|
| 12 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 13 |
+
import {markdownLineEnding, markdownSpace} from 'micromark-util-character'
|
| 14 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 15 |
+
|
| 16 |
+
/** @type {Construct} */
|
| 17 |
+
const nonLazyContinuation = {
|
| 18 |
+
partial: true,
|
| 19 |
+
tokenize: tokenizeNonLazyContinuation
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/** @type {Construct} */
|
| 23 |
+
export const codeFenced = {
|
| 24 |
+
concrete: true,
|
| 25 |
+
name: 'codeFenced',
|
| 26 |
+
tokenize: tokenizeCodeFenced
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @this {TokenizeContext}
|
| 31 |
+
* Context.
|
| 32 |
+
* @type {Tokenizer}
|
| 33 |
+
*/
|
| 34 |
+
function tokenizeCodeFenced(effects, ok, nok) {
|
| 35 |
+
const self = this
|
| 36 |
+
/** @type {Construct} */
|
| 37 |
+
const closeStart = {partial: true, tokenize: tokenizeCloseStart}
|
| 38 |
+
let initialPrefix = 0
|
| 39 |
+
let sizeOpen = 0
|
| 40 |
+
/** @type {NonNullable<Code>} */
|
| 41 |
+
let marker
|
| 42 |
+
|
| 43 |
+
return start
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Start of code.
|
| 47 |
+
*
|
| 48 |
+
* ```markdown
|
| 49 |
+
* > | ~~~js
|
| 50 |
+
* ^
|
| 51 |
+
* | alert(1)
|
| 52 |
+
* | ~~~
|
| 53 |
+
* ```
|
| 54 |
+
*
|
| 55 |
+
* @type {State}
|
| 56 |
+
*/
|
| 57 |
+
function start(code) {
|
| 58 |
+
// To do: parse whitespace like `markdown-rs`.
|
| 59 |
+
return beforeSequenceOpen(code)
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* In opening fence, after prefix, at sequence.
|
| 64 |
+
*
|
| 65 |
+
* ```markdown
|
| 66 |
+
* > | ~~~js
|
| 67 |
+
* ^
|
| 68 |
+
* | alert(1)
|
| 69 |
+
* | ~~~
|
| 70 |
+
* ```
|
| 71 |
+
*
|
| 72 |
+
* @type {State}
|
| 73 |
+
*/
|
| 74 |
+
function beforeSequenceOpen(code) {
|
| 75 |
+
assert(
|
| 76 |
+
code === codes.graveAccent || code === codes.tilde,
|
| 77 |
+
'expected `` ` `` or `~`'
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
const tail = self.events[self.events.length - 1]
|
| 81 |
+
initialPrefix =
|
| 82 |
+
tail && tail[1].type === types.linePrefix
|
| 83 |
+
? tail[2].sliceSerialize(tail[1], true).length
|
| 84 |
+
: 0
|
| 85 |
+
|
| 86 |
+
marker = code
|
| 87 |
+
effects.enter(types.codeFenced)
|
| 88 |
+
effects.enter(types.codeFencedFence)
|
| 89 |
+
effects.enter(types.codeFencedFenceSequence)
|
| 90 |
+
return sequenceOpen(code)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* In opening fence sequence.
|
| 95 |
+
*
|
| 96 |
+
* ```markdown
|
| 97 |
+
* > | ~~~js
|
| 98 |
+
* ^
|
| 99 |
+
* | alert(1)
|
| 100 |
+
* | ~~~
|
| 101 |
+
* ```
|
| 102 |
+
*
|
| 103 |
+
* @type {State}
|
| 104 |
+
*/
|
| 105 |
+
function sequenceOpen(code) {
|
| 106 |
+
if (code === marker) {
|
| 107 |
+
sizeOpen++
|
| 108 |
+
effects.consume(code)
|
| 109 |
+
return sequenceOpen
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if (sizeOpen < constants.codeFencedSequenceSizeMin) {
|
| 113 |
+
return nok(code)
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
effects.exit(types.codeFencedFenceSequence)
|
| 117 |
+
return markdownSpace(code)
|
| 118 |
+
? factorySpace(effects, infoBefore, types.whitespace)(code)
|
| 119 |
+
: infoBefore(code)
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* In opening fence, after the sequence (and optional whitespace), before info.
|
| 124 |
+
*
|
| 125 |
+
* ```markdown
|
| 126 |
+
* > | ~~~js
|
| 127 |
+
* ^
|
| 128 |
+
* | alert(1)
|
| 129 |
+
* | ~~~
|
| 130 |
+
* ```
|
| 131 |
+
*
|
| 132 |
+
* @type {State}
|
| 133 |
+
*/
|
| 134 |
+
function infoBefore(code) {
|
| 135 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 136 |
+
effects.exit(types.codeFencedFence)
|
| 137 |
+
return self.interrupt
|
| 138 |
+
? ok(code)
|
| 139 |
+
: effects.check(nonLazyContinuation, atNonLazyBreak, after)(code)
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
effects.enter(types.codeFencedFenceInfo)
|
| 143 |
+
effects.enter(types.chunkString, {contentType: constants.contentTypeString})
|
| 144 |
+
return info(code)
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* In info.
|
| 149 |
+
*
|
| 150 |
+
* ```markdown
|
| 151 |
+
* > | ~~~js
|
| 152 |
+
* ^
|
| 153 |
+
* | alert(1)
|
| 154 |
+
* | ~~~
|
| 155 |
+
* ```
|
| 156 |
+
*
|
| 157 |
+
* @type {State}
|
| 158 |
+
*/
|
| 159 |
+
function info(code) {
|
| 160 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 161 |
+
effects.exit(types.chunkString)
|
| 162 |
+
effects.exit(types.codeFencedFenceInfo)
|
| 163 |
+
return infoBefore(code)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
if (markdownSpace(code)) {
|
| 167 |
+
effects.exit(types.chunkString)
|
| 168 |
+
effects.exit(types.codeFencedFenceInfo)
|
| 169 |
+
return factorySpace(effects, metaBefore, types.whitespace)(code)
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
if (code === codes.graveAccent && code === marker) {
|
| 173 |
+
return nok(code)
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
effects.consume(code)
|
| 177 |
+
return info
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* In opening fence, after info and whitespace, before meta.
|
| 182 |
+
*
|
| 183 |
+
* ```markdown
|
| 184 |
+
* > | ~~~js eval
|
| 185 |
+
* ^
|
| 186 |
+
* | alert(1)
|
| 187 |
+
* | ~~~
|
| 188 |
+
* ```
|
| 189 |
+
*
|
| 190 |
+
* @type {State}
|
| 191 |
+
*/
|
| 192 |
+
function metaBefore(code) {
|
| 193 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 194 |
+
return infoBefore(code)
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
effects.enter(types.codeFencedFenceMeta)
|
| 198 |
+
effects.enter(types.chunkString, {contentType: constants.contentTypeString})
|
| 199 |
+
return meta(code)
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/**
|
| 203 |
+
* In meta.
|
| 204 |
+
*
|
| 205 |
+
* ```markdown
|
| 206 |
+
* > | ~~~js eval
|
| 207 |
+
* ^
|
| 208 |
+
* | alert(1)
|
| 209 |
+
* | ~~~
|
| 210 |
+
* ```
|
| 211 |
+
*
|
| 212 |
+
* @type {State}
|
| 213 |
+
*/
|
| 214 |
+
function meta(code) {
|
| 215 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 216 |
+
effects.exit(types.chunkString)
|
| 217 |
+
effects.exit(types.codeFencedFenceMeta)
|
| 218 |
+
return infoBefore(code)
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
if (code === codes.graveAccent && code === marker) {
|
| 222 |
+
return nok(code)
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
effects.consume(code)
|
| 226 |
+
return meta
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* At eol/eof in code, before a non-lazy closing fence or content.
|
| 231 |
+
*
|
| 232 |
+
* ```markdown
|
| 233 |
+
* > | ~~~js
|
| 234 |
+
* ^
|
| 235 |
+
* > | alert(1)
|
| 236 |
+
* ^
|
| 237 |
+
* | ~~~
|
| 238 |
+
* ```
|
| 239 |
+
*
|
| 240 |
+
* @type {State}
|
| 241 |
+
*/
|
| 242 |
+
function atNonLazyBreak(code) {
|
| 243 |
+
assert(markdownLineEnding(code), 'expected eol')
|
| 244 |
+
return effects.attempt(closeStart, after, contentBefore)(code)
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
* Before code content, not a closing fence, at eol.
|
| 249 |
+
*
|
| 250 |
+
* ```markdown
|
| 251 |
+
* | ~~~js
|
| 252 |
+
* > | alert(1)
|
| 253 |
+
* ^
|
| 254 |
+
* | ~~~
|
| 255 |
+
* ```
|
| 256 |
+
*
|
| 257 |
+
* @type {State}
|
| 258 |
+
*/
|
| 259 |
+
function contentBefore(code) {
|
| 260 |
+
assert(markdownLineEnding(code), 'expected eol')
|
| 261 |
+
effects.enter(types.lineEnding)
|
| 262 |
+
effects.consume(code)
|
| 263 |
+
effects.exit(types.lineEnding)
|
| 264 |
+
return contentStart
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/**
|
| 268 |
+
* Before code content, not a closing fence.
|
| 269 |
+
*
|
| 270 |
+
* ```markdown
|
| 271 |
+
* | ~~~js
|
| 272 |
+
* > | alert(1)
|
| 273 |
+
* ^
|
| 274 |
+
* | ~~~
|
| 275 |
+
* ```
|
| 276 |
+
*
|
| 277 |
+
* @type {State}
|
| 278 |
+
*/
|
| 279 |
+
function contentStart(code) {
|
| 280 |
+
return initialPrefix > 0 && markdownSpace(code)
|
| 281 |
+
? factorySpace(
|
| 282 |
+
effects,
|
| 283 |
+
beforeContentChunk,
|
| 284 |
+
types.linePrefix,
|
| 285 |
+
initialPrefix + 1
|
| 286 |
+
)(code)
|
| 287 |
+
: beforeContentChunk(code)
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
/**
|
| 291 |
+
* Before code content, after optional prefix.
|
| 292 |
+
*
|
| 293 |
+
* ```markdown
|
| 294 |
+
* | ~~~js
|
| 295 |
+
* > | alert(1)
|
| 296 |
+
* ^
|
| 297 |
+
* | ~~~
|
| 298 |
+
* ```
|
| 299 |
+
*
|
| 300 |
+
* @type {State}
|
| 301 |
+
*/
|
| 302 |
+
function beforeContentChunk(code) {
|
| 303 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 304 |
+
return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code)
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
effects.enter(types.codeFlowValue)
|
| 308 |
+
return contentChunk(code)
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
/**
|
| 312 |
+
* In code content.
|
| 313 |
+
*
|
| 314 |
+
* ```markdown
|
| 315 |
+
* | ~~~js
|
| 316 |
+
* > | alert(1)
|
| 317 |
+
* ^^^^^^^^
|
| 318 |
+
* | ~~~
|
| 319 |
+
* ```
|
| 320 |
+
*
|
| 321 |
+
* @type {State}
|
| 322 |
+
*/
|
| 323 |
+
function contentChunk(code) {
|
| 324 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 325 |
+
effects.exit(types.codeFlowValue)
|
| 326 |
+
return beforeContentChunk(code)
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
effects.consume(code)
|
| 330 |
+
return contentChunk
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
/**
|
| 334 |
+
* After code.
|
| 335 |
+
*
|
| 336 |
+
* ```markdown
|
| 337 |
+
* | ~~~js
|
| 338 |
+
* | alert(1)
|
| 339 |
+
* > | ~~~
|
| 340 |
+
* ^
|
| 341 |
+
* ```
|
| 342 |
+
*
|
| 343 |
+
* @type {State}
|
| 344 |
+
*/
|
| 345 |
+
function after(code) {
|
| 346 |
+
effects.exit(types.codeFenced)
|
| 347 |
+
return ok(code)
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
/**
|
| 351 |
+
* @this {TokenizeContext}
|
| 352 |
+
* Context.
|
| 353 |
+
* @type {Tokenizer}
|
| 354 |
+
*/
|
| 355 |
+
function tokenizeCloseStart(effects, ok, nok) {
|
| 356 |
+
let size = 0
|
| 357 |
+
|
| 358 |
+
return startBefore
|
| 359 |
+
|
| 360 |
+
/**
|
| 361 |
+
*
|
| 362 |
+
*
|
| 363 |
+
* @type {State}
|
| 364 |
+
*/
|
| 365 |
+
function startBefore(code) {
|
| 366 |
+
assert(markdownLineEnding(code), 'expected eol')
|
| 367 |
+
effects.enter(types.lineEnding)
|
| 368 |
+
effects.consume(code)
|
| 369 |
+
effects.exit(types.lineEnding)
|
| 370 |
+
return start
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
/**
|
| 374 |
+
* Before closing fence, at optional whitespace.
|
| 375 |
+
*
|
| 376 |
+
* ```markdown
|
| 377 |
+
* | ~~~js
|
| 378 |
+
* | alert(1)
|
| 379 |
+
* > | ~~~
|
| 380 |
+
* ^
|
| 381 |
+
* ```
|
| 382 |
+
*
|
| 383 |
+
* @type {State}
|
| 384 |
+
*/
|
| 385 |
+
function start(code) {
|
| 386 |
+
// Always populated by defaults.
|
| 387 |
+
assert(
|
| 388 |
+
self.parser.constructs.disable.null,
|
| 389 |
+
'expected `disable.null` to be populated'
|
| 390 |
+
)
|
| 391 |
+
|
| 392 |
+
// To do: `enter` here or in next state?
|
| 393 |
+
effects.enter(types.codeFencedFence)
|
| 394 |
+
return markdownSpace(code)
|
| 395 |
+
? factorySpace(
|
| 396 |
+
effects,
|
| 397 |
+
beforeSequenceClose,
|
| 398 |
+
types.linePrefix,
|
| 399 |
+
self.parser.constructs.disable.null.includes('codeIndented')
|
| 400 |
+
? undefined
|
| 401 |
+
: constants.tabSize
|
| 402 |
+
)(code)
|
| 403 |
+
: beforeSequenceClose(code)
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
/**
|
| 407 |
+
* In closing fence, after optional whitespace, at sequence.
|
| 408 |
+
*
|
| 409 |
+
* ```markdown
|
| 410 |
+
* | ~~~js
|
| 411 |
+
* | alert(1)
|
| 412 |
+
* > | ~~~
|
| 413 |
+
* ^
|
| 414 |
+
* ```
|
| 415 |
+
*
|
| 416 |
+
* @type {State}
|
| 417 |
+
*/
|
| 418 |
+
function beforeSequenceClose(code) {
|
| 419 |
+
if (code === marker) {
|
| 420 |
+
effects.enter(types.codeFencedFenceSequence)
|
| 421 |
+
return sequenceClose(code)
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
return nok(code)
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
/**
|
| 428 |
+
* In closing fence sequence.
|
| 429 |
+
*
|
| 430 |
+
* ```markdown
|
| 431 |
+
* | ~~~js
|
| 432 |
+
* | alert(1)
|
| 433 |
+
* > | ~~~
|
| 434 |
+
* ^
|
| 435 |
+
* ```
|
| 436 |
+
*
|
| 437 |
+
* @type {State}
|
| 438 |
+
*/
|
| 439 |
+
function sequenceClose(code) {
|
| 440 |
+
if (code === marker) {
|
| 441 |
+
size++
|
| 442 |
+
effects.consume(code)
|
| 443 |
+
return sequenceClose
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
if (size >= sizeOpen) {
|
| 447 |
+
effects.exit(types.codeFencedFenceSequence)
|
| 448 |
+
return markdownSpace(code)
|
| 449 |
+
? factorySpace(effects, sequenceCloseAfter, types.whitespace)(code)
|
| 450 |
+
: sequenceCloseAfter(code)
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
return nok(code)
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
/**
|
| 457 |
+
* After closing fence sequence, after optional whitespace.
|
| 458 |
+
*
|
| 459 |
+
* ```markdown
|
| 460 |
+
* | ~~~js
|
| 461 |
+
* | alert(1)
|
| 462 |
+
* > | ~~~
|
| 463 |
+
* ^
|
| 464 |
+
* ```
|
| 465 |
+
*
|
| 466 |
+
* @type {State}
|
| 467 |
+
*/
|
| 468 |
+
function sequenceCloseAfter(code) {
|
| 469 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 470 |
+
effects.exit(types.codeFencedFence)
|
| 471 |
+
return ok(code)
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
return nok(code)
|
| 475 |
+
}
|
| 476 |
+
}
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
/**
|
| 480 |
+
* @this {TokenizeContext}
|
| 481 |
+
* Context.
|
| 482 |
+
* @type {Tokenizer}
|
| 483 |
+
*/
|
| 484 |
+
function tokenizeNonLazyContinuation(effects, ok, nok) {
|
| 485 |
+
const self = this
|
| 486 |
+
|
| 487 |
+
return start
|
| 488 |
+
|
| 489 |
+
/**
|
| 490 |
+
*
|
| 491 |
+
*
|
| 492 |
+
* @type {State}
|
| 493 |
+
*/
|
| 494 |
+
function start(code) {
|
| 495 |
+
if (code === codes.eof) {
|
| 496 |
+
return nok(code)
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
assert(markdownLineEnding(code), 'expected eol')
|
| 500 |
+
effects.enter(types.lineEnding)
|
| 501 |
+
effects.consume(code)
|
| 502 |
+
effects.exit(types.lineEnding)
|
| 503 |
+
return lineStart
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
/**
|
| 507 |
+
*
|
| 508 |
+
*
|
| 509 |
+
* @type {State}
|
| 510 |
+
*/
|
| 511 |
+
function lineStart(code) {
|
| 512 |
+
return self.parser.lazy[self.now().line] ? nok(code) : ok(code)
|
| 513 |
+
}
|
| 514 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/code-indented.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const codeIndented: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=code-indented.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/code-indented.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"code-indented.d.ts","sourceRoot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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* State,
|
| 5 |
+
* TokenizeContext,
|
| 6 |
+
* Tokenizer
|
| 7 |
+
* } from 'micromark-util-types'
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import {ok as assert} from 'devlop'
|
| 11 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 12 |
+
import {markdownLineEnding, markdownSpace} from 'micromark-util-character'
|
| 13 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 14 |
+
|
| 15 |
+
/** @type {Construct} */
|
| 16 |
+
export const codeIndented = {
|
| 17 |
+
name: 'codeIndented',
|
| 18 |
+
tokenize: tokenizeCodeIndented
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/** @type {Construct} */
|
| 22 |
+
const furtherStart = {partial: true, tokenize: tokenizeFurtherStart}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @this {TokenizeContext}
|
| 26 |
+
* Context.
|
| 27 |
+
* @type {Tokenizer}
|
| 28 |
+
*/
|
| 29 |
+
function tokenizeCodeIndented(effects, ok, nok) {
|
| 30 |
+
const self = this
|
| 31 |
+
return start
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Start of code (indented).
|
| 35 |
+
*
|
| 36 |
+
* > **Parsing note**: it is not needed to check if this first line is a
|
| 37 |
+
* > filled line (that it has a non-whitespace character), because blank lines
|
| 38 |
+
* > are parsed already, so we never run into that.
|
| 39 |
+
*
|
| 40 |
+
* ```markdown
|
| 41 |
+
* > | aaa
|
| 42 |
+
* ^
|
| 43 |
+
* ```
|
| 44 |
+
*
|
| 45 |
+
* @type {State}
|
| 46 |
+
*/
|
| 47 |
+
function start(code) {
|
| 48 |
+
// To do: manually check if interrupting like `markdown-rs`.
|
| 49 |
+
assert(markdownSpace(code))
|
| 50 |
+
effects.enter(types.codeIndented)
|
| 51 |
+
// To do: use an improved `space_or_tab` function like `markdown-rs`,
|
| 52 |
+
// so that we can drop the next state.
|
| 53 |
+
return factorySpace(
|
| 54 |
+
effects,
|
| 55 |
+
afterPrefix,
|
| 56 |
+
types.linePrefix,
|
| 57 |
+
constants.tabSize + 1
|
| 58 |
+
)(code)
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* At start, after 1 or 4 spaces.
|
| 63 |
+
*
|
| 64 |
+
* ```markdown
|
| 65 |
+
* > | aaa
|
| 66 |
+
* ^
|
| 67 |
+
* ```
|
| 68 |
+
*
|
| 69 |
+
* @type {State}
|
| 70 |
+
*/
|
| 71 |
+
function afterPrefix(code) {
|
| 72 |
+
const tail = self.events[self.events.length - 1]
|
| 73 |
+
return tail &&
|
| 74 |
+
tail[1].type === types.linePrefix &&
|
| 75 |
+
tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize
|
| 76 |
+
? atBreak(code)
|
| 77 |
+
: nok(code)
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* At a break.
|
| 82 |
+
*
|
| 83 |
+
* ```markdown
|
| 84 |
+
* > | aaa
|
| 85 |
+
* ^ ^
|
| 86 |
+
* ```
|
| 87 |
+
*
|
| 88 |
+
* @type {State}
|
| 89 |
+
*/
|
| 90 |
+
function atBreak(code) {
|
| 91 |
+
if (code === codes.eof) {
|
| 92 |
+
return after(code)
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
if (markdownLineEnding(code)) {
|
| 96 |
+
return effects.attempt(furtherStart, atBreak, after)(code)
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
effects.enter(types.codeFlowValue)
|
| 100 |
+
return inside(code)
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* In code content.
|
| 105 |
+
*
|
| 106 |
+
* ```markdown
|
| 107 |
+
* > | aaa
|
| 108 |
+
* ^^^^
|
| 109 |
+
* ```
|
| 110 |
+
*
|
| 111 |
+
* @type {State}
|
| 112 |
+
*/
|
| 113 |
+
function inside(code) {
|
| 114 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 115 |
+
effects.exit(types.codeFlowValue)
|
| 116 |
+
return atBreak(code)
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
effects.consume(code)
|
| 120 |
+
return inside
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/** @type {State} */
|
| 124 |
+
function after(code) {
|
| 125 |
+
effects.exit(types.codeIndented)
|
| 126 |
+
// To do: allow interrupting like `markdown-rs`.
|
| 127 |
+
// Feel free to interrupt.
|
| 128 |
+
// tokenizer.interrupt = false
|
| 129 |
+
return ok(code)
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* @this {TokenizeContext}
|
| 135 |
+
* Context.
|
| 136 |
+
* @type {Tokenizer}
|
| 137 |
+
*/
|
| 138 |
+
function tokenizeFurtherStart(effects, ok, nok) {
|
| 139 |
+
const self = this
|
| 140 |
+
|
| 141 |
+
return furtherStart
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
* At eol, trying to parse another indent.
|
| 145 |
+
*
|
| 146 |
+
* ```markdown
|
| 147 |
+
* > | aaa
|
| 148 |
+
* ^
|
| 149 |
+
* | bbb
|
| 150 |
+
* ```
|
| 151 |
+
*
|
| 152 |
+
* @type {State}
|
| 153 |
+
*/
|
| 154 |
+
function furtherStart(code) {
|
| 155 |
+
// To do: improve `lazy` / `pierce` handling.
|
| 156 |
+
// If this is a lazy line, it can’t be code.
|
| 157 |
+
if (self.parser.lazy[self.now().line]) {
|
| 158 |
+
return nok(code)
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
if (markdownLineEnding(code)) {
|
| 162 |
+
effects.enter(types.lineEnding)
|
| 163 |
+
effects.consume(code)
|
| 164 |
+
effects.exit(types.lineEnding)
|
| 165 |
+
return furtherStart
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// To do: the code here in `micromark-js` is a bit different from
|
| 169 |
+
// `markdown-rs` because there it can attempt spaces.
|
| 170 |
+
// We can’t yet.
|
| 171 |
+
//
|
| 172 |
+
// To do: use an improved `space_or_tab` function like `markdown-rs`,
|
| 173 |
+
// so that we can drop the next state.
|
| 174 |
+
return factorySpace(
|
| 175 |
+
effects,
|
| 176 |
+
afterPrefix,
|
| 177 |
+
types.linePrefix,
|
| 178 |
+
constants.tabSize + 1
|
| 179 |
+
)(code)
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* At start, after 1 or 4 spaces.
|
| 184 |
+
*
|
| 185 |
+
* ```markdown
|
| 186 |
+
* > | aaa
|
| 187 |
+
* ^
|
| 188 |
+
* ```
|
| 189 |
+
*
|
| 190 |
+
* @type {State}
|
| 191 |
+
*/
|
| 192 |
+
function afterPrefix(code) {
|
| 193 |
+
const tail = self.events[self.events.length - 1]
|
| 194 |
+
return tail &&
|
| 195 |
+
tail[1].type === types.linePrefix &&
|
| 196 |
+
tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize
|
| 197 |
+
? ok(code)
|
| 198 |
+
: markdownLineEnding(code)
|
| 199 |
+
? furtherStart(code)
|
| 200 |
+
: nok(code)
|
| 201 |
+
}
|
| 202 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/code-text.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const codeText: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=code-text.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/code-text.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"code-text.d.ts","sourceRoot":"","sources":["code-text.js"],"names":[],"mappings":"AAgBA,wBAAwB;AACxB,uBADW,SAAS,CAMnB;+BAbS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/code-text.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 'micromark-util-types'
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
import {ok as assert} from 'devlop'
|
| 14 |
+
import {markdownLineEnding} from 'micromark-util-character'
|
| 15 |
+
import {codes, types} from 'micromark-util-symbol'
|
| 16 |
+
|
| 17 |
+
/** @type {Construct} */
|
| 18 |
+
export const codeText = {
|
| 19 |
+
name: 'codeText',
|
| 20 |
+
previous,
|
| 21 |
+
resolve: resolveCodeText,
|
| 22 |
+
tokenize: tokenizeCodeText
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
// To do: next major: don’t resolve, like `markdown-rs`.
|
| 26 |
+
/** @type {Resolver} */
|
| 27 |
+
function resolveCodeText(events) {
|
| 28 |
+
let tailExitIndex = events.length - 4
|
| 29 |
+
let headEnterIndex = 3
|
| 30 |
+
/** @type {number} */
|
| 31 |
+
let index
|
| 32 |
+
/** @type {number | undefined} */
|
| 33 |
+
let enter
|
| 34 |
+
|
| 35 |
+
// If we start and end with an EOL or a space.
|
| 36 |
+
if (
|
| 37 |
+
(events[headEnterIndex][1].type === types.lineEnding ||
|
| 38 |
+
events[headEnterIndex][1].type === 'space') &&
|
| 39 |
+
(events[tailExitIndex][1].type === types.lineEnding ||
|
| 40 |
+
events[tailExitIndex][1].type === 'space')
|
| 41 |
+
) {
|
| 42 |
+
index = headEnterIndex
|
| 43 |
+
|
| 44 |
+
// And we have data.
|
| 45 |
+
while (++index < tailExitIndex) {
|
| 46 |
+
if (events[index][1].type === types.codeTextData) {
|
| 47 |
+
// Then we have padding.
|
| 48 |
+
events[headEnterIndex][1].type = types.codeTextPadding
|
| 49 |
+
events[tailExitIndex][1].type = types.codeTextPadding
|
| 50 |
+
headEnterIndex += 2
|
| 51 |
+
tailExitIndex -= 2
|
| 52 |
+
break
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// Merge adjacent spaces and data.
|
| 58 |
+
index = headEnterIndex - 1
|
| 59 |
+
tailExitIndex++
|
| 60 |
+
|
| 61 |
+
while (++index <= tailExitIndex) {
|
| 62 |
+
if (enter === undefined) {
|
| 63 |
+
if (
|
| 64 |
+
index !== tailExitIndex &&
|
| 65 |
+
events[index][1].type !== types.lineEnding
|
| 66 |
+
) {
|
| 67 |
+
enter = index
|
| 68 |
+
}
|
| 69 |
+
} else if (
|
| 70 |
+
index === tailExitIndex ||
|
| 71 |
+
events[index][1].type === types.lineEnding
|
| 72 |
+
) {
|
| 73 |
+
events[enter][1].type = types.codeTextData
|
| 74 |
+
|
| 75 |
+
if (index !== enter + 2) {
|
| 76 |
+
events[enter][1].end = events[index - 1][1].end
|
| 77 |
+
events.splice(enter + 2, index - enter - 2)
|
| 78 |
+
tailExitIndex -= index - enter - 2
|
| 79 |
+
index = enter + 2
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
enter = undefined
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
return events
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* @this {TokenizeContext}
|
| 91 |
+
* Context.
|
| 92 |
+
* @type {Previous}
|
| 93 |
+
*/
|
| 94 |
+
function previous(code) {
|
| 95 |
+
// If there is a previous code, there will always be a tail.
|
| 96 |
+
return (
|
| 97 |
+
code !== codes.graveAccent ||
|
| 98 |
+
this.events[this.events.length - 1][1].type === types.characterEscape
|
| 99 |
+
)
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* @this {TokenizeContext}
|
| 104 |
+
* Context.
|
| 105 |
+
* @type {Tokenizer}
|
| 106 |
+
*/
|
| 107 |
+
function tokenizeCodeText(effects, ok, nok) {
|
| 108 |
+
const self = this
|
| 109 |
+
let sizeOpen = 0
|
| 110 |
+
/** @type {number} */
|
| 111 |
+
let size
|
| 112 |
+
/** @type {Token} */
|
| 113 |
+
let token
|
| 114 |
+
|
| 115 |
+
return start
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Start of code (text).
|
| 119 |
+
*
|
| 120 |
+
* ```markdown
|
| 121 |
+
* > | `a`
|
| 122 |
+
* ^
|
| 123 |
+
* > | \`a`
|
| 124 |
+
* ^
|
| 125 |
+
* ```
|
| 126 |
+
*
|
| 127 |
+
* @type {State}
|
| 128 |
+
*/
|
| 129 |
+
function start(code) {
|
| 130 |
+
assert(code === codes.graveAccent, 'expected `` ` ``')
|
| 131 |
+
assert(previous.call(self, self.previous), 'expected correct previous')
|
| 132 |
+
effects.enter(types.codeText)
|
| 133 |
+
effects.enter(types.codeTextSequence)
|
| 134 |
+
return sequenceOpen(code)
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* In opening sequence.
|
| 139 |
+
*
|
| 140 |
+
* ```markdown
|
| 141 |
+
* > | `a`
|
| 142 |
+
* ^
|
| 143 |
+
* ```
|
| 144 |
+
*
|
| 145 |
+
* @type {State}
|
| 146 |
+
*/
|
| 147 |
+
function sequenceOpen(code) {
|
| 148 |
+
if (code === codes.graveAccent) {
|
| 149 |
+
effects.consume(code)
|
| 150 |
+
sizeOpen++
|
| 151 |
+
return sequenceOpen
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
effects.exit(types.codeTextSequence)
|
| 155 |
+
return between(code)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* Between something and something else.
|
| 160 |
+
*
|
| 161 |
+
* ```markdown
|
| 162 |
+
* > | `a`
|
| 163 |
+
* ^^
|
| 164 |
+
* ```
|
| 165 |
+
*
|
| 166 |
+
* @type {State}
|
| 167 |
+
*/
|
| 168 |
+
function between(code) {
|
| 169 |
+
// EOF.
|
| 170 |
+
if (code === codes.eof) {
|
| 171 |
+
return nok(code)
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
// To do: next major: don’t do spaces in resolve, but when compiling,
|
| 175 |
+
// like `markdown-rs`.
|
| 176 |
+
// Tabs don’t work, and virtual spaces don’t make sense.
|
| 177 |
+
if (code === codes.space) {
|
| 178 |
+
effects.enter('space')
|
| 179 |
+
effects.consume(code)
|
| 180 |
+
effects.exit('space')
|
| 181 |
+
return between
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// Closing fence? Could also be data.
|
| 185 |
+
if (code === codes.graveAccent) {
|
| 186 |
+
token = effects.enter(types.codeTextSequence)
|
| 187 |
+
size = 0
|
| 188 |
+
return sequenceClose(code)
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
if (markdownLineEnding(code)) {
|
| 192 |
+
effects.enter(types.lineEnding)
|
| 193 |
+
effects.consume(code)
|
| 194 |
+
effects.exit(types.lineEnding)
|
| 195 |
+
return between
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
// Data.
|
| 199 |
+
effects.enter(types.codeTextData)
|
| 200 |
+
return data(code)
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* In data.
|
| 205 |
+
*
|
| 206 |
+
* ```markdown
|
| 207 |
+
* > | `a`
|
| 208 |
+
* ^
|
| 209 |
+
* ```
|
| 210 |
+
*
|
| 211 |
+
* @type {State}
|
| 212 |
+
*/
|
| 213 |
+
function data(code) {
|
| 214 |
+
if (
|
| 215 |
+
code === codes.eof ||
|
| 216 |
+
code === codes.space ||
|
| 217 |
+
code === codes.graveAccent ||
|
| 218 |
+
markdownLineEnding(code)
|
| 219 |
+
) {
|
| 220 |
+
effects.exit(types.codeTextData)
|
| 221 |
+
return between(code)
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
effects.consume(code)
|
| 225 |
+
return data
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
/**
|
| 229 |
+
* In closing sequence.
|
| 230 |
+
*
|
| 231 |
+
* ```markdown
|
| 232 |
+
* > | `a`
|
| 233 |
+
* ^
|
| 234 |
+
* ```
|
| 235 |
+
*
|
| 236 |
+
* @type {State}
|
| 237 |
+
*/
|
| 238 |
+
function sequenceClose(code) {
|
| 239 |
+
// More.
|
| 240 |
+
if (code === codes.graveAccent) {
|
| 241 |
+
effects.consume(code)
|
| 242 |
+
size++
|
| 243 |
+
return sequenceClose
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
// Done!
|
| 247 |
+
if (size === sizeOpen) {
|
| 248 |
+
effects.exit(types.codeTextSequence)
|
| 249 |
+
effects.exit(types.codeText)
|
| 250 |
+
return ok(code)
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
// More or less accents: mark as data.
|
| 254 |
+
token.type = types.codeTextData
|
| 255 |
+
return data(code)
|
| 256 |
+
}
|
| 257 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/content.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* No name because it must not be turned off.
|
| 3 |
+
* @type {Construct}
|
| 4 |
+
*/
|
| 5 |
+
export const content: Construct;
|
| 6 |
+
import type { Construct } from 'micromark-util-types';
|
| 7 |
+
//# sourceMappingURL=content.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/content.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["content.js"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,sBAFU,SAAS,CAEwD;+BAbjE,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/content.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
| 11 |
+
|
| 12 |
+
import {ok as assert} from 'devlop'
|
| 13 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 14 |
+
import {markdownLineEnding} from 'micromark-util-character'
|
| 15 |
+
import {subtokenize} from 'micromark-util-subtokenize'
|
| 16 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* No name because it must not be turned off.
|
| 20 |
+
* @type {Construct}
|
| 21 |
+
*/
|
| 22 |
+
export const content = {resolve: resolveContent, tokenize: tokenizeContent}
|
| 23 |
+
|
| 24 |
+
/** @type {Construct} */
|
| 25 |
+
const continuationConstruct = {partial: true, tokenize: tokenizeContinuation}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Content is transparent: it’s parsed right now. That way, definitions are also
|
| 29 |
+
* parsed right now: before text in paragraphs (specifically, media) are parsed.
|
| 30 |
+
*
|
| 31 |
+
* @type {Resolver}
|
| 32 |
+
*/
|
| 33 |
+
function resolveContent(events) {
|
| 34 |
+
subtokenize(events)
|
| 35 |
+
return events
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* @this {TokenizeContext}
|
| 40 |
+
* Context.
|
| 41 |
+
* @type {Tokenizer}
|
| 42 |
+
*/
|
| 43 |
+
function tokenizeContent(effects, ok) {
|
| 44 |
+
/** @type {Token | undefined} */
|
| 45 |
+
let previous
|
| 46 |
+
|
| 47 |
+
return chunkStart
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Before a content chunk.
|
| 51 |
+
*
|
| 52 |
+
* ```markdown
|
| 53 |
+
* > | abc
|
| 54 |
+
* ^
|
| 55 |
+
* ```
|
| 56 |
+
*
|
| 57 |
+
* @type {State}
|
| 58 |
+
*/
|
| 59 |
+
function chunkStart(code) {
|
| 60 |
+
assert(
|
| 61 |
+
code !== codes.eof && !markdownLineEnding(code),
|
| 62 |
+
'expected no eof or eol'
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
effects.enter(types.content)
|
| 66 |
+
previous = effects.enter(types.chunkContent, {
|
| 67 |
+
contentType: constants.contentTypeContent
|
| 68 |
+
})
|
| 69 |
+
return chunkInside(code)
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* In a content chunk.
|
| 74 |
+
*
|
| 75 |
+
* ```markdown
|
| 76 |
+
* > | abc
|
| 77 |
+
* ^^^
|
| 78 |
+
* ```
|
| 79 |
+
*
|
| 80 |
+
* @type {State}
|
| 81 |
+
*/
|
| 82 |
+
function chunkInside(code) {
|
| 83 |
+
if (code === codes.eof) {
|
| 84 |
+
return contentEnd(code)
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// To do: in `markdown-rs`, each line is parsed on its own, and everything
|
| 88 |
+
// is stitched together resolving.
|
| 89 |
+
if (markdownLineEnding(code)) {
|
| 90 |
+
return effects.check(
|
| 91 |
+
continuationConstruct,
|
| 92 |
+
contentContinue,
|
| 93 |
+
contentEnd
|
| 94 |
+
)(code)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// Data.
|
| 98 |
+
effects.consume(code)
|
| 99 |
+
return chunkInside
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
*
|
| 104 |
+
*
|
| 105 |
+
* @type {State}
|
| 106 |
+
*/
|
| 107 |
+
function contentEnd(code) {
|
| 108 |
+
effects.exit(types.chunkContent)
|
| 109 |
+
effects.exit(types.content)
|
| 110 |
+
return ok(code)
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
*
|
| 115 |
+
*
|
| 116 |
+
* @type {State}
|
| 117 |
+
*/
|
| 118 |
+
function contentContinue(code) {
|
| 119 |
+
assert(markdownLineEnding(code), 'expected eol')
|
| 120 |
+
effects.consume(code)
|
| 121 |
+
effects.exit(types.chunkContent)
|
| 122 |
+
assert(previous, 'expected previous token')
|
| 123 |
+
previous.next = effects.enter(types.chunkContent, {
|
| 124 |
+
contentType: constants.contentTypeContent,
|
| 125 |
+
previous
|
| 126 |
+
})
|
| 127 |
+
previous = previous.next
|
| 128 |
+
return chunkInside
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/**
|
| 133 |
+
* @this {TokenizeContext}
|
| 134 |
+
* Context.
|
| 135 |
+
* @type {Tokenizer}
|
| 136 |
+
*/
|
| 137 |
+
function tokenizeContinuation(effects, ok, nok) {
|
| 138 |
+
const self = this
|
| 139 |
+
|
| 140 |
+
return startLookahead
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
*
|
| 144 |
+
*
|
| 145 |
+
* @type {State}
|
| 146 |
+
*/
|
| 147 |
+
function startLookahead(code) {
|
| 148 |
+
assert(markdownLineEnding(code), 'expected a line ending')
|
| 149 |
+
effects.exit(types.chunkContent)
|
| 150 |
+
effects.enter(types.lineEnding)
|
| 151 |
+
effects.consume(code)
|
| 152 |
+
effects.exit(types.lineEnding)
|
| 153 |
+
return factorySpace(effects, prefixed, types.linePrefix)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
*
|
| 158 |
+
*
|
| 159 |
+
* @type {State}
|
| 160 |
+
*/
|
| 161 |
+
function prefixed(code) {
|
| 162 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 163 |
+
return nok(code)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
// Always populated by defaults.
|
| 167 |
+
assert(
|
| 168 |
+
self.parser.constructs.disable.null,
|
| 169 |
+
'expected `disable.null` to be populated'
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
const tail = self.events[self.events.length - 1]
|
| 173 |
+
|
| 174 |
+
if (
|
| 175 |
+
!self.parser.constructs.disable.null.includes('codeIndented') &&
|
| 176 |
+
tail &&
|
| 177 |
+
tail[1].type === types.linePrefix &&
|
| 178 |
+
tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize
|
| 179 |
+
) {
|
| 180 |
+
return ok(code)
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
return effects.interrupt(self.parser.constructs.flow, nok, ok)(code)
|
| 184 |
+
}
|
| 185 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/definition.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const definition: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=definition.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/definition.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["definition.js"],"names":[],"mappings":"AAuBA,wBAAwB;AACxB,yBADW,SAAS,CACwD;+BAlBlE,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/definition.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* State,
|
| 5 |
+
* TokenizeContext,
|
| 6 |
+
* Tokenizer
|
| 7 |
+
* } from 'micromark-util-types'
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import {ok as assert} from 'devlop'
|
| 11 |
+
import {factoryDestination} from 'micromark-factory-destination'
|
| 12 |
+
import {factoryLabel} from 'micromark-factory-label'
|
| 13 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 14 |
+
import {factoryTitle} from 'micromark-factory-title'
|
| 15 |
+
import {factoryWhitespace} from 'micromark-factory-whitespace'
|
| 16 |
+
import {
|
| 17 |
+
markdownLineEndingOrSpace,
|
| 18 |
+
markdownLineEnding,
|
| 19 |
+
markdownSpace
|
| 20 |
+
} from 'micromark-util-character'
|
| 21 |
+
import {normalizeIdentifier} from 'micromark-util-normalize-identifier'
|
| 22 |
+
import {codes, types} from 'micromark-util-symbol'
|
| 23 |
+
|
| 24 |
+
/** @type {Construct} */
|
| 25 |
+
export const definition = {name: 'definition', tokenize: tokenizeDefinition}
|
| 26 |
+
|
| 27 |
+
/** @type {Construct} */
|
| 28 |
+
const titleBefore = {partial: true, tokenize: tokenizeTitleBefore}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @this {TokenizeContext}
|
| 32 |
+
* Context.
|
| 33 |
+
* @type {Tokenizer}
|
| 34 |
+
*/
|
| 35 |
+
function tokenizeDefinition(effects, ok, nok) {
|
| 36 |
+
const self = this
|
| 37 |
+
/** @type {string} */
|
| 38 |
+
let identifier
|
| 39 |
+
|
| 40 |
+
return start
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* At start of a definition.
|
| 44 |
+
*
|
| 45 |
+
* ```markdown
|
| 46 |
+
* > | [a]: b "c"
|
| 47 |
+
* ^
|
| 48 |
+
* ```
|
| 49 |
+
*
|
| 50 |
+
* @type {State}
|
| 51 |
+
*/
|
| 52 |
+
function start(code) {
|
| 53 |
+
// Do not interrupt paragraphs (but do follow definitions).
|
| 54 |
+
// To do: do `interrupt` the way `markdown-rs` does.
|
| 55 |
+
// To do: parse whitespace the way `markdown-rs` does.
|
| 56 |
+
effects.enter(types.definition)
|
| 57 |
+
return before(code)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* After optional whitespace, at `[`.
|
| 62 |
+
*
|
| 63 |
+
* ```markdown
|
| 64 |
+
* > | [a]: b "c"
|
| 65 |
+
* ^
|
| 66 |
+
* ```
|
| 67 |
+
*
|
| 68 |
+
* @type {State}
|
| 69 |
+
*/
|
| 70 |
+
function before(code) {
|
| 71 |
+
// To do: parse whitespace the way `markdown-rs` does.
|
| 72 |
+
assert(code === codes.leftSquareBracket, 'expected `[`')
|
| 73 |
+
return factoryLabel.call(
|
| 74 |
+
self,
|
| 75 |
+
effects,
|
| 76 |
+
labelAfter,
|
| 77 |
+
// Note: we don’t need to reset the way `markdown-rs` does.
|
| 78 |
+
nok,
|
| 79 |
+
types.definitionLabel,
|
| 80 |
+
types.definitionLabelMarker,
|
| 81 |
+
types.definitionLabelString
|
| 82 |
+
)(code)
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* After label.
|
| 87 |
+
*
|
| 88 |
+
* ```markdown
|
| 89 |
+
* > | [a]: b "c"
|
| 90 |
+
* ^
|
| 91 |
+
* ```
|
| 92 |
+
*
|
| 93 |
+
* @type {State}
|
| 94 |
+
*/
|
| 95 |
+
function labelAfter(code) {
|
| 96 |
+
identifier = normalizeIdentifier(
|
| 97 |
+
self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1)
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
if (code === codes.colon) {
|
| 101 |
+
effects.enter(types.definitionMarker)
|
| 102 |
+
effects.consume(code)
|
| 103 |
+
effects.exit(types.definitionMarker)
|
| 104 |
+
return markerAfter
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
return nok(code)
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* After marker.
|
| 112 |
+
*
|
| 113 |
+
* ```markdown
|
| 114 |
+
* > | [a]: b "c"
|
| 115 |
+
* ^
|
| 116 |
+
* ```
|
| 117 |
+
*
|
| 118 |
+
* @type {State}
|
| 119 |
+
*/
|
| 120 |
+
function markerAfter(code) {
|
| 121 |
+
// Note: whitespace is optional.
|
| 122 |
+
return markdownLineEndingOrSpace(code)
|
| 123 |
+
? factoryWhitespace(effects, destinationBefore)(code)
|
| 124 |
+
: destinationBefore(code)
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* Before destination.
|
| 129 |
+
*
|
| 130 |
+
* ```markdown
|
| 131 |
+
* > | [a]: b "c"
|
| 132 |
+
* ^
|
| 133 |
+
* ```
|
| 134 |
+
*
|
| 135 |
+
* @type {State}
|
| 136 |
+
*/
|
| 137 |
+
function destinationBefore(code) {
|
| 138 |
+
return factoryDestination(
|
| 139 |
+
effects,
|
| 140 |
+
destinationAfter,
|
| 141 |
+
// Note: we don’t need to reset the way `markdown-rs` does.
|
| 142 |
+
nok,
|
| 143 |
+
types.definitionDestination,
|
| 144 |
+
types.definitionDestinationLiteral,
|
| 145 |
+
types.definitionDestinationLiteralMarker,
|
| 146 |
+
types.definitionDestinationRaw,
|
| 147 |
+
types.definitionDestinationString
|
| 148 |
+
)(code)
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* After destination.
|
| 153 |
+
*
|
| 154 |
+
* ```markdown
|
| 155 |
+
* > | [a]: b "c"
|
| 156 |
+
* ^
|
| 157 |
+
* ```
|
| 158 |
+
*
|
| 159 |
+
* @type {State}
|
| 160 |
+
*/
|
| 161 |
+
function destinationAfter(code) {
|
| 162 |
+
return effects.attempt(titleBefore, after, after)(code)
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* After definition.
|
| 167 |
+
*
|
| 168 |
+
* ```markdown
|
| 169 |
+
* > | [a]: b
|
| 170 |
+
* ^
|
| 171 |
+
* > | [a]: b "c"
|
| 172 |
+
* ^
|
| 173 |
+
* ```
|
| 174 |
+
*
|
| 175 |
+
* @type {State}
|
| 176 |
+
*/
|
| 177 |
+
function after(code) {
|
| 178 |
+
return markdownSpace(code)
|
| 179 |
+
? factorySpace(effects, afterWhitespace, types.whitespace)(code)
|
| 180 |
+
: afterWhitespace(code)
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* After definition, after optional whitespace.
|
| 185 |
+
*
|
| 186 |
+
* ```markdown
|
| 187 |
+
* > | [a]: b
|
| 188 |
+
* ^
|
| 189 |
+
* > | [a]: b "c"
|
| 190 |
+
* ^
|
| 191 |
+
* ```
|
| 192 |
+
*
|
| 193 |
+
* @type {State}
|
| 194 |
+
*/
|
| 195 |
+
function afterWhitespace(code) {
|
| 196 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 197 |
+
effects.exit(types.definition)
|
| 198 |
+
|
| 199 |
+
// Note: we don’t care about uniqueness.
|
| 200 |
+
// It’s likely that that doesn’t happen very frequently.
|
| 201 |
+
// It is more likely that it wastes precious time.
|
| 202 |
+
self.parser.defined.push(identifier)
|
| 203 |
+
|
| 204 |
+
// To do: `markdown-rs` interrupt.
|
| 205 |
+
// // You’d be interrupting.
|
| 206 |
+
// tokenizer.interrupt = true
|
| 207 |
+
return ok(code)
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
return nok(code)
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* @this {TokenizeContext}
|
| 216 |
+
* Context.
|
| 217 |
+
* @type {Tokenizer}
|
| 218 |
+
*/
|
| 219 |
+
function tokenizeTitleBefore(effects, ok, nok) {
|
| 220 |
+
return titleBefore
|
| 221 |
+
|
| 222 |
+
/**
|
| 223 |
+
* After destination, at whitespace.
|
| 224 |
+
*
|
| 225 |
+
* ```markdown
|
| 226 |
+
* > | [a]: b
|
| 227 |
+
* ^
|
| 228 |
+
* > | [a]: b "c"
|
| 229 |
+
* ^
|
| 230 |
+
* ```
|
| 231 |
+
*
|
| 232 |
+
* @type {State}
|
| 233 |
+
*/
|
| 234 |
+
function titleBefore(code) {
|
| 235 |
+
return markdownLineEndingOrSpace(code)
|
| 236 |
+
? factoryWhitespace(effects, beforeMarker)(code)
|
| 237 |
+
: nok(code)
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* At title.
|
| 242 |
+
*
|
| 243 |
+
* ```markdown
|
| 244 |
+
* | [a]: b
|
| 245 |
+
* > | "c"
|
| 246 |
+
* ^
|
| 247 |
+
* ```
|
| 248 |
+
*
|
| 249 |
+
* @type {State}
|
| 250 |
+
*/
|
| 251 |
+
function beforeMarker(code) {
|
| 252 |
+
return factoryTitle(
|
| 253 |
+
effects,
|
| 254 |
+
titleAfter,
|
| 255 |
+
nok,
|
| 256 |
+
types.definitionTitle,
|
| 257 |
+
types.definitionTitleMarker,
|
| 258 |
+
types.definitionTitleString
|
| 259 |
+
)(code)
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* After title.
|
| 264 |
+
*
|
| 265 |
+
* ```markdown
|
| 266 |
+
* > | [a]: b "c"
|
| 267 |
+
* ^
|
| 268 |
+
* ```
|
| 269 |
+
*
|
| 270 |
+
* @type {State}
|
| 271 |
+
*/
|
| 272 |
+
function titleAfter(code) {
|
| 273 |
+
return markdownSpace(code)
|
| 274 |
+
? factorySpace(
|
| 275 |
+
effects,
|
| 276 |
+
titleAfterOptionalWhitespace,
|
| 277 |
+
types.whitespace
|
| 278 |
+
)(code)
|
| 279 |
+
: titleAfterOptionalWhitespace(code)
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
/**
|
| 283 |
+
* After title, after optional whitespace.
|
| 284 |
+
*
|
| 285 |
+
* ```markdown
|
| 286 |
+
* > | [a]: b "c"
|
| 287 |
+
* ^
|
| 288 |
+
* ```
|
| 289 |
+
*
|
| 290 |
+
* @type {State}
|
| 291 |
+
*/
|
| 292 |
+
function titleAfterOptionalWhitespace(code) {
|
| 293 |
+
return code === codes.eof || markdownLineEnding(code) ? ok(code) : nok(code)
|
| 294 |
+
}
|
| 295 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const hardBreakEscape: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=hard-break-escape.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"hard-break-escape.d.ts","sourceRoot":"","sources":["hard-break-escape.js"],"names":[],"mappings":"AAaA,wBAAwB;AACxB,8BADW,SAAS,CAInB;+BAXS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* State,
|
| 5 |
+
* TokenizeContext,
|
| 6 |
+
* Tokenizer
|
| 7 |
+
* } from 'micromark-util-types'
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import {ok as assert} from 'devlop'
|
| 11 |
+
import {markdownLineEnding} from 'micromark-util-character'
|
| 12 |
+
import {codes, types} from 'micromark-util-symbol'
|
| 13 |
+
|
| 14 |
+
/** @type {Construct} */
|
| 15 |
+
export const hardBreakEscape = {
|
| 16 |
+
name: 'hardBreakEscape',
|
| 17 |
+
tokenize: tokenizeHardBreakEscape
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* @this {TokenizeContext}
|
| 22 |
+
* Context.
|
| 23 |
+
* @type {Tokenizer}
|
| 24 |
+
*/
|
| 25 |
+
function tokenizeHardBreakEscape(effects, ok, nok) {
|
| 26 |
+
return start
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Start of a hard break (escape).
|
| 30 |
+
*
|
| 31 |
+
* ```markdown
|
| 32 |
+
* > | a\
|
| 33 |
+
* ^
|
| 34 |
+
* | b
|
| 35 |
+
* ```
|
| 36 |
+
*
|
| 37 |
+
* @type {State}
|
| 38 |
+
*/
|
| 39 |
+
function start(code) {
|
| 40 |
+
assert(code === codes.backslash, 'expected `\\`')
|
| 41 |
+
effects.enter(types.hardBreakEscape)
|
| 42 |
+
effects.consume(code)
|
| 43 |
+
return after
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* After `\`, at eol.
|
| 48 |
+
*
|
| 49 |
+
* ```markdown
|
| 50 |
+
* > | a\
|
| 51 |
+
* ^
|
| 52 |
+
* | b
|
| 53 |
+
* ```
|
| 54 |
+
*
|
| 55 |
+
* @type {State}
|
| 56 |
+
*/
|
| 57 |
+
function after(code) {
|
| 58 |
+
if (markdownLineEnding(code)) {
|
| 59 |
+
effects.exit(types.hardBreakEscape)
|
| 60 |
+
return ok(code)
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
return nok(code)
|
| 64 |
+
}
|
| 65 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/heading-atx.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const headingAtx: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=heading-atx.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/heading-atx.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"heading-atx.d.ts","sourceRoot":"","sources":["heading-atx.js"],"names":[],"mappings":"AAqBA,wBAAwB;AACxB,yBADW,SAAS,CAKnB;+BAlBS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/heading-atx.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Construct,
|
| 4 |
+
* Resolver,
|
| 5 |
+
* State,
|
| 6 |
+
* TokenizeContext,
|
| 7 |
+
* Tokenizer,
|
| 8 |
+
* Token
|
| 9 |
+
* } from 'micromark-util-types'
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
import {ok as assert} from 'devlop'
|
| 13 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 14 |
+
import {
|
| 15 |
+
markdownLineEndingOrSpace,
|
| 16 |
+
markdownLineEnding,
|
| 17 |
+
markdownSpace
|
| 18 |
+
} from 'micromark-util-character'
|
| 19 |
+
import {splice} from 'micromark-util-chunked'
|
| 20 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 21 |
+
|
| 22 |
+
/** @type {Construct} */
|
| 23 |
+
export const headingAtx = {
|
| 24 |
+
name: 'headingAtx',
|
| 25 |
+
resolve: resolveHeadingAtx,
|
| 26 |
+
tokenize: tokenizeHeadingAtx
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/** @type {Resolver} */
|
| 30 |
+
function resolveHeadingAtx(events, context) {
|
| 31 |
+
let contentEnd = events.length - 2
|
| 32 |
+
let contentStart = 3
|
| 33 |
+
/** @type {Token} */
|
| 34 |
+
let content
|
| 35 |
+
/** @type {Token} */
|
| 36 |
+
let text
|
| 37 |
+
|
| 38 |
+
// Prefix whitespace, part of the opening.
|
| 39 |
+
if (events[contentStart][1].type === types.whitespace) {
|
| 40 |
+
contentStart += 2
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
// Suffix whitespace, part of the closing.
|
| 44 |
+
if (
|
| 45 |
+
contentEnd - 2 > contentStart &&
|
| 46 |
+
events[contentEnd][1].type === types.whitespace
|
| 47 |
+
) {
|
| 48 |
+
contentEnd -= 2
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if (
|
| 52 |
+
events[contentEnd][1].type === types.atxHeadingSequence &&
|
| 53 |
+
(contentStart === contentEnd - 1 ||
|
| 54 |
+
(contentEnd - 4 > contentStart &&
|
| 55 |
+
events[contentEnd - 2][1].type === types.whitespace))
|
| 56 |
+
) {
|
| 57 |
+
contentEnd -= contentStart + 1 === contentEnd ? 2 : 4
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
if (contentEnd > contentStart) {
|
| 61 |
+
content = {
|
| 62 |
+
type: types.atxHeadingText,
|
| 63 |
+
start: events[contentStart][1].start,
|
| 64 |
+
end: events[contentEnd][1].end
|
| 65 |
+
}
|
| 66 |
+
text = {
|
| 67 |
+
type: types.chunkText,
|
| 68 |
+
start: events[contentStart][1].start,
|
| 69 |
+
end: events[contentEnd][1].end,
|
| 70 |
+
contentType: constants.contentTypeText
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
splice(events, contentStart, contentEnd - contentStart + 1, [
|
| 74 |
+
['enter', content, context],
|
| 75 |
+
['enter', text, context],
|
| 76 |
+
['exit', text, context],
|
| 77 |
+
['exit', content, context]
|
| 78 |
+
])
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
return events
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* @this {TokenizeContext}
|
| 86 |
+
* Context.
|
| 87 |
+
* @type {Tokenizer}
|
| 88 |
+
*/
|
| 89 |
+
function tokenizeHeadingAtx(effects, ok, nok) {
|
| 90 |
+
let size = 0
|
| 91 |
+
|
| 92 |
+
return start
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Start of a heading (atx).
|
| 96 |
+
*
|
| 97 |
+
* ```markdown
|
| 98 |
+
* > | ## aa
|
| 99 |
+
* ^
|
| 100 |
+
* ```
|
| 101 |
+
*
|
| 102 |
+
* @type {State}
|
| 103 |
+
*/
|
| 104 |
+
function start(code) {
|
| 105 |
+
// To do: parse indent like `markdown-rs`.
|
| 106 |
+
effects.enter(types.atxHeading)
|
| 107 |
+
return before(code)
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* After optional whitespace, at `#`.
|
| 112 |
+
*
|
| 113 |
+
* ```markdown
|
| 114 |
+
* > | ## aa
|
| 115 |
+
* ^
|
| 116 |
+
* ```
|
| 117 |
+
*
|
| 118 |
+
* @type {State}
|
| 119 |
+
*/
|
| 120 |
+
function before(code) {
|
| 121 |
+
assert(code === codes.numberSign, 'expected `#`')
|
| 122 |
+
effects.enter(types.atxHeadingSequence)
|
| 123 |
+
return sequenceOpen(code)
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* In opening sequence.
|
| 128 |
+
*
|
| 129 |
+
* ```markdown
|
| 130 |
+
* > | ## aa
|
| 131 |
+
* ^
|
| 132 |
+
* ```
|
| 133 |
+
*
|
| 134 |
+
* @type {State}
|
| 135 |
+
*/
|
| 136 |
+
function sequenceOpen(code) {
|
| 137 |
+
if (
|
| 138 |
+
code === codes.numberSign &&
|
| 139 |
+
size++ < constants.atxHeadingOpeningFenceSizeMax
|
| 140 |
+
) {
|
| 141 |
+
effects.consume(code)
|
| 142 |
+
return sequenceOpen
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
// Always at least one `#`.
|
| 146 |
+
if (code === codes.eof || markdownLineEndingOrSpace(code)) {
|
| 147 |
+
effects.exit(types.atxHeadingSequence)
|
| 148 |
+
return atBreak(code)
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
return nok(code)
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* After something, before something else.
|
| 156 |
+
*
|
| 157 |
+
* ```markdown
|
| 158 |
+
* > | ## aa
|
| 159 |
+
* ^
|
| 160 |
+
* ```
|
| 161 |
+
*
|
| 162 |
+
* @type {State}
|
| 163 |
+
*/
|
| 164 |
+
function atBreak(code) {
|
| 165 |
+
if (code === codes.numberSign) {
|
| 166 |
+
effects.enter(types.atxHeadingSequence)
|
| 167 |
+
return sequenceFurther(code)
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 171 |
+
effects.exit(types.atxHeading)
|
| 172 |
+
// To do: interrupt like `markdown-rs`.
|
| 173 |
+
// // Feel free to interrupt.
|
| 174 |
+
// tokenizer.interrupt = false
|
| 175 |
+
return ok(code)
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
if (markdownSpace(code)) {
|
| 179 |
+
return factorySpace(effects, atBreak, types.whitespace)(code)
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
// To do: generate `data` tokens, add the `text` token later.
|
| 183 |
+
// Needs edit map, see: `markdown.rs`.
|
| 184 |
+
effects.enter(types.atxHeadingText)
|
| 185 |
+
return data(code)
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* In further sequence (after whitespace).
|
| 190 |
+
*
|
| 191 |
+
* Could be normal “visible” hashes in the heading or a final sequence.
|
| 192 |
+
*
|
| 193 |
+
* ```markdown
|
| 194 |
+
* > | ## aa ##
|
| 195 |
+
* ^
|
| 196 |
+
* ```
|
| 197 |
+
*
|
| 198 |
+
* @type {State}
|
| 199 |
+
*/
|
| 200 |
+
function sequenceFurther(code) {
|
| 201 |
+
if (code === codes.numberSign) {
|
| 202 |
+
effects.consume(code)
|
| 203 |
+
return sequenceFurther
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
effects.exit(types.atxHeadingSequence)
|
| 207 |
+
return atBreak(code)
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* In text.
|
| 212 |
+
*
|
| 213 |
+
* ```markdown
|
| 214 |
+
* > | ## aa
|
| 215 |
+
* ^
|
| 216 |
+
* ```
|
| 217 |
+
*
|
| 218 |
+
* @type {State}
|
| 219 |
+
*/
|
| 220 |
+
function data(code) {
|
| 221 |
+
if (
|
| 222 |
+
code === codes.eof ||
|
| 223 |
+
code === codes.numberSign ||
|
| 224 |
+
markdownLineEndingOrSpace(code)
|
| 225 |
+
) {
|
| 226 |
+
effects.exit(types.atxHeadingText)
|
| 227 |
+
return atBreak(code)
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
effects.consume(code)
|
| 231 |
+
return data
|
| 232 |
+
}
|
| 233 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const htmlFlow: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=html-flow.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"html-flow.d.ts","sourceRoot":"","sources":["html-flow.js"],"names":[],"mappings":"AAuBA,wBAAwB;AACxB,uBADW,SAAS,CAMnB;+BArBS,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/html-flow.js
ADDED
|
@@ -0,0 +1,989 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Code,
|
| 4 |
+
* Construct,
|
| 5 |
+
* Resolver,
|
| 6 |
+
* State,
|
| 7 |
+
* TokenizeContext,
|
| 8 |
+
* Tokenizer
|
| 9 |
+
* } from 'micromark-util-types'
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
import {ok as assert} from 'devlop'
|
| 13 |
+
import {
|
| 14 |
+
asciiAlphanumeric,
|
| 15 |
+
asciiAlpha,
|
| 16 |
+
markdownLineEndingOrSpace,
|
| 17 |
+
markdownLineEnding,
|
| 18 |
+
markdownSpace
|
| 19 |
+
} from 'micromark-util-character'
|
| 20 |
+
import {htmlBlockNames, htmlRawNames} from 'micromark-util-html-tag-name'
|
| 21 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 22 |
+
import {blankLine} from './blank-line.js'
|
| 23 |
+
|
| 24 |
+
/** @type {Construct} */
|
| 25 |
+
export const htmlFlow = {
|
| 26 |
+
concrete: true,
|
| 27 |
+
name: 'htmlFlow',
|
| 28 |
+
resolveTo: resolveToHtmlFlow,
|
| 29 |
+
tokenize: tokenizeHtmlFlow
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/** @type {Construct} */
|
| 33 |
+
const blankLineBefore = {partial: true, tokenize: tokenizeBlankLineBefore}
|
| 34 |
+
const nonLazyContinuationStart = {
|
| 35 |
+
partial: true,
|
| 36 |
+
tokenize: tokenizeNonLazyContinuationStart
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/** @type {Resolver} */
|
| 40 |
+
function resolveToHtmlFlow(events) {
|
| 41 |
+
let index = events.length
|
| 42 |
+
|
| 43 |
+
while (index--) {
|
| 44 |
+
if (
|
| 45 |
+
events[index][0] === 'enter' &&
|
| 46 |
+
events[index][1].type === types.htmlFlow
|
| 47 |
+
) {
|
| 48 |
+
break
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
if (index > 1 && events[index - 2][1].type === types.linePrefix) {
|
| 53 |
+
// Add the prefix start to the HTML token.
|
| 54 |
+
events[index][1].start = events[index - 2][1].start
|
| 55 |
+
// Add the prefix start to the HTML line token.
|
| 56 |
+
events[index + 1][1].start = events[index - 2][1].start
|
| 57 |
+
// Remove the line prefix.
|
| 58 |
+
events.splice(index - 2, 2)
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
return events
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* @this {TokenizeContext}
|
| 66 |
+
* Context.
|
| 67 |
+
* @type {Tokenizer}
|
| 68 |
+
*/
|
| 69 |
+
function tokenizeHtmlFlow(effects, ok, nok) {
|
| 70 |
+
const self = this
|
| 71 |
+
/** @type {number} */
|
| 72 |
+
let marker
|
| 73 |
+
/** @type {boolean} */
|
| 74 |
+
let closingTag
|
| 75 |
+
/** @type {string} */
|
| 76 |
+
let buffer
|
| 77 |
+
/** @type {number} */
|
| 78 |
+
let index
|
| 79 |
+
/** @type {Code} */
|
| 80 |
+
let markerB
|
| 81 |
+
|
| 82 |
+
return start
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Start of HTML (flow).
|
| 86 |
+
*
|
| 87 |
+
* ```markdown
|
| 88 |
+
* > | <x />
|
| 89 |
+
* ^
|
| 90 |
+
* ```
|
| 91 |
+
*
|
| 92 |
+
* @type {State}
|
| 93 |
+
*/
|
| 94 |
+
function start(code) {
|
| 95 |
+
// To do: parse indent like `markdown-rs`.
|
| 96 |
+
return before(code)
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* At `<`, after optional whitespace.
|
| 101 |
+
*
|
| 102 |
+
* ```markdown
|
| 103 |
+
* > | <x />
|
| 104 |
+
* ^
|
| 105 |
+
* ```
|
| 106 |
+
*
|
| 107 |
+
* @type {State}
|
| 108 |
+
*/
|
| 109 |
+
function before(code) {
|
| 110 |
+
assert(code === codes.lessThan, 'expected `<`')
|
| 111 |
+
effects.enter(types.htmlFlow)
|
| 112 |
+
effects.enter(types.htmlFlowData)
|
| 113 |
+
effects.consume(code)
|
| 114 |
+
return open
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* After `<`, at tag name or other stuff.
|
| 119 |
+
*
|
| 120 |
+
* ```markdown
|
| 121 |
+
* > | <x />
|
| 122 |
+
* ^
|
| 123 |
+
* > | <!doctype>
|
| 124 |
+
* ^
|
| 125 |
+
* > | <!--xxx-->
|
| 126 |
+
* ^
|
| 127 |
+
* ```
|
| 128 |
+
*
|
| 129 |
+
* @type {State}
|
| 130 |
+
*/
|
| 131 |
+
function open(code) {
|
| 132 |
+
if (code === codes.exclamationMark) {
|
| 133 |
+
effects.consume(code)
|
| 134 |
+
return declarationOpen
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
if (code === codes.slash) {
|
| 138 |
+
effects.consume(code)
|
| 139 |
+
closingTag = true
|
| 140 |
+
return tagCloseStart
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
if (code === codes.questionMark) {
|
| 144 |
+
effects.consume(code)
|
| 145 |
+
marker = constants.htmlInstruction
|
| 146 |
+
// To do:
|
| 147 |
+
// tokenizer.concrete = true
|
| 148 |
+
// To do: use `markdown-rs` style interrupt.
|
| 149 |
+
// While we’re in an instruction instead of a declaration, we’re on a `?`
|
| 150 |
+
// right now, so we do need to search for `>`, similar to declarations.
|
| 151 |
+
return self.interrupt ? ok : continuationDeclarationInside
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
// ASCII alphabetical.
|
| 155 |
+
if (asciiAlpha(code)) {
|
| 156 |
+
assert(code !== null) // Always the case.
|
| 157 |
+
effects.consume(code)
|
| 158 |
+
buffer = String.fromCharCode(code)
|
| 159 |
+
return tagName
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
return nok(code)
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* After `<!`, at declaration, comment, or CDATA.
|
| 167 |
+
*
|
| 168 |
+
* ```markdown
|
| 169 |
+
* > | <!doctype>
|
| 170 |
+
* ^
|
| 171 |
+
* > | <!--xxx-->
|
| 172 |
+
* ^
|
| 173 |
+
* > | <![CDATA[>&<]]>
|
| 174 |
+
* ^
|
| 175 |
+
* ```
|
| 176 |
+
*
|
| 177 |
+
* @type {State}
|
| 178 |
+
*/
|
| 179 |
+
function declarationOpen(code) {
|
| 180 |
+
if (code === codes.dash) {
|
| 181 |
+
effects.consume(code)
|
| 182 |
+
marker = constants.htmlComment
|
| 183 |
+
return commentOpenInside
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
if (code === codes.leftSquareBracket) {
|
| 187 |
+
effects.consume(code)
|
| 188 |
+
marker = constants.htmlCdata
|
| 189 |
+
index = 0
|
| 190 |
+
return cdataOpenInside
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
// ASCII alphabetical.
|
| 194 |
+
if (asciiAlpha(code)) {
|
| 195 |
+
effects.consume(code)
|
| 196 |
+
marker = constants.htmlDeclaration
|
| 197 |
+
// // Do not form containers.
|
| 198 |
+
// tokenizer.concrete = true
|
| 199 |
+
return self.interrupt ? ok : continuationDeclarationInside
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
return nok(code)
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
* After `<!-`, inside a comment, at another `-`.
|
| 207 |
+
*
|
| 208 |
+
* ```markdown
|
| 209 |
+
* > | <!--xxx-->
|
| 210 |
+
* ^
|
| 211 |
+
* ```
|
| 212 |
+
*
|
| 213 |
+
* @type {State}
|
| 214 |
+
*/
|
| 215 |
+
function commentOpenInside(code) {
|
| 216 |
+
if (code === codes.dash) {
|
| 217 |
+
effects.consume(code)
|
| 218 |
+
// // Do not form containers.
|
| 219 |
+
// tokenizer.concrete = true
|
| 220 |
+
return self.interrupt ? ok : continuationDeclarationInside
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
return nok(code)
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
/**
|
| 227 |
+
* After `<![`, inside CDATA, expecting `CDATA[`.
|
| 228 |
+
*
|
| 229 |
+
* ```markdown
|
| 230 |
+
* > | <![CDATA[>&<]]>
|
| 231 |
+
* ^^^^^^
|
| 232 |
+
* ```
|
| 233 |
+
*
|
| 234 |
+
* @type {State}
|
| 235 |
+
*/
|
| 236 |
+
function cdataOpenInside(code) {
|
| 237 |
+
const value = constants.cdataOpeningString
|
| 238 |
+
|
| 239 |
+
if (code === value.charCodeAt(index++)) {
|
| 240 |
+
effects.consume(code)
|
| 241 |
+
|
| 242 |
+
if (index === value.length) {
|
| 243 |
+
// // Do not form containers.
|
| 244 |
+
// tokenizer.concrete = true
|
| 245 |
+
return self.interrupt ? ok : continuation
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
return cdataOpenInside
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
return nok(code)
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* After `</`, in closing tag, at tag name.
|
| 256 |
+
*
|
| 257 |
+
* ```markdown
|
| 258 |
+
* > | </x>
|
| 259 |
+
* ^
|
| 260 |
+
* ```
|
| 261 |
+
*
|
| 262 |
+
* @type {State}
|
| 263 |
+
*/
|
| 264 |
+
function tagCloseStart(code) {
|
| 265 |
+
if (asciiAlpha(code)) {
|
| 266 |
+
assert(code !== null) // Always the case.
|
| 267 |
+
effects.consume(code)
|
| 268 |
+
buffer = String.fromCharCode(code)
|
| 269 |
+
return tagName
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
return nok(code)
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* In tag name.
|
| 277 |
+
*
|
| 278 |
+
* ```markdown
|
| 279 |
+
* > | <ab>
|
| 280 |
+
* ^^
|
| 281 |
+
* > | </ab>
|
| 282 |
+
* ^^
|
| 283 |
+
* ```
|
| 284 |
+
*
|
| 285 |
+
* @type {State}
|
| 286 |
+
*/
|
| 287 |
+
function tagName(code) {
|
| 288 |
+
if (
|
| 289 |
+
code === codes.eof ||
|
| 290 |
+
code === codes.slash ||
|
| 291 |
+
code === codes.greaterThan ||
|
| 292 |
+
markdownLineEndingOrSpace(code)
|
| 293 |
+
) {
|
| 294 |
+
const slash = code === codes.slash
|
| 295 |
+
const name = buffer.toLowerCase()
|
| 296 |
+
|
| 297 |
+
if (!slash && !closingTag && htmlRawNames.includes(name)) {
|
| 298 |
+
marker = constants.htmlRaw
|
| 299 |
+
// // Do not form containers.
|
| 300 |
+
// tokenizer.concrete = true
|
| 301 |
+
return self.interrupt ? ok(code) : continuation(code)
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
if (htmlBlockNames.includes(buffer.toLowerCase())) {
|
| 305 |
+
marker = constants.htmlBasic
|
| 306 |
+
|
| 307 |
+
if (slash) {
|
| 308 |
+
effects.consume(code)
|
| 309 |
+
return basicSelfClosing
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
// // Do not form containers.
|
| 313 |
+
// tokenizer.concrete = true
|
| 314 |
+
return self.interrupt ? ok(code) : continuation(code)
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
marker = constants.htmlComplete
|
| 318 |
+
// Do not support complete HTML when interrupting.
|
| 319 |
+
return self.interrupt && !self.parser.lazy[self.now().line]
|
| 320 |
+
? nok(code)
|
| 321 |
+
: closingTag
|
| 322 |
+
? completeClosingTagAfter(code)
|
| 323 |
+
: completeAttributeNameBefore(code)
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
// ASCII alphanumerical and `-`.
|
| 327 |
+
if (code === codes.dash || asciiAlphanumeric(code)) {
|
| 328 |
+
effects.consume(code)
|
| 329 |
+
buffer += String.fromCharCode(code)
|
| 330 |
+
return tagName
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
return nok(code)
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
/**
|
| 337 |
+
* After closing slash of a basic tag name.
|
| 338 |
+
*
|
| 339 |
+
* ```markdown
|
| 340 |
+
* > | <div/>
|
| 341 |
+
* ^
|
| 342 |
+
* ```
|
| 343 |
+
*
|
| 344 |
+
* @type {State}
|
| 345 |
+
*/
|
| 346 |
+
function basicSelfClosing(code) {
|
| 347 |
+
if (code === codes.greaterThan) {
|
| 348 |
+
effects.consume(code)
|
| 349 |
+
// // Do not form containers.
|
| 350 |
+
// tokenizer.concrete = true
|
| 351 |
+
return self.interrupt ? ok : continuation
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
return nok(code)
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
/**
|
| 358 |
+
* After closing slash of a complete tag name.
|
| 359 |
+
*
|
| 360 |
+
* ```markdown
|
| 361 |
+
* > | <x/>
|
| 362 |
+
* ^
|
| 363 |
+
* ```
|
| 364 |
+
*
|
| 365 |
+
* @type {State}
|
| 366 |
+
*/
|
| 367 |
+
function completeClosingTagAfter(code) {
|
| 368 |
+
if (markdownSpace(code)) {
|
| 369 |
+
effects.consume(code)
|
| 370 |
+
return completeClosingTagAfter
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
return completeEnd(code)
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
/**
|
| 377 |
+
* At an attribute name.
|
| 378 |
+
*
|
| 379 |
+
* At first, this state is used after a complete tag name, after whitespace,
|
| 380 |
+
* where it expects optional attributes or the end of the tag.
|
| 381 |
+
* It is also reused after attributes, when expecting more optional
|
| 382 |
+
* attributes.
|
| 383 |
+
*
|
| 384 |
+
* ```markdown
|
| 385 |
+
* > | <a />
|
| 386 |
+
* ^
|
| 387 |
+
* > | <a :b>
|
| 388 |
+
* ^
|
| 389 |
+
* > | <a _b>
|
| 390 |
+
* ^
|
| 391 |
+
* > | <a b>
|
| 392 |
+
* ^
|
| 393 |
+
* > | <a >
|
| 394 |
+
* ^
|
| 395 |
+
* ```
|
| 396 |
+
*
|
| 397 |
+
* @type {State}
|
| 398 |
+
*/
|
| 399 |
+
function completeAttributeNameBefore(code) {
|
| 400 |
+
if (code === codes.slash) {
|
| 401 |
+
effects.consume(code)
|
| 402 |
+
return completeEnd
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
// ASCII alphanumerical and `:` and `_`.
|
| 406 |
+
if (code === codes.colon || code === codes.underscore || asciiAlpha(code)) {
|
| 407 |
+
effects.consume(code)
|
| 408 |
+
return completeAttributeName
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
if (markdownSpace(code)) {
|
| 412 |
+
effects.consume(code)
|
| 413 |
+
return completeAttributeNameBefore
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
return completeEnd(code)
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
/**
|
| 420 |
+
* In attribute name.
|
| 421 |
+
*
|
| 422 |
+
* ```markdown
|
| 423 |
+
* > | <a :b>
|
| 424 |
+
* ^
|
| 425 |
+
* > | <a _b>
|
| 426 |
+
* ^
|
| 427 |
+
* > | <a b>
|
| 428 |
+
* ^
|
| 429 |
+
* ```
|
| 430 |
+
*
|
| 431 |
+
* @type {State}
|
| 432 |
+
*/
|
| 433 |
+
function completeAttributeName(code) {
|
| 434 |
+
// ASCII alphanumerical and `-`, `.`, `:`, and `_`.
|
| 435 |
+
if (
|
| 436 |
+
code === codes.dash ||
|
| 437 |
+
code === codes.dot ||
|
| 438 |
+
code === codes.colon ||
|
| 439 |
+
code === codes.underscore ||
|
| 440 |
+
asciiAlphanumeric(code)
|
| 441 |
+
) {
|
| 442 |
+
effects.consume(code)
|
| 443 |
+
return completeAttributeName
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
return completeAttributeNameAfter(code)
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
/**
|
| 450 |
+
* After attribute name, at an optional initializer, the end of the tag, or
|
| 451 |
+
* whitespace.
|
| 452 |
+
*
|
| 453 |
+
* ```markdown
|
| 454 |
+
* > | <a b>
|
| 455 |
+
* ^
|
| 456 |
+
* > | <a b=c>
|
| 457 |
+
* ^
|
| 458 |
+
* ```
|
| 459 |
+
*
|
| 460 |
+
* @type {State}
|
| 461 |
+
*/
|
| 462 |
+
function completeAttributeNameAfter(code) {
|
| 463 |
+
if (code === codes.equalsTo) {
|
| 464 |
+
effects.consume(code)
|
| 465 |
+
return completeAttributeValueBefore
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
if (markdownSpace(code)) {
|
| 469 |
+
effects.consume(code)
|
| 470 |
+
return completeAttributeNameAfter
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
return completeAttributeNameBefore(code)
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
/**
|
| 477 |
+
* Before unquoted, double quoted, or single quoted attribute value, allowing
|
| 478 |
+
* whitespace.
|
| 479 |
+
*
|
| 480 |
+
* ```markdown
|
| 481 |
+
* > | <a b=c>
|
| 482 |
+
* ^
|
| 483 |
+
* > | <a b="c">
|
| 484 |
+
* ^
|
| 485 |
+
* ```
|
| 486 |
+
*
|
| 487 |
+
* @type {State}
|
| 488 |
+
*/
|
| 489 |
+
function completeAttributeValueBefore(code) {
|
| 490 |
+
if (
|
| 491 |
+
code === codes.eof ||
|
| 492 |
+
code === codes.lessThan ||
|
| 493 |
+
code === codes.equalsTo ||
|
| 494 |
+
code === codes.greaterThan ||
|
| 495 |
+
code === codes.graveAccent
|
| 496 |
+
) {
|
| 497 |
+
return nok(code)
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
if (code === codes.quotationMark || code === codes.apostrophe) {
|
| 501 |
+
effects.consume(code)
|
| 502 |
+
markerB = code
|
| 503 |
+
return completeAttributeValueQuoted
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
if (markdownSpace(code)) {
|
| 507 |
+
effects.consume(code)
|
| 508 |
+
return completeAttributeValueBefore
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
return completeAttributeValueUnquoted(code)
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
/**
|
| 515 |
+
* In double or single quoted attribute value.
|
| 516 |
+
*
|
| 517 |
+
* ```markdown
|
| 518 |
+
* > | <a b="c">
|
| 519 |
+
* ^
|
| 520 |
+
* > | <a b='c'>
|
| 521 |
+
* ^
|
| 522 |
+
* ```
|
| 523 |
+
*
|
| 524 |
+
* @type {State}
|
| 525 |
+
*/
|
| 526 |
+
function completeAttributeValueQuoted(code) {
|
| 527 |
+
if (code === markerB) {
|
| 528 |
+
effects.consume(code)
|
| 529 |
+
markerB = null
|
| 530 |
+
return completeAttributeValueQuotedAfter
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 534 |
+
return nok(code)
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
effects.consume(code)
|
| 538 |
+
return completeAttributeValueQuoted
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
/**
|
| 542 |
+
* In unquoted attribute value.
|
| 543 |
+
*
|
| 544 |
+
* ```markdown
|
| 545 |
+
* > | <a b=c>
|
| 546 |
+
* ^
|
| 547 |
+
* ```
|
| 548 |
+
*
|
| 549 |
+
* @type {State}
|
| 550 |
+
*/
|
| 551 |
+
function completeAttributeValueUnquoted(code) {
|
| 552 |
+
if (
|
| 553 |
+
code === codes.eof ||
|
| 554 |
+
code === codes.quotationMark ||
|
| 555 |
+
code === codes.apostrophe ||
|
| 556 |
+
code === codes.slash ||
|
| 557 |
+
code === codes.lessThan ||
|
| 558 |
+
code === codes.equalsTo ||
|
| 559 |
+
code === codes.greaterThan ||
|
| 560 |
+
code === codes.graveAccent ||
|
| 561 |
+
markdownLineEndingOrSpace(code)
|
| 562 |
+
) {
|
| 563 |
+
return completeAttributeNameAfter(code)
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
effects.consume(code)
|
| 567 |
+
return completeAttributeValueUnquoted
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
/**
|
| 571 |
+
* After double or single quoted attribute value, before whitespace or the
|
| 572 |
+
* end of the tag.
|
| 573 |
+
*
|
| 574 |
+
* ```markdown
|
| 575 |
+
* > | <a b="c">
|
| 576 |
+
* ^
|
| 577 |
+
* ```
|
| 578 |
+
*
|
| 579 |
+
* @type {State}
|
| 580 |
+
*/
|
| 581 |
+
function completeAttributeValueQuotedAfter(code) {
|
| 582 |
+
if (
|
| 583 |
+
code === codes.slash ||
|
| 584 |
+
code === codes.greaterThan ||
|
| 585 |
+
markdownSpace(code)
|
| 586 |
+
) {
|
| 587 |
+
return completeAttributeNameBefore(code)
|
| 588 |
+
}
|
| 589 |
+
|
| 590 |
+
return nok(code)
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
/**
|
| 594 |
+
* In certain circumstances of a complete tag where only an `>` is allowed.
|
| 595 |
+
*
|
| 596 |
+
* ```markdown
|
| 597 |
+
* > | <a b="c">
|
| 598 |
+
* ^
|
| 599 |
+
* ```
|
| 600 |
+
*
|
| 601 |
+
* @type {State}
|
| 602 |
+
*/
|
| 603 |
+
function completeEnd(code) {
|
| 604 |
+
if (code === codes.greaterThan) {
|
| 605 |
+
effects.consume(code)
|
| 606 |
+
return completeAfter
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
return nok(code)
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
/**
|
| 613 |
+
* After `>` in a complete tag.
|
| 614 |
+
*
|
| 615 |
+
* ```markdown
|
| 616 |
+
* > | <x>
|
| 617 |
+
* ^
|
| 618 |
+
* ```
|
| 619 |
+
*
|
| 620 |
+
* @type {State}
|
| 621 |
+
*/
|
| 622 |
+
function completeAfter(code) {
|
| 623 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 624 |
+
// // Do not form containers.
|
| 625 |
+
// tokenizer.concrete = true
|
| 626 |
+
return continuation(code)
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
if (markdownSpace(code)) {
|
| 630 |
+
effects.consume(code)
|
| 631 |
+
return completeAfter
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
return nok(code)
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
/**
|
| 638 |
+
* In continuation of any HTML kind.
|
| 639 |
+
*
|
| 640 |
+
* ```markdown
|
| 641 |
+
* > | <!--xxx-->
|
| 642 |
+
* ^
|
| 643 |
+
* ```
|
| 644 |
+
*
|
| 645 |
+
* @type {State}
|
| 646 |
+
*/
|
| 647 |
+
function continuation(code) {
|
| 648 |
+
if (code === codes.dash && marker === constants.htmlComment) {
|
| 649 |
+
effects.consume(code)
|
| 650 |
+
return continuationCommentInside
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
if (code === codes.lessThan && marker === constants.htmlRaw) {
|
| 654 |
+
effects.consume(code)
|
| 655 |
+
return continuationRawTagOpen
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
if (code === codes.greaterThan && marker === constants.htmlDeclaration) {
|
| 659 |
+
effects.consume(code)
|
| 660 |
+
return continuationClose
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
if (code === codes.questionMark && marker === constants.htmlInstruction) {
|
| 664 |
+
effects.consume(code)
|
| 665 |
+
return continuationDeclarationInside
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
if (code === codes.rightSquareBracket && marker === constants.htmlCdata) {
|
| 669 |
+
effects.consume(code)
|
| 670 |
+
return continuationCdataInside
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
if (
|
| 674 |
+
markdownLineEnding(code) &&
|
| 675 |
+
(marker === constants.htmlBasic || marker === constants.htmlComplete)
|
| 676 |
+
) {
|
| 677 |
+
effects.exit(types.htmlFlowData)
|
| 678 |
+
return effects.check(
|
| 679 |
+
blankLineBefore,
|
| 680 |
+
continuationAfter,
|
| 681 |
+
continuationStart
|
| 682 |
+
)(code)
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 686 |
+
effects.exit(types.htmlFlowData)
|
| 687 |
+
return continuationStart(code)
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
effects.consume(code)
|
| 691 |
+
return continuation
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
/**
|
| 695 |
+
* In continuation, at eol.
|
| 696 |
+
*
|
| 697 |
+
* ```markdown
|
| 698 |
+
* > | <x>
|
| 699 |
+
* ^
|
| 700 |
+
* | asd
|
| 701 |
+
* ```
|
| 702 |
+
*
|
| 703 |
+
* @type {State}
|
| 704 |
+
*/
|
| 705 |
+
function continuationStart(code) {
|
| 706 |
+
return effects.check(
|
| 707 |
+
nonLazyContinuationStart,
|
| 708 |
+
continuationStartNonLazy,
|
| 709 |
+
continuationAfter
|
| 710 |
+
)(code)
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
/**
|
| 714 |
+
* In continuation, at eol, before non-lazy content.
|
| 715 |
+
*
|
| 716 |
+
* ```markdown
|
| 717 |
+
* > | <x>
|
| 718 |
+
* ^
|
| 719 |
+
* | asd
|
| 720 |
+
* ```
|
| 721 |
+
*
|
| 722 |
+
* @type {State}
|
| 723 |
+
*/
|
| 724 |
+
function continuationStartNonLazy(code) {
|
| 725 |
+
assert(markdownLineEnding(code))
|
| 726 |
+
effects.enter(types.lineEnding)
|
| 727 |
+
effects.consume(code)
|
| 728 |
+
effects.exit(types.lineEnding)
|
| 729 |
+
return continuationBefore
|
| 730 |
+
}
|
| 731 |
+
|
| 732 |
+
/**
|
| 733 |
+
* In continuation, before non-lazy content.
|
| 734 |
+
*
|
| 735 |
+
* ```markdown
|
| 736 |
+
* | <x>
|
| 737 |
+
* > | asd
|
| 738 |
+
* ^
|
| 739 |
+
* ```
|
| 740 |
+
*
|
| 741 |
+
* @type {State}
|
| 742 |
+
*/
|
| 743 |
+
function continuationBefore(code) {
|
| 744 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 745 |
+
return continuationStart(code)
|
| 746 |
+
}
|
| 747 |
+
|
| 748 |
+
effects.enter(types.htmlFlowData)
|
| 749 |
+
return continuation(code)
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
/**
|
| 753 |
+
* In comment continuation, after one `-`, expecting another.
|
| 754 |
+
*
|
| 755 |
+
* ```markdown
|
| 756 |
+
* > | <!--xxx-->
|
| 757 |
+
* ^
|
| 758 |
+
* ```
|
| 759 |
+
*
|
| 760 |
+
* @type {State}
|
| 761 |
+
*/
|
| 762 |
+
function continuationCommentInside(code) {
|
| 763 |
+
if (code === codes.dash) {
|
| 764 |
+
effects.consume(code)
|
| 765 |
+
return continuationDeclarationInside
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
return continuation(code)
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
/**
|
| 772 |
+
* In raw continuation, after `<`, at `/`.
|
| 773 |
+
*
|
| 774 |
+
* ```markdown
|
| 775 |
+
* > | <script>console.log(1)</script>
|
| 776 |
+
* ^
|
| 777 |
+
* ```
|
| 778 |
+
*
|
| 779 |
+
* @type {State}
|
| 780 |
+
*/
|
| 781 |
+
function continuationRawTagOpen(code) {
|
| 782 |
+
if (code === codes.slash) {
|
| 783 |
+
effects.consume(code)
|
| 784 |
+
buffer = ''
|
| 785 |
+
return continuationRawEndTag
|
| 786 |
+
}
|
| 787 |
+
|
| 788 |
+
return continuation(code)
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
/**
|
| 792 |
+
* In raw continuation, after `</`, in a raw tag name.
|
| 793 |
+
*
|
| 794 |
+
* ```markdown
|
| 795 |
+
* > | <script>console.log(1)</script>
|
| 796 |
+
* ^^^^^^
|
| 797 |
+
* ```
|
| 798 |
+
*
|
| 799 |
+
* @type {State}
|
| 800 |
+
*/
|
| 801 |
+
function continuationRawEndTag(code) {
|
| 802 |
+
if (code === codes.greaterThan) {
|
| 803 |
+
const name = buffer.toLowerCase()
|
| 804 |
+
|
| 805 |
+
if (htmlRawNames.includes(name)) {
|
| 806 |
+
effects.consume(code)
|
| 807 |
+
return continuationClose
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
return continuation(code)
|
| 811 |
+
}
|
| 812 |
+
|
| 813 |
+
if (asciiAlpha(code) && buffer.length < constants.htmlRawSizeMax) {
|
| 814 |
+
assert(code !== null) // Always the case.
|
| 815 |
+
effects.consume(code)
|
| 816 |
+
buffer += String.fromCharCode(code)
|
| 817 |
+
return continuationRawEndTag
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
return continuation(code)
|
| 821 |
+
}
|
| 822 |
+
|
| 823 |
+
/**
|
| 824 |
+
* In cdata continuation, after `]`, expecting `]>`.
|
| 825 |
+
*
|
| 826 |
+
* ```markdown
|
| 827 |
+
* > | <![CDATA[>&<]]>
|
| 828 |
+
* ^
|
| 829 |
+
* ```
|
| 830 |
+
*
|
| 831 |
+
* @type {State}
|
| 832 |
+
*/
|
| 833 |
+
function continuationCdataInside(code) {
|
| 834 |
+
if (code === codes.rightSquareBracket) {
|
| 835 |
+
effects.consume(code)
|
| 836 |
+
return continuationDeclarationInside
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
return continuation(code)
|
| 840 |
+
}
|
| 841 |
+
|
| 842 |
+
/**
|
| 843 |
+
* In declaration or instruction continuation, at `>`.
|
| 844 |
+
*
|
| 845 |
+
* ```markdown
|
| 846 |
+
* > | <!-->
|
| 847 |
+
* ^
|
| 848 |
+
* > | <?>
|
| 849 |
+
* ^
|
| 850 |
+
* > | <!q>
|
| 851 |
+
* ^
|
| 852 |
+
* > | <!--ab-->
|
| 853 |
+
* ^
|
| 854 |
+
* > | <![CDATA[>&<]]>
|
| 855 |
+
* ^
|
| 856 |
+
* ```
|
| 857 |
+
*
|
| 858 |
+
* @type {State}
|
| 859 |
+
*/
|
| 860 |
+
function continuationDeclarationInside(code) {
|
| 861 |
+
if (code === codes.greaterThan) {
|
| 862 |
+
effects.consume(code)
|
| 863 |
+
return continuationClose
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
// More dashes.
|
| 867 |
+
if (code === codes.dash && marker === constants.htmlComment) {
|
| 868 |
+
effects.consume(code)
|
| 869 |
+
return continuationDeclarationInside
|
| 870 |
+
}
|
| 871 |
+
|
| 872 |
+
return continuation(code)
|
| 873 |
+
}
|
| 874 |
+
|
| 875 |
+
/**
|
| 876 |
+
* In closed continuation: everything we get until the eol/eof is part of it.
|
| 877 |
+
*
|
| 878 |
+
* ```markdown
|
| 879 |
+
* > | <!doctype>
|
| 880 |
+
* ^
|
| 881 |
+
* ```
|
| 882 |
+
*
|
| 883 |
+
* @type {State}
|
| 884 |
+
*/
|
| 885 |
+
function continuationClose(code) {
|
| 886 |
+
if (code === codes.eof || markdownLineEnding(code)) {
|
| 887 |
+
effects.exit(types.htmlFlowData)
|
| 888 |
+
return continuationAfter(code)
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
+
effects.consume(code)
|
| 892 |
+
return continuationClose
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
/**
|
| 896 |
+
* Done.
|
| 897 |
+
*
|
| 898 |
+
* ```markdown
|
| 899 |
+
* > | <!doctype>
|
| 900 |
+
* ^
|
| 901 |
+
* ```
|
| 902 |
+
*
|
| 903 |
+
* @type {State}
|
| 904 |
+
*/
|
| 905 |
+
function continuationAfter(code) {
|
| 906 |
+
effects.exit(types.htmlFlow)
|
| 907 |
+
// // Feel free to interrupt.
|
| 908 |
+
// tokenizer.interrupt = false
|
| 909 |
+
// // No longer concrete.
|
| 910 |
+
// tokenizer.concrete = false
|
| 911 |
+
return ok(code)
|
| 912 |
+
}
|
| 913 |
+
}
|
| 914 |
+
|
| 915 |
+
/**
|
| 916 |
+
* @this {TokenizeContext}
|
| 917 |
+
* Context.
|
| 918 |
+
* @type {Tokenizer}
|
| 919 |
+
*/
|
| 920 |
+
function tokenizeNonLazyContinuationStart(effects, ok, nok) {
|
| 921 |
+
const self = this
|
| 922 |
+
|
| 923 |
+
return start
|
| 924 |
+
|
| 925 |
+
/**
|
| 926 |
+
* At eol, before continuation.
|
| 927 |
+
*
|
| 928 |
+
* ```markdown
|
| 929 |
+
* > | * ```js
|
| 930 |
+
* ^
|
| 931 |
+
* | b
|
| 932 |
+
* ```
|
| 933 |
+
*
|
| 934 |
+
* @type {State}
|
| 935 |
+
*/
|
| 936 |
+
function start(code) {
|
| 937 |
+
if (markdownLineEnding(code)) {
|
| 938 |
+
effects.enter(types.lineEnding)
|
| 939 |
+
effects.consume(code)
|
| 940 |
+
effects.exit(types.lineEnding)
|
| 941 |
+
return after
|
| 942 |
+
}
|
| 943 |
+
|
| 944 |
+
return nok(code)
|
| 945 |
+
}
|
| 946 |
+
|
| 947 |
+
/**
|
| 948 |
+
* A continuation.
|
| 949 |
+
*
|
| 950 |
+
* ```markdown
|
| 951 |
+
* | * ```js
|
| 952 |
+
* > | b
|
| 953 |
+
* ^
|
| 954 |
+
* ```
|
| 955 |
+
*
|
| 956 |
+
* @type {State}
|
| 957 |
+
*/
|
| 958 |
+
function after(code) {
|
| 959 |
+
return self.parser.lazy[self.now().line] ? nok(code) : ok(code)
|
| 960 |
+
}
|
| 961 |
+
}
|
| 962 |
+
|
| 963 |
+
/**
|
| 964 |
+
* @this {TokenizeContext}
|
| 965 |
+
* Context.
|
| 966 |
+
* @type {Tokenizer}
|
| 967 |
+
*/
|
| 968 |
+
function tokenizeBlankLineBefore(effects, ok, nok) {
|
| 969 |
+
return start
|
| 970 |
+
|
| 971 |
+
/**
|
| 972 |
+
* Before eol, expecting blank line.
|
| 973 |
+
*
|
| 974 |
+
* ```markdown
|
| 975 |
+
* > | <div>
|
| 976 |
+
* ^
|
| 977 |
+
* |
|
| 978 |
+
* ```
|
| 979 |
+
*
|
| 980 |
+
* @type {State}
|
| 981 |
+
*/
|
| 982 |
+
function start(code) {
|
| 983 |
+
assert(markdownLineEnding(code), 'expected a line ending')
|
| 984 |
+
effects.enter(types.lineEnding)
|
| 985 |
+
effects.consume(code)
|
| 986 |
+
effects.exit(types.lineEnding)
|
| 987 |
+
return effects.attempt(blankLine, ok, nok)
|
| 988 |
+
}
|
| 989 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/html-text.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const htmlText: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=html-text.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/html-text.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"html-text.d.ts","sourceRoot":"","sources":["html-text.js"],"names":[],"mappings":"AAqBA,wBAAwB;AACxB,uBADW,SAAS,CACkD;+BAf5D,sBAAsB"}
|
node_modules/micromark-core-commonmark/dev/lib/html-text.js
ADDED
|
@@ -0,0 +1,783 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {
|
| 3 |
+
* Code,
|
| 4 |
+
* Construct,
|
| 5 |
+
* State,
|
| 6 |
+
* TokenizeContext,
|
| 7 |
+
* Tokenizer
|
| 8 |
+
* } from 'micromark-util-types'
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
import {ok as assert} from 'devlop'
|
| 12 |
+
import {factorySpace} from 'micromark-factory-space'
|
| 13 |
+
import {
|
| 14 |
+
asciiAlphanumeric,
|
| 15 |
+
asciiAlpha,
|
| 16 |
+
markdownLineEndingOrSpace,
|
| 17 |
+
markdownLineEnding,
|
| 18 |
+
markdownSpace
|
| 19 |
+
} from 'micromark-util-character'
|
| 20 |
+
import {codes, constants, types} from 'micromark-util-symbol'
|
| 21 |
+
|
| 22 |
+
/** @type {Construct} */
|
| 23 |
+
export const htmlText = {name: 'htmlText', tokenize: tokenizeHtmlText}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* @this {TokenizeContext}
|
| 27 |
+
* Context.
|
| 28 |
+
* @type {Tokenizer}
|
| 29 |
+
*/
|
| 30 |
+
function tokenizeHtmlText(effects, ok, nok) {
|
| 31 |
+
const self = this
|
| 32 |
+
/** @type {NonNullable<Code> | undefined} */
|
| 33 |
+
let marker
|
| 34 |
+
/** @type {number} */
|
| 35 |
+
let index
|
| 36 |
+
/** @type {State} */
|
| 37 |
+
let returnState
|
| 38 |
+
|
| 39 |
+
return start
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Start of HTML (text).
|
| 43 |
+
*
|
| 44 |
+
* ```markdown
|
| 45 |
+
* > | a <b> c
|
| 46 |
+
* ^
|
| 47 |
+
* ```
|
| 48 |
+
*
|
| 49 |
+
* @type {State}
|
| 50 |
+
*/
|
| 51 |
+
function start(code) {
|
| 52 |
+
assert(code === codes.lessThan, 'expected `<`')
|
| 53 |
+
effects.enter(types.htmlText)
|
| 54 |
+
effects.enter(types.htmlTextData)
|
| 55 |
+
effects.consume(code)
|
| 56 |
+
return open
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* After `<`, at tag name or other stuff.
|
| 61 |
+
*
|
| 62 |
+
* ```markdown
|
| 63 |
+
* > | a <b> c
|
| 64 |
+
* ^
|
| 65 |
+
* > | a <!doctype> c
|
| 66 |
+
* ^
|
| 67 |
+
* > | a <!--b--> c
|
| 68 |
+
* ^
|
| 69 |
+
* ```
|
| 70 |
+
*
|
| 71 |
+
* @type {State}
|
| 72 |
+
*/
|
| 73 |
+
function open(code) {
|
| 74 |
+
if (code === codes.exclamationMark) {
|
| 75 |
+
effects.consume(code)
|
| 76 |
+
return declarationOpen
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
if (code === codes.slash) {
|
| 80 |
+
effects.consume(code)
|
| 81 |
+
return tagCloseStart
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if (code === codes.questionMark) {
|
| 85 |
+
effects.consume(code)
|
| 86 |
+
return instruction
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// ASCII alphabetical.
|
| 90 |
+
if (asciiAlpha(code)) {
|
| 91 |
+
effects.consume(code)
|
| 92 |
+
return tagOpen
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
return nok(code)
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* After `<!`, at declaration, comment, or CDATA.
|
| 100 |
+
*
|
| 101 |
+
* ```markdown
|
| 102 |
+
* > | a <!doctype> c
|
| 103 |
+
* ^
|
| 104 |
+
* > | a <!--b--> c
|
| 105 |
+
* ^
|
| 106 |
+
* > | a <![CDATA[>&<]]> c
|
| 107 |
+
* ^
|
| 108 |
+
* ```
|
| 109 |
+
*
|
| 110 |
+
* @type {State}
|
| 111 |
+
*/
|
| 112 |
+
function declarationOpen(code) {
|
| 113 |
+
if (code === codes.dash) {
|
| 114 |
+
effects.consume(code)
|
| 115 |
+
return commentOpenInside
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
if (code === codes.leftSquareBracket) {
|
| 119 |
+
effects.consume(code)
|
| 120 |
+
index = 0
|
| 121 |
+
return cdataOpenInside
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if (asciiAlpha(code)) {
|
| 125 |
+
effects.consume(code)
|
| 126 |
+
return declaration
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
return nok(code)
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/**
|
| 133 |
+
* In a comment, after `<!-`, at another `-`.
|
| 134 |
+
*
|
| 135 |
+
* ```markdown
|
| 136 |
+
* > | a <!--b--> c
|
| 137 |
+
* ^
|
| 138 |
+
* ```
|
| 139 |
+
*
|
| 140 |
+
* @type {State}
|
| 141 |
+
*/
|
| 142 |
+
function commentOpenInside(code) {
|
| 143 |
+
if (code === codes.dash) {
|
| 144 |
+
effects.consume(code)
|
| 145 |
+
return commentEnd
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
return nok(code)
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* In comment.
|
| 153 |
+
*
|
| 154 |
+
* ```markdown
|
| 155 |
+
* > | a <!--b--> c
|
| 156 |
+
* ^
|
| 157 |
+
* ```
|
| 158 |
+
*
|
| 159 |
+
* @type {State}
|
| 160 |
+
*/
|
| 161 |
+
function comment(code) {
|
| 162 |
+
if (code === codes.eof) {
|
| 163 |
+
return nok(code)
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
if (code === codes.dash) {
|
| 167 |
+
effects.consume(code)
|
| 168 |
+
return commentClose
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
if (markdownLineEnding(code)) {
|
| 172 |
+
returnState = comment
|
| 173 |
+
return lineEndingBefore(code)
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
effects.consume(code)
|
| 177 |
+
return comment
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* In comment, after `-`.
|
| 182 |
+
*
|
| 183 |
+
* ```markdown
|
| 184 |
+
* > | a <!--b--> c
|
| 185 |
+
* ^
|
| 186 |
+
* ```
|
| 187 |
+
*
|
| 188 |
+
* @type {State}
|
| 189 |
+
*/
|
| 190 |
+
function commentClose(code) {
|
| 191 |
+
if (code === codes.dash) {
|
| 192 |
+
effects.consume(code)
|
| 193 |
+
return commentEnd
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
return comment(code)
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* In comment, after `--`.
|
| 201 |
+
*
|
| 202 |
+
* ```markdown
|
| 203 |
+
* > | a <!--b--> c
|
| 204 |
+
* ^
|
| 205 |
+
* ```
|
| 206 |
+
*
|
| 207 |
+
* @type {State}
|
| 208 |
+
*/
|
| 209 |
+
function commentEnd(code) {
|
| 210 |
+
return code === codes.greaterThan
|
| 211 |
+
? end(code)
|
| 212 |
+
: code === codes.dash
|
| 213 |
+
? commentClose(code)
|
| 214 |
+
: comment(code)
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* After `<![`, in CDATA, expecting `CDATA[`.
|
| 219 |
+
*
|
| 220 |
+
* ```markdown
|
| 221 |
+
* > | a <![CDATA[>&<]]> b
|
| 222 |
+
* ^^^^^^
|
| 223 |
+
* ```
|
| 224 |
+
*
|
| 225 |
+
* @type {State}
|
| 226 |
+
*/
|
| 227 |
+
function cdataOpenInside(code) {
|
| 228 |
+
const value = constants.cdataOpeningString
|
| 229 |
+
|
| 230 |
+
if (code === value.charCodeAt(index++)) {
|
| 231 |
+
effects.consume(code)
|
| 232 |
+
return index === value.length ? cdata : cdataOpenInside
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
return nok(code)
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* In CDATA.
|
| 240 |
+
*
|
| 241 |
+
* ```markdown
|
| 242 |
+
* > | a <![CDATA[>&<]]> b
|
| 243 |
+
* ^^^
|
| 244 |
+
* ```
|
| 245 |
+
*
|
| 246 |
+
* @type {State}
|
| 247 |
+
*/
|
| 248 |
+
function cdata(code) {
|
| 249 |
+
if (code === codes.eof) {
|
| 250 |
+
return nok(code)
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
if (code === codes.rightSquareBracket) {
|
| 254 |
+
effects.consume(code)
|
| 255 |
+
return cdataClose
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
if (markdownLineEnding(code)) {
|
| 259 |
+
returnState = cdata
|
| 260 |
+
return lineEndingBefore(code)
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
effects.consume(code)
|
| 264 |
+
return cdata
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/**
|
| 268 |
+
* In CDATA, after `]`, at another `]`.
|
| 269 |
+
*
|
| 270 |
+
* ```markdown
|
| 271 |
+
* > | a <![CDATA[>&<]]> b
|
| 272 |
+
* ^
|
| 273 |
+
* ```
|
| 274 |
+
*
|
| 275 |
+
* @type {State}
|
| 276 |
+
*/
|
| 277 |
+
function cdataClose(code) {
|
| 278 |
+
if (code === codes.rightSquareBracket) {
|
| 279 |
+
effects.consume(code)
|
| 280 |
+
return cdataEnd
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
return cdata(code)
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/**
|
| 287 |
+
* In CDATA, after `]]`, at `>`.
|
| 288 |
+
*
|
| 289 |
+
* ```markdown
|
| 290 |
+
* > | a <![CDATA[>&<]]> b
|
| 291 |
+
* ^
|
| 292 |
+
* ```
|
| 293 |
+
*
|
| 294 |
+
* @type {State}
|
| 295 |
+
*/
|
| 296 |
+
function cdataEnd(code) {
|
| 297 |
+
if (code === codes.greaterThan) {
|
| 298 |
+
return end(code)
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
if (code === codes.rightSquareBracket) {
|
| 302 |
+
effects.consume(code)
|
| 303 |
+
return cdataEnd
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
return cdata(code)
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
/**
|
| 310 |
+
* In declaration.
|
| 311 |
+
*
|
| 312 |
+
* ```markdown
|
| 313 |
+
* > | a <!b> c
|
| 314 |
+
* ^
|
| 315 |
+
* ```
|
| 316 |
+
*
|
| 317 |
+
* @type {State}
|
| 318 |
+
*/
|
| 319 |
+
function declaration(code) {
|
| 320 |
+
if (code === codes.eof || code === codes.greaterThan) {
|
| 321 |
+
return end(code)
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
if (markdownLineEnding(code)) {
|
| 325 |
+
returnState = declaration
|
| 326 |
+
return lineEndingBefore(code)
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
effects.consume(code)
|
| 330 |
+
return declaration
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
/**
|
| 334 |
+
* In instruction.
|
| 335 |
+
*
|
| 336 |
+
* ```markdown
|
| 337 |
+
* > | a <?b?> c
|
| 338 |
+
* ^
|
| 339 |
+
* ```
|
| 340 |
+
*
|
| 341 |
+
* @type {State}
|
| 342 |
+
*/
|
| 343 |
+
function instruction(code) {
|
| 344 |
+
if (code === codes.eof) {
|
| 345 |
+
return nok(code)
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
if (code === codes.questionMark) {
|
| 349 |
+
effects.consume(code)
|
| 350 |
+
return instructionClose
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
if (markdownLineEnding(code)) {
|
| 354 |
+
returnState = instruction
|
| 355 |
+
return lineEndingBefore(code)
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
effects.consume(code)
|
| 359 |
+
return instruction
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
/**
|
| 363 |
+
* In instruction, after `?`, at `>`.
|
| 364 |
+
*
|
| 365 |
+
* ```markdown
|
| 366 |
+
* > | a <?b?> c
|
| 367 |
+
* ^
|
| 368 |
+
* ```
|
| 369 |
+
*
|
| 370 |
+
* @type {State}
|
| 371 |
+
*/
|
| 372 |
+
function instructionClose(code) {
|
| 373 |
+
return code === codes.greaterThan ? end(code) : instruction(code)
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
/**
|
| 377 |
+
* After `</`, in closing tag, at tag name.
|
| 378 |
+
*
|
| 379 |
+
* ```markdown
|
| 380 |
+
* > | a </b> c
|
| 381 |
+
* ^
|
| 382 |
+
* ```
|
| 383 |
+
*
|
| 384 |
+
* @type {State}
|
| 385 |
+
*/
|
| 386 |
+
function tagCloseStart(code) {
|
| 387 |
+
// ASCII alphabetical.
|
| 388 |
+
if (asciiAlpha(code)) {
|
| 389 |
+
effects.consume(code)
|
| 390 |
+
return tagClose
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
return nok(code)
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
/**
|
| 397 |
+
* After `</x`, in a tag name.
|
| 398 |
+
*
|
| 399 |
+
* ```markdown
|
| 400 |
+
* > | a </b> c
|
| 401 |
+
* ^
|
| 402 |
+
* ```
|
| 403 |
+
*
|
| 404 |
+
* @type {State}
|
| 405 |
+
*/
|
| 406 |
+
function tagClose(code) {
|
| 407 |
+
// ASCII alphanumerical and `-`.
|
| 408 |
+
if (code === codes.dash || asciiAlphanumeric(code)) {
|
| 409 |
+
effects.consume(code)
|
| 410 |
+
return tagClose
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
return tagCloseBetween(code)
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/**
|
| 417 |
+
* In closing tag, after tag name.
|
| 418 |
+
*
|
| 419 |
+
* ```markdown
|
| 420 |
+
* > | a </b> c
|
| 421 |
+
* ^
|
| 422 |
+
* ```
|
| 423 |
+
*
|
| 424 |
+
* @type {State}
|
| 425 |
+
*/
|
| 426 |
+
function tagCloseBetween(code) {
|
| 427 |
+
if (markdownLineEnding(code)) {
|
| 428 |
+
returnState = tagCloseBetween
|
| 429 |
+
return lineEndingBefore(code)
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
if (markdownSpace(code)) {
|
| 433 |
+
effects.consume(code)
|
| 434 |
+
return tagCloseBetween
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
return end(code)
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
/**
|
| 441 |
+
* After `<x`, in opening tag name.
|
| 442 |
+
*
|
| 443 |
+
* ```markdown
|
| 444 |
+
* > | a <b> c
|
| 445 |
+
* ^
|
| 446 |
+
* ```
|
| 447 |
+
*
|
| 448 |
+
* @type {State}
|
| 449 |
+
*/
|
| 450 |
+
function tagOpen(code) {
|
| 451 |
+
// ASCII alphanumerical and `-`.
|
| 452 |
+
if (code === codes.dash || asciiAlphanumeric(code)) {
|
| 453 |
+
effects.consume(code)
|
| 454 |
+
return tagOpen
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
if (
|
| 458 |
+
code === codes.slash ||
|
| 459 |
+
code === codes.greaterThan ||
|
| 460 |
+
markdownLineEndingOrSpace(code)
|
| 461 |
+
) {
|
| 462 |
+
return tagOpenBetween(code)
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
return nok(code)
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
/**
|
| 469 |
+
* In opening tag, after tag name.
|
| 470 |
+
*
|
| 471 |
+
* ```markdown
|
| 472 |
+
* > | a <b> c
|
| 473 |
+
* ^
|
| 474 |
+
* ```
|
| 475 |
+
*
|
| 476 |
+
* @type {State}
|
| 477 |
+
*/
|
| 478 |
+
function tagOpenBetween(code) {
|
| 479 |
+
if (code === codes.slash) {
|
| 480 |
+
effects.consume(code)
|
| 481 |
+
return end
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
// ASCII alphabetical and `:` and `_`.
|
| 485 |
+
if (code === codes.colon || code === codes.underscore || asciiAlpha(code)) {
|
| 486 |
+
effects.consume(code)
|
| 487 |
+
return tagOpenAttributeName
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
if (markdownLineEnding(code)) {
|
| 491 |
+
returnState = tagOpenBetween
|
| 492 |
+
return lineEndingBefore(code)
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
if (markdownSpace(code)) {
|
| 496 |
+
effects.consume(code)
|
| 497 |
+
return tagOpenBetween
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
return end(code)
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
* In attribute name.
|
| 505 |
+
*
|
| 506 |
+
* ```markdown
|
| 507 |
+
* > | a <b c> d
|
| 508 |
+
* ^
|
| 509 |
+
* ```
|
| 510 |
+
*
|
| 511 |
+
* @type {State}
|
| 512 |
+
*/
|
| 513 |
+
function tagOpenAttributeName(code) {
|
| 514 |
+
// ASCII alphabetical and `-`, `.`, `:`, and `_`.
|
| 515 |
+
if (
|
| 516 |
+
code === codes.dash ||
|
| 517 |
+
code === codes.dot ||
|
| 518 |
+
code === codes.colon ||
|
| 519 |
+
code === codes.underscore ||
|
| 520 |
+
asciiAlphanumeric(code)
|
| 521 |
+
) {
|
| 522 |
+
effects.consume(code)
|
| 523 |
+
return tagOpenAttributeName
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
return tagOpenAttributeNameAfter(code)
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
/**
|
| 530 |
+
* After attribute name, before initializer, the end of the tag, or
|
| 531 |
+
* whitespace.
|
| 532 |
+
*
|
| 533 |
+
* ```markdown
|
| 534 |
+
* > | a <b c> d
|
| 535 |
+
* ^
|
| 536 |
+
* ```
|
| 537 |
+
*
|
| 538 |
+
* @type {State}
|
| 539 |
+
*/
|
| 540 |
+
function tagOpenAttributeNameAfter(code) {
|
| 541 |
+
if (code === codes.equalsTo) {
|
| 542 |
+
effects.consume(code)
|
| 543 |
+
return tagOpenAttributeValueBefore
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
if (markdownLineEnding(code)) {
|
| 547 |
+
returnState = tagOpenAttributeNameAfter
|
| 548 |
+
return lineEndingBefore(code)
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
if (markdownSpace(code)) {
|
| 552 |
+
effects.consume(code)
|
| 553 |
+
return tagOpenAttributeNameAfter
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
return tagOpenBetween(code)
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
/**
|
| 560 |
+
* Before unquoted, double quoted, or single quoted attribute value, allowing
|
| 561 |
+
* whitespace.
|
| 562 |
+
*
|
| 563 |
+
* ```markdown
|
| 564 |
+
* > | a <b c=d> e
|
| 565 |
+
* ^
|
| 566 |
+
* ```
|
| 567 |
+
*
|
| 568 |
+
* @type {State}
|
| 569 |
+
*/
|
| 570 |
+
function tagOpenAttributeValueBefore(code) {
|
| 571 |
+
if (
|
| 572 |
+
code === codes.eof ||
|
| 573 |
+
code === codes.lessThan ||
|
| 574 |
+
code === codes.equalsTo ||
|
| 575 |
+
code === codes.greaterThan ||
|
| 576 |
+
code === codes.graveAccent
|
| 577 |
+
) {
|
| 578 |
+
return nok(code)
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
if (code === codes.quotationMark || code === codes.apostrophe) {
|
| 582 |
+
effects.consume(code)
|
| 583 |
+
marker = code
|
| 584 |
+
return tagOpenAttributeValueQuoted
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
if (markdownLineEnding(code)) {
|
| 588 |
+
returnState = tagOpenAttributeValueBefore
|
| 589 |
+
return lineEndingBefore(code)
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
if (markdownSpace(code)) {
|
| 593 |
+
effects.consume(code)
|
| 594 |
+
return tagOpenAttributeValueBefore
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
effects.consume(code)
|
| 598 |
+
return tagOpenAttributeValueUnquoted
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
/**
|
| 602 |
+
* In double or single quoted attribute value.
|
| 603 |
+
*
|
| 604 |
+
* ```markdown
|
| 605 |
+
* > | a <b c="d"> e
|
| 606 |
+
* ^
|
| 607 |
+
* ```
|
| 608 |
+
*
|
| 609 |
+
* @type {State}
|
| 610 |
+
*/
|
| 611 |
+
function tagOpenAttributeValueQuoted(code) {
|
| 612 |
+
if (code === marker) {
|
| 613 |
+
effects.consume(code)
|
| 614 |
+
marker = undefined
|
| 615 |
+
return tagOpenAttributeValueQuotedAfter
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
if (code === codes.eof) {
|
| 619 |
+
return nok(code)
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
if (markdownLineEnding(code)) {
|
| 623 |
+
returnState = tagOpenAttributeValueQuoted
|
| 624 |
+
return lineEndingBefore(code)
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
effects.consume(code)
|
| 628 |
+
return tagOpenAttributeValueQuoted
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
/**
|
| 632 |
+
* In unquoted attribute value.
|
| 633 |
+
*
|
| 634 |
+
* ```markdown
|
| 635 |
+
* > | a <b c=d> e
|
| 636 |
+
* ^
|
| 637 |
+
* ```
|
| 638 |
+
*
|
| 639 |
+
* @type {State}
|
| 640 |
+
*/
|
| 641 |
+
function tagOpenAttributeValueUnquoted(code) {
|
| 642 |
+
if (
|
| 643 |
+
code === codes.eof ||
|
| 644 |
+
code === codes.quotationMark ||
|
| 645 |
+
code === codes.apostrophe ||
|
| 646 |
+
code === codes.lessThan ||
|
| 647 |
+
code === codes.equalsTo ||
|
| 648 |
+
code === codes.graveAccent
|
| 649 |
+
) {
|
| 650 |
+
return nok(code)
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
if (
|
| 654 |
+
code === codes.slash ||
|
| 655 |
+
code === codes.greaterThan ||
|
| 656 |
+
markdownLineEndingOrSpace(code)
|
| 657 |
+
) {
|
| 658 |
+
return tagOpenBetween(code)
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
effects.consume(code)
|
| 662 |
+
return tagOpenAttributeValueUnquoted
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
/**
|
| 666 |
+
* After double or single quoted attribute value, before whitespace or the end
|
| 667 |
+
* of the tag.
|
| 668 |
+
*
|
| 669 |
+
* ```markdown
|
| 670 |
+
* > | a <b c="d"> e
|
| 671 |
+
* ^
|
| 672 |
+
* ```
|
| 673 |
+
*
|
| 674 |
+
* @type {State}
|
| 675 |
+
*/
|
| 676 |
+
function tagOpenAttributeValueQuotedAfter(code) {
|
| 677 |
+
if (
|
| 678 |
+
code === codes.slash ||
|
| 679 |
+
code === codes.greaterThan ||
|
| 680 |
+
markdownLineEndingOrSpace(code)
|
| 681 |
+
) {
|
| 682 |
+
return tagOpenBetween(code)
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
return nok(code)
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
/**
|
| 689 |
+
* In certain circumstances of a tag where only an `>` is allowed.
|
| 690 |
+
*
|
| 691 |
+
* ```markdown
|
| 692 |
+
* > | a <b c="d"> e
|
| 693 |
+
* ^
|
| 694 |
+
* ```
|
| 695 |
+
*
|
| 696 |
+
* @type {State}
|
| 697 |
+
*/
|
| 698 |
+
function end(code) {
|
| 699 |
+
if (code === codes.greaterThan) {
|
| 700 |
+
effects.consume(code)
|
| 701 |
+
effects.exit(types.htmlTextData)
|
| 702 |
+
effects.exit(types.htmlText)
|
| 703 |
+
return ok
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
+
return nok(code)
|
| 707 |
+
}
|
| 708 |
+
|
| 709 |
+
/**
|
| 710 |
+
* At eol.
|
| 711 |
+
*
|
| 712 |
+
* > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
|
| 713 |
+
* > empty tokens.
|
| 714 |
+
*
|
| 715 |
+
* ```markdown
|
| 716 |
+
* > | a <!--a
|
| 717 |
+
* ^
|
| 718 |
+
* | b-->
|
| 719 |
+
* ```
|
| 720 |
+
*
|
| 721 |
+
* @type {State}
|
| 722 |
+
*/
|
| 723 |
+
function lineEndingBefore(code) {
|
| 724 |
+
assert(returnState, 'expected return state')
|
| 725 |
+
assert(markdownLineEnding(code), 'expected eol')
|
| 726 |
+
effects.exit(types.htmlTextData)
|
| 727 |
+
effects.enter(types.lineEnding)
|
| 728 |
+
effects.consume(code)
|
| 729 |
+
effects.exit(types.lineEnding)
|
| 730 |
+
return lineEndingAfter
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
/**
|
| 734 |
+
* After eol, at optional whitespace.
|
| 735 |
+
*
|
| 736 |
+
* > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
|
| 737 |
+
* > empty tokens.
|
| 738 |
+
*
|
| 739 |
+
* ```markdown
|
| 740 |
+
* | a <!--a
|
| 741 |
+
* > | b-->
|
| 742 |
+
* ^
|
| 743 |
+
* ```
|
| 744 |
+
*
|
| 745 |
+
* @type {State}
|
| 746 |
+
*/
|
| 747 |
+
function lineEndingAfter(code) {
|
| 748 |
+
// Always populated by defaults.
|
| 749 |
+
assert(
|
| 750 |
+
self.parser.constructs.disable.null,
|
| 751 |
+
'expected `disable.null` to be populated'
|
| 752 |
+
)
|
| 753 |
+
return markdownSpace(code)
|
| 754 |
+
? factorySpace(
|
| 755 |
+
effects,
|
| 756 |
+
lineEndingAfterPrefix,
|
| 757 |
+
types.linePrefix,
|
| 758 |
+
self.parser.constructs.disable.null.includes('codeIndented')
|
| 759 |
+
? undefined
|
| 760 |
+
: constants.tabSize
|
| 761 |
+
)(code)
|
| 762 |
+
: lineEndingAfterPrefix(code)
|
| 763 |
+
}
|
| 764 |
+
|
| 765 |
+
/**
|
| 766 |
+
* After eol, after optional whitespace.
|
| 767 |
+
*
|
| 768 |
+
* > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
|
| 769 |
+
* > empty tokens.
|
| 770 |
+
*
|
| 771 |
+
* ```markdown
|
| 772 |
+
* | a <!--a
|
| 773 |
+
* > | b-->
|
| 774 |
+
* ^
|
| 775 |
+
* ```
|
| 776 |
+
*
|
| 777 |
+
* @type {State}
|
| 778 |
+
*/
|
| 779 |
+
function lineEndingAfterPrefix(code) {
|
| 780 |
+
effects.enter(types.htmlTextData)
|
| 781 |
+
return returnState(code)
|
| 782 |
+
}
|
| 783 |
+
}
|
node_modules/micromark-core-commonmark/dev/lib/label-end.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Construct} */
|
| 2 |
+
export const labelEnd: Construct;
|
| 3 |
+
import type { Construct } from 'micromark-util-types';
|
| 4 |
+
//# sourceMappingURL=label-end.d.ts.map
|
node_modules/micromark-core-commonmark/dev/lib/label-end.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"label-end.d.ts","sourceRoot":"","sources":["label-end.js"],"names":[],"mappings":"AAuBA,wBAAwB;AACxB,uBADW,SAAS,CAMnB;+BApBS,sBAAsB"}
|