Files
react-native-devtools-frontend/node_modules/micromark/lib/tokenize/content.js
T
Tim van der Lippe efb716af67 Update linter packages
- Updates stylelint to 13.8.0
- Updates ESLint to 7.14.0
- Updates @typescript-eslint to 4.9.0

DISABLE_THIRD_PARTY_CHECK=NPM update
R=jacktfranklin@chromium.org

Change-Id: I207e204607ede782710e042c17d6510c7f696905
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2566806
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
2020-12-01 16:04:40 +00:00

103 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
exports.tokenize = tokenizeContent
exports.resolve = resolveContent
exports.interruptible = true
exports.lazy = true
var assert = require('assert')
var codes = require('../character/codes')
var markdownLineEnding = require('../character/markdown-line-ending')
var constants = require('../constant/constants')
var types = require('../constant/types')
var subtokenize = require('../util/subtokenize')
var prefixSize = require('../util/prefix-size')
var createSpace = require('./factory-space')
var lookaheadConstruct = {tokenize: tokenizeLookaheadConstruct, partial: true}
// Content is transparent: it’s parsed right now. That way, definitions are also
// parsed right now: before text in paragraphs (specifically, media) are parsed.
function resolveContent(events) {
subtokenize(events)
return events
}
function tokenizeContent(effects, ok) {
var previous
return start
function start(code) {
assert(
code !== codes.eof && !markdownLineEnding(code),
'expected no eof or eol'
)
effects.enter(types.content)
previous = effects.enter(types.chunkContent, {
contentType: constants.contentTypeContent
})
return data(code)
}
function data(code) {
if (code === codes.eof) {
return contentEnd(code)
}
if (markdownLineEnding(code)) {
return effects.check(
lookaheadConstruct,
contentContinue,
contentEnd
)(code)
}
// Data.
effects.consume(code)
return data
}
function contentEnd(code) {
effects.exit(types.chunkContent)
effects.exit(types.content)
return ok(code)
}
function contentContinue(code) {
assert(markdownLineEnding(code), 'expected eol')
effects.consume(code)
effects.exit(types.chunkContent)
previous = previous.next = effects.enter(types.chunkContent, {
contentType: constants.contentTypeContent,
previous: previous
})
return data
}
}
function tokenizeLookaheadConstruct(effects, ok, nok) {
var self = this
return startLookahead
function startLookahead(code) {
assert(markdownLineEnding(code), 'expected a line ending')
effects.enter(types.lineEnding)
effects.consume(code)
effects.exit(types.lineEnding)
return createSpace(effects, prefixed, types.linePrefix)
}
function prefixed(code) {
if (code === codes.eof || markdownLineEnding(code)) {
return nok(code)
}
if (prefixSize(self.events, types.linePrefix) < constants.tabSize) {
return effects.interrupt(self.parser.constructs.flow, nok, ok)(code)
}
return ok(code)
}
}