This commit is contained in:
91
node_modules/micromark/lib/initialize/content.js
generated
vendored
Normal file
91
node_modules/micromark/lib/initialize/content.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
'use strict'
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {value: true})
|
||||
|
||||
var assert = require('assert')
|
||||
var codes = require('../character/codes.js')
|
||||
var markdownLineEnding = require('../character/markdown-line-ending.js')
|
||||
var constants = require('../constant/constants.js')
|
||||
var types = require('../constant/types.js')
|
||||
var factorySpace = require('../tokenize/factory-space.js')
|
||||
|
||||
function _interopDefaultLegacy(e) {
|
||||
return e && typeof e === 'object' && 'default' in e ? e : {default: e}
|
||||
}
|
||||
|
||||
var assert__default = /*#__PURE__*/ _interopDefaultLegacy(assert)
|
||||
|
||||
var tokenize = initializeContent
|
||||
|
||||
function initializeContent(effects) {
|
||||
var contentStart = effects.attempt(
|
||||
this.parser.constructs.contentInitial,
|
||||
afterContentStartConstruct,
|
||||
paragraphInitial
|
||||
)
|
||||
var previous
|
||||
|
||||
return contentStart
|
||||
|
||||
function afterContentStartConstruct(code) {
|
||||
assert__default['default'](
|
||||
code === codes.eof || markdownLineEnding(code),
|
||||
'expected eol or eof'
|
||||
)
|
||||
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.lineEnding)
|
||||
effects.consume(code)
|
||||
effects.exit(types.lineEnding)
|
||||
return factorySpace(effects, contentStart, types.linePrefix)
|
||||
}
|
||||
|
||||
function paragraphInitial(code) {
|
||||
assert__default['default'](
|
||||
code !== codes.eof && !markdownLineEnding(code),
|
||||
'expected anything other than a line ending or EOF'
|
||||
)
|
||||
effects.enter(types.paragraph)
|
||||
return lineStart(code)
|
||||
}
|
||||
|
||||
function lineStart(code) {
|
||||
var token = effects.enter(types.chunkText, {
|
||||
contentType: constants.contentTypeText,
|
||||
previous: previous
|
||||
})
|
||||
|
||||
if (previous) {
|
||||
previous.next = token
|
||||
}
|
||||
|
||||
previous = token
|
||||
|
||||
return data(code)
|
||||
}
|
||||
|
||||
function data(code) {
|
||||
if (code === codes.eof) {
|
||||
effects.exit(types.chunkText)
|
||||
effects.exit(types.paragraph)
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
if (markdownLineEnding(code)) {
|
||||
effects.consume(code)
|
||||
effects.exit(types.chunkText)
|
||||
return lineStart
|
||||
}
|
||||
|
||||
// Data.
|
||||
effects.consume(code)
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
exports.tokenize = tokenize
|
||||
79
node_modules/micromark/lib/initialize/content.mjs
generated
vendored
Normal file
79
node_modules/micromark/lib/initialize/content.mjs
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
export var tokenize = initializeContent
|
||||
|
||||
import assert from 'assert'
|
||||
import codes from '../character/codes.mjs'
|
||||
import markdownLineEnding from '../character/markdown-line-ending.mjs'
|
||||
import constants from '../constant/constants.mjs'
|
||||
import types from '../constant/types.mjs'
|
||||
import spaceFactory from '../tokenize/factory-space.mjs'
|
||||
|
||||
function initializeContent(effects) {
|
||||
var contentStart = effects.attempt(
|
||||
this.parser.constructs.contentInitial,
|
||||
afterContentStartConstruct,
|
||||
paragraphInitial
|
||||
)
|
||||
var previous
|
||||
|
||||
return contentStart
|
||||
|
||||
function afterContentStartConstruct(code) {
|
||||
assert(
|
||||
code === codes.eof || markdownLineEnding(code),
|
||||
'expected eol or eof'
|
||||
)
|
||||
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.lineEnding)
|
||||
effects.consume(code)
|
||||
effects.exit(types.lineEnding)
|
||||
return spaceFactory(effects, contentStart, types.linePrefix)
|
||||
}
|
||||
|
||||
function paragraphInitial(code) {
|
||||
assert(
|
||||
code !== codes.eof && !markdownLineEnding(code),
|
||||
'expected anything other than a line ending or EOF'
|
||||
)
|
||||
effects.enter(types.paragraph)
|
||||
return lineStart(code)
|
||||
}
|
||||
|
||||
function lineStart(code) {
|
||||
var token = effects.enter(types.chunkText, {
|
||||
contentType: constants.contentTypeText,
|
||||
previous: previous
|
||||
})
|
||||
|
||||
if (previous) {
|
||||
previous.next = token
|
||||
}
|
||||
|
||||
previous = token
|
||||
|
||||
return data(code)
|
||||
}
|
||||
|
||||
function data(code) {
|
||||
if (code === codes.eof) {
|
||||
effects.exit(types.chunkText)
|
||||
effects.exit(types.paragraph)
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
if (markdownLineEnding(code)) {
|
||||
effects.consume(code)
|
||||
effects.exit(types.chunkText)
|
||||
return lineStart
|
||||
}
|
||||
|
||||
// Data.
|
||||
effects.consume(code)
|
||||
return data
|
||||
}
|
||||
}
|
||||
245
node_modules/micromark/lib/initialize/document.js
generated
vendored
Normal file
245
node_modules/micromark/lib/initialize/document.js
generated
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
'use strict'
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {value: true})
|
||||
|
||||
var codes = require('../character/codes.js')
|
||||
var markdownLineEnding = require('../character/markdown-line-ending.js')
|
||||
var constants = require('../constant/constants.js')
|
||||
var types = require('../constant/types.js')
|
||||
var factorySpace = require('../tokenize/factory-space.js')
|
||||
var partialBlankLine = require('../tokenize/partial-blank-line.js')
|
||||
|
||||
var tokenize = initializeDocument
|
||||
|
||||
var containerConstruct = {tokenize: tokenizeContainer}
|
||||
var lazyFlowConstruct = {tokenize: tokenizeLazyFlow}
|
||||
|
||||
function initializeDocument(effects) {
|
||||
var self = this
|
||||
var stack = []
|
||||
var continued = 0
|
||||
var inspectConstruct = {tokenize: tokenizeInspect, partial: true}
|
||||
var inspectResult
|
||||
var childFlow
|
||||
var childToken
|
||||
|
||||
return start
|
||||
|
||||
function start(code) {
|
||||
if (continued < stack.length) {
|
||||
self.containerState = stack[continued][1]
|
||||
return effects.attempt(
|
||||
stack[continued][0].continuation,
|
||||
documentContinue,
|
||||
documentContinued
|
||||
)(code)
|
||||
}
|
||||
|
||||
return documentContinued(code)
|
||||
}
|
||||
|
||||
function documentContinue(code) {
|
||||
continued++
|
||||
return start(code)
|
||||
}
|
||||
|
||||
function documentContinued(code) {
|
||||
// If we’re in a concrete construct (such as when expecting another line of
|
||||
// HTML, or we resulted in lazy content), we can immediately start flow.
|
||||
if (inspectResult && inspectResult.flowContinue) {
|
||||
return flowStart(code)
|
||||
}
|
||||
|
||||
self.interrupt =
|
||||
childFlow &&
|
||||
childFlow.currentConstruct &&
|
||||
childFlow.currentConstruct.interruptible
|
||||
self.containerState = {}
|
||||
return effects.attempt(
|
||||
containerConstruct,
|
||||
containerContinue,
|
||||
flowStart
|
||||
)(code)
|
||||
}
|
||||
|
||||
function containerContinue(code) {
|
||||
stack.push([self.currentConstruct, self.containerState])
|
||||
self.containerState = undefined
|
||||
return documentContinued(code)
|
||||
}
|
||||
|
||||
function flowStart(code) {
|
||||
if (code === codes.eof) {
|
||||
exitContainers(0, true)
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
childFlow = childFlow || self.parser.flow(self.now())
|
||||
|
||||
effects.enter(types.chunkFlow, {
|
||||
contentType: constants.contentTypeFlow,
|
||||
previous: childToken,
|
||||
_tokenizer: childFlow
|
||||
})
|
||||
|
||||
return flowContinue(code)
|
||||
}
|
||||
|
||||
function flowContinue(code) {
|
||||
if (code === codes.eof) {
|
||||
continueFlow(effects.exit(types.chunkFlow))
|
||||
return flowStart(code)
|
||||
}
|
||||
|
||||
if (markdownLineEnding(code)) {
|
||||
effects.consume(code)
|
||||
continueFlow(effects.exit(types.chunkFlow))
|
||||
return effects.check(inspectConstruct, documentAfterPeek)
|
||||
}
|
||||
|
||||
effects.consume(code)
|
||||
return flowContinue
|
||||
}
|
||||
|
||||
function documentAfterPeek(code) {
|
||||
exitContainers(
|
||||
inspectResult.continued,
|
||||
inspectResult && inspectResult.flowEnd
|
||||
)
|
||||
continued = 0
|
||||
return start(code)
|
||||
}
|
||||
|
||||
function continueFlow(token) {
|
||||
if (childToken) childToken.next = token
|
||||
childToken = token
|
||||
childFlow.lazy = inspectResult && inspectResult.lazy
|
||||
childFlow.defineSkip(token.start)
|
||||
childFlow.write(self.sliceStream(token))
|
||||
}
|
||||
|
||||
function exitContainers(size, end) {
|
||||
var index = stack.length
|
||||
|
||||
// Close the flow.
|
||||
if (childFlow && end) {
|
||||
childFlow.write([codes.eof])
|
||||
childToken = childFlow = undefined
|
||||
}
|
||||
|
||||
// Exit open containers.
|
||||
while (index-- > size) {
|
||||
self.containerState = stack[index][1]
|
||||
stack[index][0].exit.call(self, effects)
|
||||
}
|
||||
|
||||
stack.length = size
|
||||
}
|
||||
|
||||
function tokenizeInspect(effects, ok) {
|
||||
var subcontinued = 0
|
||||
|
||||
inspectResult = {}
|
||||
|
||||
return inspectStart
|
||||
|
||||
function inspectStart(code) {
|
||||
if (subcontinued < stack.length) {
|
||||
self.containerState = stack[subcontinued][1]
|
||||
return effects.attempt(
|
||||
stack[subcontinued][0].continuation,
|
||||
inspectContinue,
|
||||
inspectLess
|
||||
)(code)
|
||||
}
|
||||
|
||||
// If we’re continued but in a concrete flow, we can’t have more
|
||||
// containers.
|
||||
if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {
|
||||
inspectResult.flowContinue = true
|
||||
return inspectDone(code)
|
||||
}
|
||||
|
||||
self.interrupt =
|
||||
childFlow.currentConstruct && childFlow.currentConstruct.interruptible
|
||||
self.containerState = {}
|
||||
return effects.attempt(
|
||||
containerConstruct,
|
||||
inspectFlowEnd,
|
||||
inspectDone
|
||||
)(code)
|
||||
}
|
||||
|
||||
function inspectContinue(code) {
|
||||
subcontinued++
|
||||
return self.containerState._closeFlow
|
||||
? inspectFlowEnd(code)
|
||||
: inspectStart(code)
|
||||
}
|
||||
|
||||
function inspectLess(code) {
|
||||
if (childFlow.currentConstruct && childFlow.currentConstruct.lazy) {
|
||||
// Maybe another container?
|
||||
self.containerState = {}
|
||||
return effects.attempt(
|
||||
containerConstruct,
|
||||
inspectFlowEnd,
|
||||
// Maybe flow, or a blank line?
|
||||
effects.attempt(
|
||||
lazyFlowConstruct,
|
||||
inspectFlowEnd,
|
||||
effects.check(partialBlankLine, inspectFlowEnd, inspectLazy)
|
||||
)
|
||||
)(code)
|
||||
}
|
||||
|
||||
// Otherwise we’re interrupting.
|
||||
return inspectFlowEnd(code)
|
||||
}
|
||||
|
||||
function inspectLazy(code) {
|
||||
// Act as if all containers are continued.
|
||||
subcontinued = stack.length
|
||||
inspectResult.lazy = true
|
||||
inspectResult.flowContinue = true
|
||||
return inspectDone(code)
|
||||
}
|
||||
|
||||
// We’re done with flow if we have more containers, or an interruption.
|
||||
function inspectFlowEnd(code) {
|
||||
inspectResult.flowEnd = true
|
||||
return inspectDone(code)
|
||||
}
|
||||
|
||||
function inspectDone(code) {
|
||||
inspectResult.continued = subcontinued
|
||||
self.interrupt = self.containerState = undefined
|
||||
return ok(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tokenizeContainer(effects, ok, nok) {
|
||||
return factorySpace(
|
||||
effects,
|
||||
effects.attempt(this.parser.constructs.document, ok, nok),
|
||||
types.linePrefix,
|
||||
this.parser.constructs.disable.null.indexOf('codeIndented') > -1
|
||||
? undefined
|
||||
: constants.tabSize
|
||||
)
|
||||
}
|
||||
|
||||
function tokenizeLazyFlow(effects, ok, nok) {
|
||||
return factorySpace(
|
||||
effects,
|
||||
effects.lazy(this.parser.constructs.flow, ok, nok),
|
||||
types.linePrefix,
|
||||
this.parser.constructs.disable.null.indexOf('codeIndented') > -1
|
||||
? undefined
|
||||
: constants.tabSize
|
||||
)
|
||||
}
|
||||
|
||||
exports.tokenize = tokenize
|
||||
239
node_modules/micromark/lib/initialize/document.mjs
generated
vendored
Normal file
239
node_modules/micromark/lib/initialize/document.mjs
generated
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
export var tokenize = initializeDocument
|
||||
|
||||
import codes from '../character/codes.mjs'
|
||||
import markdownLineEnding from '../character/markdown-line-ending.mjs'
|
||||
import constants from '../constant/constants.mjs'
|
||||
import types from '../constant/types.mjs'
|
||||
import spaceFactory from '../tokenize/factory-space.mjs'
|
||||
import blank from '../tokenize/partial-blank-line.mjs'
|
||||
|
||||
var containerConstruct = {tokenize: tokenizeContainer}
|
||||
var lazyFlowConstruct = {tokenize: tokenizeLazyFlow}
|
||||
|
||||
function initializeDocument(effects) {
|
||||
var self = this
|
||||
var stack = []
|
||||
var continued = 0
|
||||
var inspectConstruct = {tokenize: tokenizeInspect, partial: true}
|
||||
var inspectResult
|
||||
var childFlow
|
||||
var childToken
|
||||
|
||||
return start
|
||||
|
||||
function start(code) {
|
||||
if (continued < stack.length) {
|
||||
self.containerState = stack[continued][1]
|
||||
return effects.attempt(
|
||||
stack[continued][0].continuation,
|
||||
documentContinue,
|
||||
documentContinued
|
||||
)(code)
|
||||
}
|
||||
|
||||
return documentContinued(code)
|
||||
}
|
||||
|
||||
function documentContinue(code) {
|
||||
continued++
|
||||
return start(code)
|
||||
}
|
||||
|
||||
function documentContinued(code) {
|
||||
// If we’re in a concrete construct (such as when expecting another line of
|
||||
// HTML, or we resulted in lazy content), we can immediately start flow.
|
||||
if (inspectResult && inspectResult.flowContinue) {
|
||||
return flowStart(code)
|
||||
}
|
||||
|
||||
self.interrupt =
|
||||
childFlow &&
|
||||
childFlow.currentConstruct &&
|
||||
childFlow.currentConstruct.interruptible
|
||||
self.containerState = {}
|
||||
return effects.attempt(
|
||||
containerConstruct,
|
||||
containerContinue,
|
||||
flowStart
|
||||
)(code)
|
||||
}
|
||||
|
||||
function containerContinue(code) {
|
||||
stack.push([self.currentConstruct, self.containerState])
|
||||
self.containerState = undefined
|
||||
return documentContinued(code)
|
||||
}
|
||||
|
||||
function flowStart(code) {
|
||||
if (code === codes.eof) {
|
||||
exitContainers(0, true)
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
childFlow = childFlow || self.parser.flow(self.now())
|
||||
|
||||
effects.enter(types.chunkFlow, {
|
||||
contentType: constants.contentTypeFlow,
|
||||
previous: childToken,
|
||||
_tokenizer: childFlow
|
||||
})
|
||||
|
||||
return flowContinue(code)
|
||||
}
|
||||
|
||||
function flowContinue(code) {
|
||||
if (code === codes.eof) {
|
||||
continueFlow(effects.exit(types.chunkFlow))
|
||||
return flowStart(code)
|
||||
}
|
||||
|
||||
if (markdownLineEnding(code)) {
|
||||
effects.consume(code)
|
||||
continueFlow(effects.exit(types.chunkFlow))
|
||||
return effects.check(inspectConstruct, documentAfterPeek)
|
||||
}
|
||||
|
||||
effects.consume(code)
|
||||
return flowContinue
|
||||
}
|
||||
|
||||
function documentAfterPeek(code) {
|
||||
exitContainers(
|
||||
inspectResult.continued,
|
||||
inspectResult && inspectResult.flowEnd
|
||||
)
|
||||
continued = 0
|
||||
return start(code)
|
||||
}
|
||||
|
||||
function continueFlow(token) {
|
||||
if (childToken) childToken.next = token
|
||||
childToken = token
|
||||
childFlow.lazy = inspectResult && inspectResult.lazy
|
||||
childFlow.defineSkip(token.start)
|
||||
childFlow.write(self.sliceStream(token))
|
||||
}
|
||||
|
||||
function exitContainers(size, end) {
|
||||
var index = stack.length
|
||||
|
||||
// Close the flow.
|
||||
if (childFlow && end) {
|
||||
childFlow.write([codes.eof])
|
||||
childToken = childFlow = undefined
|
||||
}
|
||||
|
||||
// Exit open containers.
|
||||
while (index-- > size) {
|
||||
self.containerState = stack[index][1]
|
||||
stack[index][0].exit.call(self, effects)
|
||||
}
|
||||
|
||||
stack.length = size
|
||||
}
|
||||
|
||||
function tokenizeInspect(effects, ok) {
|
||||
var subcontinued = 0
|
||||
|
||||
inspectResult = {}
|
||||
|
||||
return inspectStart
|
||||
|
||||
function inspectStart(code) {
|
||||
if (subcontinued < stack.length) {
|
||||
self.containerState = stack[subcontinued][1]
|
||||
return effects.attempt(
|
||||
stack[subcontinued][0].continuation,
|
||||
inspectContinue,
|
||||
inspectLess
|
||||
)(code)
|
||||
}
|
||||
|
||||
// If we’re continued but in a concrete flow, we can’t have more
|
||||
// containers.
|
||||
if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {
|
||||
inspectResult.flowContinue = true
|
||||
return inspectDone(code)
|
||||
}
|
||||
|
||||
self.interrupt =
|
||||
childFlow.currentConstruct && childFlow.currentConstruct.interruptible
|
||||
self.containerState = {}
|
||||
return effects.attempt(
|
||||
containerConstruct,
|
||||
inspectFlowEnd,
|
||||
inspectDone
|
||||
)(code)
|
||||
}
|
||||
|
||||
function inspectContinue(code) {
|
||||
subcontinued++
|
||||
return self.containerState._closeFlow
|
||||
? inspectFlowEnd(code)
|
||||
: inspectStart(code)
|
||||
}
|
||||
|
||||
function inspectLess(code) {
|
||||
if (childFlow.currentConstruct && childFlow.currentConstruct.lazy) {
|
||||
// Maybe another container?
|
||||
self.containerState = {}
|
||||
return effects.attempt(
|
||||
containerConstruct,
|
||||
inspectFlowEnd,
|
||||
// Maybe flow, or a blank line?
|
||||
effects.attempt(
|
||||
lazyFlowConstruct,
|
||||
inspectFlowEnd,
|
||||
effects.check(blank, inspectFlowEnd, inspectLazy)
|
||||
)
|
||||
)(code)
|
||||
}
|
||||
|
||||
// Otherwise we’re interrupting.
|
||||
return inspectFlowEnd(code)
|
||||
}
|
||||
|
||||
function inspectLazy(code) {
|
||||
// Act as if all containers are continued.
|
||||
subcontinued = stack.length
|
||||
inspectResult.lazy = true
|
||||
inspectResult.flowContinue = true
|
||||
return inspectDone(code)
|
||||
}
|
||||
|
||||
// We’re done with flow if we have more containers, or an interruption.
|
||||
function inspectFlowEnd(code) {
|
||||
inspectResult.flowEnd = true
|
||||
return inspectDone(code)
|
||||
}
|
||||
|
||||
function inspectDone(code) {
|
||||
inspectResult.continued = subcontinued
|
||||
self.interrupt = self.containerState = undefined
|
||||
return ok(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tokenizeContainer(effects, ok, nok) {
|
||||
return spaceFactory(
|
||||
effects,
|
||||
effects.attempt(this.parser.constructs.document, ok, nok),
|
||||
types.linePrefix,
|
||||
this.parser.constructs.disable.null.indexOf('codeIndented') > -1
|
||||
? undefined
|
||||
: constants.tabSize
|
||||
)
|
||||
}
|
||||
|
||||
function tokenizeLazyFlow(effects, ok, nok) {
|
||||
return spaceFactory(
|
||||
effects,
|
||||
effects.lazy(this.parser.constructs.flow, ok, nok),
|
||||
types.linePrefix,
|
||||
this.parser.constructs.disable.null.indexOf('codeIndented') > -1
|
||||
? undefined
|
||||
: constants.tabSize
|
||||
)
|
||||
}
|
||||
82
node_modules/micromark/lib/initialize/flow.js
generated
vendored
Normal file
82
node_modules/micromark/lib/initialize/flow.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict'
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {value: true})
|
||||
|
||||
var assert = require('assert')
|
||||
var codes = require('../character/codes.js')
|
||||
var markdownLineEnding = require('../character/markdown-line-ending.js')
|
||||
var types = require('../constant/types.js')
|
||||
var content = require('../tokenize/content.js')
|
||||
var factorySpace = require('../tokenize/factory-space.js')
|
||||
var partialBlankLine = require('../tokenize/partial-blank-line.js')
|
||||
|
||||
function _interopDefaultLegacy(e) {
|
||||
return e && typeof e === 'object' && 'default' in e ? e : {default: e}
|
||||
}
|
||||
|
||||
var assert__default = /*#__PURE__*/ _interopDefaultLegacy(assert)
|
||||
|
||||
var tokenize = initializeFlow
|
||||
|
||||
function initializeFlow(effects) {
|
||||
var self = this
|
||||
var initial = effects.attempt(
|
||||
// Try to parse a blank line.
|
||||
partialBlankLine,
|
||||
atBlankEnding,
|
||||
// Try to parse initial flow (essentially, only code).
|
||||
effects.attempt(
|
||||
this.parser.constructs.flowInitial,
|
||||
afterConstruct,
|
||||
factorySpace(
|
||||
effects,
|
||||
effects.attempt(
|
||||
this.parser.constructs.flow,
|
||||
afterConstruct,
|
||||
effects.attempt(content, afterConstruct)
|
||||
),
|
||||
types.linePrefix
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return initial
|
||||
|
||||
function atBlankEnding(code) {
|
||||
assert__default['default'](
|
||||
code === codes.eof || markdownLineEnding(code),
|
||||
'expected eol or eof'
|
||||
)
|
||||
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.lineEndingBlank)
|
||||
effects.consume(code)
|
||||
effects.exit(types.lineEndingBlank)
|
||||
self.currentConstruct = undefined
|
||||
return initial
|
||||
}
|
||||
|
||||
function afterConstruct(code) {
|
||||
assert__default['default'](
|
||||
code === codes.eof || markdownLineEnding(code),
|
||||
'expected eol or eof'
|
||||
)
|
||||
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.lineEnding)
|
||||
effects.consume(code)
|
||||
effects.exit(types.lineEnding)
|
||||
self.currentConstruct = undefined
|
||||
return initial
|
||||
}
|
||||
}
|
||||
|
||||
exports.tokenize = tokenize
|
||||
70
node_modules/micromark/lib/initialize/flow.mjs
generated
vendored
Normal file
70
node_modules/micromark/lib/initialize/flow.mjs
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
export var tokenize = initializeFlow
|
||||
|
||||
import assert from 'assert'
|
||||
import codes from '../character/codes.mjs'
|
||||
import markdownLineEnding from '../character/markdown-line-ending.mjs'
|
||||
import types from '../constant/types.mjs'
|
||||
import content from '../tokenize/content.mjs'
|
||||
import spaceFactory from '../tokenize/factory-space.mjs'
|
||||
import blank from '../tokenize/partial-blank-line.mjs'
|
||||
|
||||
function initializeFlow(effects) {
|
||||
var self = this
|
||||
var initial = effects.attempt(
|
||||
// Try to parse a blank line.
|
||||
blank,
|
||||
atBlankEnding,
|
||||
// Try to parse initial flow (essentially, only code).
|
||||
effects.attempt(
|
||||
this.parser.constructs.flowInitial,
|
||||
afterConstruct,
|
||||
spaceFactory(
|
||||
effects,
|
||||
effects.attempt(
|
||||
this.parser.constructs.flow,
|
||||
afterConstruct,
|
||||
effects.attempt(content, afterConstruct)
|
||||
),
|
||||
types.linePrefix
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return initial
|
||||
|
||||
function atBlankEnding(code) {
|
||||
assert(
|
||||
code === codes.eof || markdownLineEnding(code),
|
||||
'expected eol or eof'
|
||||
)
|
||||
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.lineEndingBlank)
|
||||
effects.consume(code)
|
||||
effects.exit(types.lineEndingBlank)
|
||||
self.currentConstruct = undefined
|
||||
return initial
|
||||
}
|
||||
|
||||
function afterConstruct(code) {
|
||||
assert(
|
||||
code === codes.eof || markdownLineEnding(code),
|
||||
'expected eol or eof'
|
||||
)
|
||||
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.lineEnding)
|
||||
effects.consume(code)
|
||||
effects.exit(types.lineEnding)
|
||||
self.currentConstruct = undefined
|
||||
return initial
|
||||
}
|
||||
}
|
||||
210
node_modules/micromark/lib/initialize/text.js
generated
vendored
Normal file
210
node_modules/micromark/lib/initialize/text.js
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
'use strict'
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {value: true})
|
||||
|
||||
var codes = require('../character/codes.js')
|
||||
var assign = require('../constant/assign.js')
|
||||
var constants = require('../constant/constants.js')
|
||||
var types = require('../constant/types.js')
|
||||
var shallow = require('../util/shallow.js')
|
||||
|
||||
var text = initializeFactory('text')
|
||||
var string = initializeFactory('string')
|
||||
var resolver = {resolveAll: createResolver()}
|
||||
|
||||
function initializeFactory(field) {
|
||||
return {
|
||||
tokenize: initializeText,
|
||||
resolveAll: createResolver(
|
||||
field === 'text' ? resolveAllLineSuffixes : undefined
|
||||
)
|
||||
}
|
||||
|
||||
function initializeText(effects) {
|
||||
var self = this
|
||||
var constructs = this.parser.constructs[field]
|
||||
var text = effects.attempt(constructs, start, notText)
|
||||
|
||||
return start
|
||||
|
||||
function start(code) {
|
||||
return atBreak(code) ? text(code) : notText(code)
|
||||
}
|
||||
|
||||
function notText(code) {
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.data)
|
||||
effects.consume(code)
|
||||
return data
|
||||
}
|
||||
|
||||
function data(code) {
|
||||
if (atBreak(code)) {
|
||||
effects.exit(types.data)
|
||||
return text(code)
|
||||
}
|
||||
|
||||
// Data.
|
||||
effects.consume(code)
|
||||
return data
|
||||
}
|
||||
|
||||
function atBreak(code) {
|
||||
var list = constructs[code]
|
||||
var index = -1
|
||||
|
||||
if (code === codes.eof) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (list) {
|
||||
while (++index < list.length) {
|
||||
if (
|
||||
!list[index].previous ||
|
||||
list[index].previous.call(self, self.previous)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createResolver(extraResolver) {
|
||||
return resolveAllText
|
||||
|
||||
function resolveAllText(events, context) {
|
||||
var index = -1
|
||||
var enter
|
||||
|
||||
// A rather boring computation (to merge adjacent `data` events) which
|
||||
// improves mm performance by 29%.
|
||||
while (++index <= events.length) {
|
||||
if (enter === undefined) {
|
||||
if (events[index] && events[index][1].type === types.data) {
|
||||
enter = index
|
||||
index++
|
||||
}
|
||||
} else if (!events[index] || events[index][1].type !== types.data) {
|
||||
// Don’t do anything if there is one data token.
|
||||
if (index !== enter + 2) {
|
||||
events[enter][1].end = events[index - 1][1].end
|
||||
events.splice(enter + 2, index - enter - 2)
|
||||
index = enter + 2
|
||||
}
|
||||
|
||||
enter = undefined
|
||||
}
|
||||
}
|
||||
|
||||
return extraResolver ? extraResolver(events, context) : events
|
||||
}
|
||||
}
|
||||
|
||||
// A rather ugly set of instructions which again looks at chunks in the input
|
||||
// stream.
|
||||
// The reason to do this here is that it is *much* faster to parse in reverse.
|
||||
// And that we can’t hook into `null` to split the line suffix before an EOF.
|
||||
// To do: figure out if we can make this into a clean utility, or even in core.
|
||||
// As it will be useful for GFMs literal autolink extension (and maybe even
|
||||
// tables?)
|
||||
function resolveAllLineSuffixes(events, context) {
|
||||
var eventIndex = -1
|
||||
var chunks
|
||||
var data
|
||||
var chunk
|
||||
var index
|
||||
var bufferIndex
|
||||
var size
|
||||
var tabs
|
||||
var token
|
||||
|
||||
while (++eventIndex <= events.length) {
|
||||
if (
|
||||
(eventIndex === events.length ||
|
||||
events[eventIndex][1].type === types.lineEnding) &&
|
||||
events[eventIndex - 1][1].type === types.data
|
||||
) {
|
||||
data = events[eventIndex - 1][1]
|
||||
chunks = context.sliceStream(data)
|
||||
index = chunks.length
|
||||
bufferIndex = -1
|
||||
size = 0
|
||||
tabs = undefined
|
||||
|
||||
while (index--) {
|
||||
chunk = chunks[index]
|
||||
|
||||
if (typeof chunk === 'string') {
|
||||
bufferIndex = chunk.length
|
||||
|
||||
while (chunk.charCodeAt(bufferIndex - 1) === codes.space) {
|
||||
size++
|
||||
bufferIndex--
|
||||
}
|
||||
|
||||
if (bufferIndex) break
|
||||
bufferIndex = -1
|
||||
}
|
||||
// Number
|
||||
else if (chunk === codes.horizontalTab) {
|
||||
tabs = true
|
||||
size++
|
||||
} else if (chunk === codes.virtualSpace);
|
||||
else {
|
||||
// Replacement character, exit.
|
||||
index++
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (size) {
|
||||
token = {
|
||||
type:
|
||||
eventIndex === events.length ||
|
||||
tabs ||
|
||||
size < constants.hardBreakPrefixSizeMin
|
||||
? types.lineSuffix
|
||||
: types.hardBreakTrailing,
|
||||
start: {
|
||||
line: data.end.line,
|
||||
column: data.end.column - size,
|
||||
offset: data.end.offset - size,
|
||||
_index: data.start._index + index,
|
||||
_bufferIndex: index
|
||||
? bufferIndex
|
||||
: data.start._bufferIndex + bufferIndex
|
||||
},
|
||||
end: shallow(data.end)
|
||||
}
|
||||
|
||||
data.end = shallow(token.start)
|
||||
|
||||
if (data.start.offset === data.end.offset) {
|
||||
assign(data, token)
|
||||
} else {
|
||||
events.splice(
|
||||
eventIndex,
|
||||
0,
|
||||
['enter', token, context],
|
||||
['exit', token, context]
|
||||
)
|
||||
eventIndex += 2
|
||||
}
|
||||
}
|
||||
|
||||
eventIndex++
|
||||
}
|
||||
}
|
||||
|
||||
return events
|
||||
}
|
||||
|
||||
exports.resolver = resolver
|
||||
exports.string = string
|
||||
exports.text = text
|
||||
203
node_modules/micromark/lib/initialize/text.mjs
generated
vendored
Normal file
203
node_modules/micromark/lib/initialize/text.mjs
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
export var text = initializeFactory('text')
|
||||
export var string = initializeFactory('string')
|
||||
export var resolver = {resolveAll: createResolver()}
|
||||
|
||||
import codes from '../character/codes.mjs'
|
||||
import assign from '../constant/assign.mjs'
|
||||
import constants from '../constant/constants.mjs'
|
||||
import types from '../constant/types.mjs'
|
||||
import shallow from '../util/shallow.mjs'
|
||||
|
||||
function initializeFactory(field) {
|
||||
return {
|
||||
tokenize: initializeText,
|
||||
resolveAll: createResolver(
|
||||
field === 'text' ? resolveAllLineSuffixes : undefined
|
||||
)
|
||||
}
|
||||
|
||||
function initializeText(effects) {
|
||||
var self = this
|
||||
var constructs = this.parser.constructs[field]
|
||||
var text = effects.attempt(constructs, start, notText)
|
||||
|
||||
return start
|
||||
|
||||
function start(code) {
|
||||
return atBreak(code) ? text(code) : notText(code)
|
||||
}
|
||||
|
||||
function notText(code) {
|
||||
if (code === codes.eof) {
|
||||
effects.consume(code)
|
||||
return
|
||||
}
|
||||
|
||||
effects.enter(types.data)
|
||||
effects.consume(code)
|
||||
return data
|
||||
}
|
||||
|
||||
function data(code) {
|
||||
if (atBreak(code)) {
|
||||
effects.exit(types.data)
|
||||
return text(code)
|
||||
}
|
||||
|
||||
// Data.
|
||||
effects.consume(code)
|
||||
return data
|
||||
}
|
||||
|
||||
function atBreak(code) {
|
||||
var list = constructs[code]
|
||||
var index = -1
|
||||
|
||||
if (code === codes.eof) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (list) {
|
||||
while (++index < list.length) {
|
||||
if (
|
||||
!list[index].previous ||
|
||||
list[index].previous.call(self, self.previous)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createResolver(extraResolver) {
|
||||
return resolveAllText
|
||||
|
||||
function resolveAllText(events, context) {
|
||||
var index = -1
|
||||
var enter
|
||||
|
||||
// A rather boring computation (to merge adjacent `data` events) which
|
||||
// improves mm performance by 29%.
|
||||
while (++index <= events.length) {
|
||||
if (enter === undefined) {
|
||||
if (events[index] && events[index][1].type === types.data) {
|
||||
enter = index
|
||||
index++
|
||||
}
|
||||
} else if (!events[index] || events[index][1].type !== types.data) {
|
||||
// Don’t do anything if there is one data token.
|
||||
if (index !== enter + 2) {
|
||||
events[enter][1].end = events[index - 1][1].end
|
||||
events.splice(enter + 2, index - enter - 2)
|
||||
index = enter + 2
|
||||
}
|
||||
|
||||
enter = undefined
|
||||
}
|
||||
}
|
||||
|
||||
return extraResolver ? extraResolver(events, context) : events
|
||||
}
|
||||
}
|
||||
|
||||
// A rather ugly set of instructions which again looks at chunks in the input
|
||||
// stream.
|
||||
// The reason to do this here is that it is *much* faster to parse in reverse.
|
||||
// And that we can’t hook into `null` to split the line suffix before an EOF.
|
||||
// To do: figure out if we can make this into a clean utility, or even in core.
|
||||
// As it will be useful for GFMs literal autolink extension (and maybe even
|
||||
// tables?)
|
||||
function resolveAllLineSuffixes(events, context) {
|
||||
var eventIndex = -1
|
||||
var chunks
|
||||
var data
|
||||
var chunk
|
||||
var index
|
||||
var bufferIndex
|
||||
var size
|
||||
var tabs
|
||||
var token
|
||||
|
||||
while (++eventIndex <= events.length) {
|
||||
if (
|
||||
(eventIndex === events.length ||
|
||||
events[eventIndex][1].type === types.lineEnding) &&
|
||||
events[eventIndex - 1][1].type === types.data
|
||||
) {
|
||||
data = events[eventIndex - 1][1]
|
||||
chunks = context.sliceStream(data)
|
||||
index = chunks.length
|
||||
bufferIndex = -1
|
||||
size = 0
|
||||
tabs = undefined
|
||||
|
||||
while (index--) {
|
||||
chunk = chunks[index]
|
||||
|
||||
if (typeof chunk === 'string') {
|
||||
bufferIndex = chunk.length
|
||||
|
||||
while (chunk.charCodeAt(bufferIndex - 1) === codes.space) {
|
||||
size++
|
||||
bufferIndex--
|
||||
}
|
||||
|
||||
if (bufferIndex) break
|
||||
bufferIndex = -1
|
||||
}
|
||||
// Number
|
||||
else if (chunk === codes.horizontalTab) {
|
||||
tabs = true
|
||||
size++
|
||||
} else if (chunk === codes.virtualSpace) {
|
||||
// Empty
|
||||
} else {
|
||||
// Replacement character, exit.
|
||||
index++
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (size) {
|
||||
token = {
|
||||
type:
|
||||
eventIndex === events.length ||
|
||||
tabs ||
|
||||
size < constants.hardBreakPrefixSizeMin
|
||||
? types.lineSuffix
|
||||
: types.hardBreakTrailing,
|
||||
start: {
|
||||
line: data.end.line,
|
||||
column: data.end.column - size,
|
||||
offset: data.end.offset - size,
|
||||
_index: data.start._index + index,
|
||||
_bufferIndex: index
|
||||
? bufferIndex
|
||||
: data.start._bufferIndex + bufferIndex
|
||||
},
|
||||
end: shallow(data.end)
|
||||
}
|
||||
|
||||
data.end = shallow(token.start)
|
||||
|
||||
if (data.start.offset === data.end.offset) {
|
||||
assign(data, token)
|
||||
} else {
|
||||
events.splice(
|
||||
eventIndex,
|
||||
0,
|
||||
['enter', token, context],
|
||||
['exit', token, context]
|
||||
)
|
||||
eventIndex += 2
|
||||
}
|
||||
}
|
||||
|
||||
eventIndex++
|
||||
}
|
||||
}
|
||||
|
||||
return events
|
||||
}
|
||||
Reference in New Issue
Block a user