This commit is contained in:
133
node_modules/remark-parse/lib/tokenize/auto-link.js
generated
vendored
Normal file
133
node_modules/remark-parse/lib/tokenize/auto-link.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var decode = require('parse-entities')
|
||||
var locate = require('../locate/tag')
|
||||
|
||||
module.exports = autoLink
|
||||
autoLink.locator = locate
|
||||
autoLink.notInLink = true
|
||||
|
||||
var lessThan = '<'
|
||||
var greaterThan = '>'
|
||||
var atSign = '@'
|
||||
var slash = '/'
|
||||
var mailto = 'mailto:'
|
||||
var mailtoLength = mailto.length
|
||||
|
||||
function autoLink(eat, value, silent) {
|
||||
var self = this
|
||||
var subvalue = ''
|
||||
var length = value.length
|
||||
var index = 0
|
||||
var queue = ''
|
||||
var hasAtCharacter = false
|
||||
var link = ''
|
||||
var character
|
||||
var now
|
||||
var content
|
||||
var tokenizers
|
||||
var exit
|
||||
|
||||
if (value.charAt(0) !== lessThan) {
|
||||
return
|
||||
}
|
||||
|
||||
index++
|
||||
subvalue = lessThan
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (
|
||||
whitespace(character) ||
|
||||
character === greaterThan ||
|
||||
character === atSign ||
|
||||
(character === ':' && value.charAt(index + 1) === slash)
|
||||
) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (!queue) {
|
||||
return
|
||||
}
|
||||
|
||||
link += queue
|
||||
queue = ''
|
||||
|
||||
character = value.charAt(index)
|
||||
link += character
|
||||
index++
|
||||
|
||||
if (character === atSign) {
|
||||
hasAtCharacter = true
|
||||
} else {
|
||||
if (character !== ':' || value.charAt(index + 1) !== slash) {
|
||||
return
|
||||
}
|
||||
|
||||
link += slash
|
||||
index++
|
||||
}
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (whitespace(character) || character === greaterThan) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!queue || character !== greaterThan) {
|
||||
return
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
link += queue
|
||||
content = link
|
||||
subvalue += link + character
|
||||
now = eat.now()
|
||||
now.column++
|
||||
now.offset++
|
||||
|
||||
if (hasAtCharacter) {
|
||||
if (link.slice(0, mailtoLength).toLowerCase() === mailto) {
|
||||
content = content.substr(mailtoLength)
|
||||
now.column += mailtoLength
|
||||
now.offset += mailtoLength
|
||||
} else {
|
||||
link = mailto + link
|
||||
}
|
||||
}
|
||||
|
||||
// Temporarily remove all tokenizers except text in autolinks.
|
||||
tokenizers = self.inlineTokenizers
|
||||
self.inlineTokenizers = {text: tokenizers.text}
|
||||
|
||||
exit = self.enterLink()
|
||||
|
||||
content = self.tokenizeInline(content, now)
|
||||
|
||||
self.inlineTokenizers = tokenizers
|
||||
exit()
|
||||
|
||||
return eat(subvalue)({
|
||||
type: 'link',
|
||||
title: null,
|
||||
url: decode(link, {nonTerminated: false}),
|
||||
children: content
|
||||
})
|
||||
}
|
||||
124
node_modules/remark-parse/lib/tokenize/blockquote.js
generated
vendored
Normal file
124
node_modules/remark-parse/lib/tokenize/blockquote.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
'use strict'
|
||||
|
||||
var trim = require('trim')
|
||||
var interrupt = require('../util/interrupt')
|
||||
|
||||
module.exports = blockquote
|
||||
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
var greaterThan = '>'
|
||||
|
||||
function blockquote(eat, value, silent) {
|
||||
var self = this
|
||||
var offsets = self.offset
|
||||
var tokenizers = self.blockTokenizers
|
||||
var interruptors = self.interruptBlockquote
|
||||
var now = eat.now()
|
||||
var currentLine = now.line
|
||||
var length = value.length
|
||||
var values = []
|
||||
var contents = []
|
||||
var indents = []
|
||||
var add
|
||||
var index = 0
|
||||
var character
|
||||
var rest
|
||||
var nextIndex
|
||||
var content
|
||||
var line
|
||||
var startIndex
|
||||
var prefixed
|
||||
var exit
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
break
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
if (value.charAt(index) !== greaterThan) {
|
||||
return
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
index = 0
|
||||
|
||||
while (index < length) {
|
||||
nextIndex = value.indexOf(lineFeed, index)
|
||||
startIndex = index
|
||||
prefixed = false
|
||||
|
||||
if (nextIndex === -1) {
|
||||
nextIndex = length
|
||||
}
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
break
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
if (value.charAt(index) === greaterThan) {
|
||||
index++
|
||||
prefixed = true
|
||||
|
||||
if (value.charAt(index) === space) {
|
||||
index++
|
||||
}
|
||||
} else {
|
||||
index = startIndex
|
||||
}
|
||||
|
||||
content = value.slice(index, nextIndex)
|
||||
|
||||
if (!prefixed && !trim(content)) {
|
||||
index = startIndex
|
||||
break
|
||||
}
|
||||
|
||||
if (!prefixed) {
|
||||
rest = value.slice(index)
|
||||
|
||||
// Check if the following code contains a possible block.
|
||||
if (interrupt(interruptors, tokenizers, self, [eat, rest, true])) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
line = startIndex === index ? content : value.slice(startIndex, nextIndex)
|
||||
|
||||
indents.push(index - startIndex)
|
||||
values.push(line)
|
||||
contents.push(content)
|
||||
|
||||
index = nextIndex + 1
|
||||
}
|
||||
|
||||
index = -1
|
||||
length = indents.length
|
||||
add = eat(values.join(lineFeed))
|
||||
|
||||
while (++index < length) {
|
||||
offsets[currentLine] = (offsets[currentLine] || 0) + indents[index]
|
||||
currentLine++
|
||||
}
|
||||
|
||||
exit = self.enterBlock()
|
||||
contents = self.tokenizeBlock(contents.join(lineFeed), now)
|
||||
exit()
|
||||
|
||||
return add({type: 'blockquote', children: contents})
|
||||
}
|
||||
42
node_modules/remark-parse/lib/tokenize/break.js
generated
vendored
Normal file
42
node_modules/remark-parse/lib/tokenize/break.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict'
|
||||
|
||||
var locate = require('../locate/break')
|
||||
|
||||
module.exports = hardBreak
|
||||
hardBreak.locator = locate
|
||||
|
||||
var space = ' '
|
||||
var lineFeed = '\n'
|
||||
var minBreakLength = 2
|
||||
|
||||
function hardBreak(eat, value, silent) {
|
||||
var length = value.length
|
||||
var index = -1
|
||||
var queue = ''
|
||||
var character
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === lineFeed) {
|
||||
if (index < minBreakLength) {
|
||||
return
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
queue += character
|
||||
|
||||
return eat(queue)({type: 'break'})
|
||||
}
|
||||
|
||||
if (character !== space) {
|
||||
return
|
||||
}
|
||||
|
||||
queue += character
|
||||
}
|
||||
}
|
||||
255
node_modules/remark-parse/lib/tokenize/code-fenced.js
generated
vendored
Normal file
255
node_modules/remark-parse/lib/tokenize/code-fenced.js
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
'use strict'
|
||||
|
||||
var trim = require('trim-trailing-lines')
|
||||
|
||||
module.exports = fencedCode
|
||||
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
var tilde = '~'
|
||||
var graveAccent = '`'
|
||||
|
||||
var minFenceCount = 3
|
||||
var tabSize = 4
|
||||
|
||||
function fencedCode(eat, value, silent) {
|
||||
var self = this
|
||||
var gfm = self.options.gfm
|
||||
var length = value.length + 1
|
||||
var index = 0
|
||||
var subvalue = ''
|
||||
var fenceCount
|
||||
var marker
|
||||
var character
|
||||
var flag
|
||||
var lang
|
||||
var meta
|
||||
var queue
|
||||
var content
|
||||
var exdentedContent
|
||||
var closing
|
||||
var exdentedClosing
|
||||
var indent
|
||||
var now
|
||||
|
||||
if (!gfm) {
|
||||
return
|
||||
}
|
||||
|
||||
// Eat initial spacing.
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
indent = index
|
||||
|
||||
// Eat the fence.
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== tilde && character !== graveAccent) {
|
||||
return
|
||||
}
|
||||
|
||||
index++
|
||||
marker = character
|
||||
fenceCount = 1
|
||||
subvalue += character
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== marker) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
fenceCount++
|
||||
index++
|
||||
}
|
||||
|
||||
if (fenceCount < minFenceCount) {
|
||||
return
|
||||
}
|
||||
|
||||
// Eat spacing before flag.
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
// Eat flag.
|
||||
flag = ''
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (
|
||||
character === lineFeed ||
|
||||
character === tilde ||
|
||||
character === graveAccent
|
||||
) {
|
||||
break
|
||||
}
|
||||
|
||||
if (character === space || character === tab) {
|
||||
queue += character
|
||||
} else {
|
||||
flag += queue + character
|
||||
queue = ''
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character && character !== lineFeed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
now = eat.now()
|
||||
now.column += subvalue.length
|
||||
now.offset += subvalue.length
|
||||
|
||||
subvalue += flag
|
||||
flag = self.decode.raw(self.unescape(flag), now)
|
||||
|
||||
if (queue) {
|
||||
subvalue += queue
|
||||
}
|
||||
|
||||
queue = ''
|
||||
closing = ''
|
||||
exdentedClosing = ''
|
||||
content = ''
|
||||
exdentedContent = ''
|
||||
|
||||
// Eat content.
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
content += closing
|
||||
exdentedContent += exdentedClosing
|
||||
closing = ''
|
||||
exdentedClosing = ''
|
||||
|
||||
if (character !== lineFeed) {
|
||||
content += character
|
||||
exdentedClosing += character
|
||||
index++
|
||||
continue
|
||||
}
|
||||
|
||||
// Add the newline to `subvalue` if its the first character. Otherwise,
|
||||
// add it to the `closing` queue.
|
||||
if (content) {
|
||||
closing += character
|
||||
exdentedClosing += character
|
||||
} else {
|
||||
subvalue += character
|
||||
}
|
||||
|
||||
queue = ''
|
||||
index++
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
closing += queue
|
||||
exdentedClosing += queue.slice(indent)
|
||||
|
||||
if (queue.length >= tabSize) {
|
||||
continue
|
||||
}
|
||||
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== marker) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
closing += queue
|
||||
exdentedClosing += queue
|
||||
|
||||
if (queue.length < fenceCount) {
|
||||
continue
|
||||
}
|
||||
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
break
|
||||
}
|
||||
|
||||
closing += character
|
||||
exdentedClosing += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (!character || character === lineFeed) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
subvalue += content + closing
|
||||
|
||||
// Get lang and meta from the flag.
|
||||
index = -1
|
||||
length = flag.length
|
||||
|
||||
while (++index < length) {
|
||||
character = flag.charAt(index)
|
||||
|
||||
if (character === space || character === tab) {
|
||||
if (!lang) {
|
||||
lang = flag.slice(0, index)
|
||||
}
|
||||
} else if (lang) {
|
||||
meta = flag.slice(index)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return eat(subvalue)({
|
||||
type: 'code',
|
||||
lang: lang || flag || null,
|
||||
meta: meta || null,
|
||||
value: trim(exdentedContent)
|
||||
})
|
||||
}
|
||||
98
node_modules/remark-parse/lib/tokenize/code-indented.js
generated
vendored
Normal file
98
node_modules/remark-parse/lib/tokenize/code-indented.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
'use strict'
|
||||
|
||||
var repeat = require('repeat-string')
|
||||
var trim = require('trim-trailing-lines')
|
||||
|
||||
module.exports = indentedCode
|
||||
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
|
||||
var tabSize = 4
|
||||
var codeIndent = repeat(space, tabSize)
|
||||
|
||||
function indentedCode(eat, value, silent) {
|
||||
var index = -1
|
||||
var length = value.length
|
||||
var subvalue = ''
|
||||
var content = ''
|
||||
var subvalueQueue = ''
|
||||
var contentQueue = ''
|
||||
var character
|
||||
var blankQueue
|
||||
var indent
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (indent) {
|
||||
indent = false
|
||||
|
||||
subvalue += subvalueQueue
|
||||
content += contentQueue
|
||||
subvalueQueue = ''
|
||||
contentQueue = ''
|
||||
|
||||
if (character === lineFeed) {
|
||||
subvalueQueue = character
|
||||
contentQueue = character
|
||||
} else {
|
||||
subvalue += character
|
||||
content += character
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!character || character === lineFeed) {
|
||||
contentQueue = character
|
||||
subvalueQueue = character
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
content += character
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
character === space &&
|
||||
value.charAt(index + 1) === character &&
|
||||
value.charAt(index + 2) === character &&
|
||||
value.charAt(index + 3) === character
|
||||
) {
|
||||
subvalueQueue += codeIndent
|
||||
index += 3
|
||||
indent = true
|
||||
} else if (character === tab) {
|
||||
subvalueQueue += character
|
||||
indent = true
|
||||
} else {
|
||||
blankQueue = ''
|
||||
|
||||
while (character === tab || character === space) {
|
||||
blankQueue += character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
if (character !== lineFeed) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalueQueue += blankQueue + character
|
||||
contentQueue += character
|
||||
}
|
||||
}
|
||||
|
||||
if (content) {
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
return eat(subvalue)({
|
||||
type: 'code',
|
||||
lang: null,
|
||||
meta: null,
|
||||
value: trim(content)
|
||||
})
|
||||
}
|
||||
}
|
||||
108
node_modules/remark-parse/lib/tokenize/code-inline.js
generated
vendored
Normal file
108
node_modules/remark-parse/lib/tokenize/code-inline.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var locate = require('../locate/code-inline')
|
||||
|
||||
module.exports = inlineCode
|
||||
inlineCode.locator = locate
|
||||
|
||||
var graveAccent = '`'
|
||||
|
||||
function inlineCode(eat, value, silent) {
|
||||
var length = value.length
|
||||
var index = 0
|
||||
var queue = ''
|
||||
var tickQueue = ''
|
||||
var contentQueue
|
||||
var subqueue
|
||||
var count
|
||||
var openingCount
|
||||
var subvalue
|
||||
var character
|
||||
var found
|
||||
var next
|
||||
|
||||
while (index < length) {
|
||||
if (value.charAt(index) !== graveAccent) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += graveAccent
|
||||
index++
|
||||
}
|
||||
|
||||
if (!queue) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue = queue
|
||||
openingCount = index
|
||||
queue = ''
|
||||
next = value.charAt(index)
|
||||
count = 0
|
||||
|
||||
while (index < length) {
|
||||
character = next
|
||||
next = value.charAt(index + 1)
|
||||
|
||||
if (character === graveAccent) {
|
||||
count++
|
||||
tickQueue += character
|
||||
} else {
|
||||
count = 0
|
||||
queue += character
|
||||
}
|
||||
|
||||
if (count && next !== graveAccent) {
|
||||
if (count === openingCount) {
|
||||
subvalue += queue + tickQueue
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
queue += tickQueue
|
||||
tickQueue = ''
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
if (openingCount % 2 !== 0) {
|
||||
return
|
||||
}
|
||||
|
||||
queue = ''
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
contentQueue = ''
|
||||
subqueue = ''
|
||||
length = queue.length
|
||||
index = -1
|
||||
|
||||
while (++index < length) {
|
||||
character = queue.charAt(index)
|
||||
|
||||
if (whitespace(character)) {
|
||||
subqueue += character
|
||||
continue
|
||||
}
|
||||
|
||||
if (subqueue) {
|
||||
if (contentQueue) {
|
||||
contentQueue += subqueue
|
||||
}
|
||||
|
||||
subqueue = ''
|
||||
}
|
||||
|
||||
contentQueue += character
|
||||
}
|
||||
|
||||
return eat(subvalue)({type: 'inlineCode', value: contentQueue})
|
||||
}
|
||||
275
node_modules/remark-parse/lib/tokenize/definition.js
generated
vendored
Normal file
275
node_modules/remark-parse/lib/tokenize/definition.js
generated
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var normalize = require('../util/normalize')
|
||||
|
||||
module.exports = definition
|
||||
definition.notInList = true
|
||||
definition.notInBlock = true
|
||||
|
||||
var quotationMark = '"'
|
||||
var apostrophe = "'"
|
||||
var backslash = '\\'
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var leftParenthesis = '('
|
||||
var rightParenthesis = ')'
|
||||
var colon = ':'
|
||||
var lessThan = '<'
|
||||
var greaterThan = '>'
|
||||
|
||||
function definition(eat, value, silent) {
|
||||
var self = this
|
||||
var commonmark = self.options.commonmark
|
||||
var index = 0
|
||||
var length = value.length
|
||||
var subvalue = ''
|
||||
var beforeURL
|
||||
var beforeTitle
|
||||
var queue
|
||||
var character
|
||||
var test
|
||||
var identifier
|
||||
var url
|
||||
var title
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== leftSquareBracket) {
|
||||
return
|
||||
}
|
||||
|
||||
index++
|
||||
subvalue += character
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === rightSquareBracket) {
|
||||
break
|
||||
} else if (character === backslash) {
|
||||
queue += character
|
||||
index++
|
||||
character = value.charAt(index)
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (
|
||||
!queue ||
|
||||
value.charAt(index) !== rightSquareBracket ||
|
||||
value.charAt(index + 1) !== colon
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
identifier = queue
|
||||
subvalue += queue + rightSquareBracket + colon
|
||||
index = subvalue.length
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== tab && character !== space && character !== lineFeed) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
queue = ''
|
||||
beforeURL = subvalue
|
||||
|
||||
if (character === lessThan) {
|
||||
index++
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!isEnclosedURLCharacter(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === isEnclosedURLCharacter.delimiter) {
|
||||
subvalue += lessThan + queue + character
|
||||
index++
|
||||
} else {
|
||||
if (commonmark) {
|
||||
return
|
||||
}
|
||||
|
||||
index -= queue.length + 1
|
||||
queue = ''
|
||||
}
|
||||
}
|
||||
|
||||
if (!queue) {
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!isUnclosedURLCharacter(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
subvalue += queue
|
||||
}
|
||||
|
||||
if (!queue) {
|
||||
return
|
||||
}
|
||||
|
||||
url = queue
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== tab && character !== space && character !== lineFeed) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
test = null
|
||||
|
||||
if (character === quotationMark) {
|
||||
test = quotationMark
|
||||
} else if (character === apostrophe) {
|
||||
test = apostrophe
|
||||
} else if (character === leftParenthesis) {
|
||||
test = rightParenthesis
|
||||
}
|
||||
|
||||
if (!test) {
|
||||
queue = ''
|
||||
index = subvalue.length
|
||||
} else if (queue) {
|
||||
subvalue += queue + character
|
||||
index = subvalue.length
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === test) {
|
||||
break
|
||||
}
|
||||
|
||||
if (character === lineFeed) {
|
||||
index++
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === lineFeed || character === test) {
|
||||
return
|
||||
}
|
||||
|
||||
queue += lineFeed
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== test) {
|
||||
return
|
||||
}
|
||||
|
||||
beforeTitle = subvalue
|
||||
subvalue += queue + character
|
||||
index++
|
||||
title = queue
|
||||
queue = ''
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== tab && character !== space) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!character || character === lineFeed) {
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
beforeURL = eat(beforeURL).test().end
|
||||
url = self.decode.raw(self.unescape(url), beforeURL, {nonTerminated: false})
|
||||
|
||||
if (title) {
|
||||
beforeTitle = eat(beforeTitle).test().end
|
||||
title = self.decode.raw(self.unescape(title), beforeTitle)
|
||||
}
|
||||
|
||||
return eat(subvalue)({
|
||||
type: 'definition',
|
||||
identifier: normalize(identifier),
|
||||
label: identifier,
|
||||
title: title || null,
|
||||
url: url
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Check if `character` can be inside an enclosed URI.
|
||||
function isEnclosedURLCharacter(character) {
|
||||
return (
|
||||
character !== greaterThan &&
|
||||
character !== leftSquareBracket &&
|
||||
character !== rightSquareBracket
|
||||
)
|
||||
}
|
||||
|
||||
isEnclosedURLCharacter.delimiter = greaterThan
|
||||
|
||||
// Check if `character` can be inside an unclosed URI.
|
||||
function isUnclosedURLCharacter(character) {
|
||||
return (
|
||||
character !== leftSquareBracket &&
|
||||
character !== rightSquareBracket &&
|
||||
!whitespace(character)
|
||||
)
|
||||
}
|
||||
60
node_modules/remark-parse/lib/tokenize/delete.js
generated
vendored
Normal file
60
node_modules/remark-parse/lib/tokenize/delete.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var locate = require('../locate/delete')
|
||||
|
||||
module.exports = strikethrough
|
||||
strikethrough.locator = locate
|
||||
|
||||
var tilde = '~'
|
||||
var fence = '~~'
|
||||
|
||||
function strikethrough(eat, value, silent) {
|
||||
var self = this
|
||||
var character = ''
|
||||
var previous = ''
|
||||
var preceding = ''
|
||||
var subvalue = ''
|
||||
var index
|
||||
var length
|
||||
var now
|
||||
|
||||
if (
|
||||
!self.options.gfm ||
|
||||
value.charAt(0) !== tilde ||
|
||||
value.charAt(1) !== tilde ||
|
||||
whitespace(value.charAt(2))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
index = 1
|
||||
length = value.length
|
||||
now = eat.now()
|
||||
now.column += 2
|
||||
now.offset += 2
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (
|
||||
character === tilde &&
|
||||
previous === tilde &&
|
||||
(!preceding || !whitespace(preceding))
|
||||
) {
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
return eat(fence + subvalue + fence)({
|
||||
type: 'delete',
|
||||
children: self.tokenizeInline(subvalue, now)
|
||||
})
|
||||
}
|
||||
|
||||
subvalue += previous
|
||||
preceding = previous
|
||||
previous = character
|
||||
}
|
||||
}
|
||||
86
node_modules/remark-parse/lib/tokenize/emphasis.js
generated
vendored
Normal file
86
node_modules/remark-parse/lib/tokenize/emphasis.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
'use strict'
|
||||
|
||||
var trim = require('trim')
|
||||
var word = require('is-word-character')
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var locate = require('../locate/emphasis')
|
||||
|
||||
module.exports = emphasis
|
||||
emphasis.locator = locate
|
||||
|
||||
var asterisk = '*'
|
||||
var underscore = '_'
|
||||
var backslash = '\\'
|
||||
|
||||
function emphasis(eat, value, silent) {
|
||||
var self = this
|
||||
var index = 0
|
||||
var character = value.charAt(index)
|
||||
var now
|
||||
var pedantic
|
||||
var marker
|
||||
var queue
|
||||
var subvalue
|
||||
var length
|
||||
var prev
|
||||
|
||||
if (character !== asterisk && character !== underscore) {
|
||||
return
|
||||
}
|
||||
|
||||
pedantic = self.options.pedantic
|
||||
subvalue = character
|
||||
marker = character
|
||||
length = value.length
|
||||
index++
|
||||
queue = ''
|
||||
character = ''
|
||||
|
||||
if (pedantic && whitespace(value.charAt(index))) {
|
||||
return
|
||||
}
|
||||
|
||||
while (index < length) {
|
||||
prev = character
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === marker && (!pedantic || !whitespace(prev))) {
|
||||
character = value.charAt(++index)
|
||||
|
||||
if (character !== marker) {
|
||||
if (!trim(queue) || prev === marker) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!pedantic && marker === underscore && word(character)) {
|
||||
queue += marker
|
||||
continue
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
now = eat.now()
|
||||
now.column++
|
||||
now.offset++
|
||||
|
||||
return eat(subvalue + queue + marker)({
|
||||
type: 'emphasis',
|
||||
children: self.tokenizeInline(queue, now)
|
||||
})
|
||||
}
|
||||
|
||||
queue += marker
|
||||
}
|
||||
|
||||
if (!pedantic && character === backslash) {
|
||||
queue += character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
}
|
||||
34
node_modules/remark-parse/lib/tokenize/escape.js
generated
vendored
Normal file
34
node_modules/remark-parse/lib/tokenize/escape.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict'
|
||||
|
||||
var locate = require('../locate/escape')
|
||||
|
||||
module.exports = escape
|
||||
escape.locator = locate
|
||||
|
||||
var lineFeed = '\n'
|
||||
var backslash = '\\'
|
||||
|
||||
function escape(eat, value, silent) {
|
||||
var self = this
|
||||
var character
|
||||
var node
|
||||
|
||||
if (value.charAt(0) === backslash) {
|
||||
character = value.charAt(1)
|
||||
|
||||
if (self.escape.indexOf(character) !== -1) {
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (character === lineFeed) {
|
||||
node = {type: 'break'}
|
||||
} else {
|
||||
node = {type: 'text', value: character}
|
||||
}
|
||||
|
||||
return eat(backslash + character)(node)
|
||||
}
|
||||
}
|
||||
}
|
||||
186
node_modules/remark-parse/lib/tokenize/footnote-definition.js
generated
vendored
Normal file
186
node_modules/remark-parse/lib/tokenize/footnote-definition.js
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var normalize = require('../util/normalize')
|
||||
|
||||
module.exports = footnoteDefinition
|
||||
footnoteDefinition.notInList = true
|
||||
footnoteDefinition.notInBlock = true
|
||||
|
||||
var backslash = '\\'
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
var caret = '^'
|
||||
var colon = ':'
|
||||
|
||||
var EXPRESSION_INITIAL_TAB = /^( {4}|\t)?/gm
|
||||
|
||||
function footnoteDefinition(eat, value, silent) {
|
||||
var self = this
|
||||
var offsets = self.offset
|
||||
var index
|
||||
var length
|
||||
var subvalue
|
||||
var now
|
||||
var currentLine
|
||||
var content
|
||||
var queue
|
||||
var subqueue
|
||||
var character
|
||||
var identifier
|
||||
var add
|
||||
var exit
|
||||
|
||||
if (!self.options.footnotes) {
|
||||
return
|
||||
}
|
||||
|
||||
index = 0
|
||||
length = value.length
|
||||
subvalue = ''
|
||||
now = eat.now()
|
||||
currentLine = now.line
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!whitespace(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (
|
||||
value.charAt(index) !== leftSquareBracket ||
|
||||
value.charAt(index + 1) !== caret
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue += leftSquareBracket + caret
|
||||
index = subvalue.length
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === rightSquareBracket) {
|
||||
break
|
||||
} else if (character === backslash) {
|
||||
queue += character
|
||||
index++
|
||||
character = value.charAt(index)
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (
|
||||
!queue ||
|
||||
value.charAt(index) !== rightSquareBracket ||
|
||||
value.charAt(index + 1) !== colon
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
identifier = queue
|
||||
subvalue += queue + rightSquareBracket + colon
|
||||
index = subvalue.length
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== tab && character !== space) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
now.column += subvalue.length
|
||||
now.offset += subvalue.length
|
||||
queue = ''
|
||||
content = ''
|
||||
subqueue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === lineFeed) {
|
||||
subqueue = character
|
||||
index++
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== lineFeed) {
|
||||
break
|
||||
}
|
||||
|
||||
subqueue += character
|
||||
index++
|
||||
}
|
||||
|
||||
queue += subqueue
|
||||
subqueue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space) {
|
||||
break
|
||||
}
|
||||
|
||||
subqueue += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (subqueue.length === 0) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += subqueue
|
||||
}
|
||||
|
||||
if (queue) {
|
||||
content += queue
|
||||
queue = ''
|
||||
}
|
||||
|
||||
content += character
|
||||
index++
|
||||
}
|
||||
|
||||
subvalue += content
|
||||
|
||||
content = content.replace(EXPRESSION_INITIAL_TAB, function(line) {
|
||||
offsets[currentLine] = (offsets[currentLine] || 0) + line.length
|
||||
currentLine++
|
||||
|
||||
return ''
|
||||
})
|
||||
|
||||
add = eat(subvalue)
|
||||
|
||||
exit = self.enterBlock()
|
||||
content = self.tokenizeBlock(content, now)
|
||||
exit()
|
||||
|
||||
return add({
|
||||
type: 'footnoteDefinition',
|
||||
identifier: normalize(identifier),
|
||||
label: identifier,
|
||||
children: content
|
||||
})
|
||||
}
|
||||
135
node_modules/remark-parse/lib/tokenize/heading-atx.js
generated
vendored
Normal file
135
node_modules/remark-parse/lib/tokenize/heading-atx.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = atxHeading
|
||||
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
var numberSign = '#'
|
||||
|
||||
var maxFenceCount = 6
|
||||
|
||||
function atxHeading(eat, value, silent) {
|
||||
var self = this
|
||||
var pedantic = self.options.pedantic
|
||||
var length = value.length + 1
|
||||
var index = -1
|
||||
var now = eat.now()
|
||||
var subvalue = ''
|
||||
var content = ''
|
||||
var character
|
||||
var queue
|
||||
var depth
|
||||
|
||||
// Eat initial spacing.
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
index--
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
}
|
||||
|
||||
// Eat hashes.
|
||||
depth = 0
|
||||
|
||||
while (++index <= length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== numberSign) {
|
||||
index--
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
depth++
|
||||
}
|
||||
|
||||
if (depth > maxFenceCount) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!depth || (!pedantic && value.charAt(index + 1) === numberSign)) {
|
||||
return
|
||||
}
|
||||
|
||||
length = value.length + 1
|
||||
|
||||
// Eat intermediate white-space.
|
||||
queue = ''
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space && character !== tab) {
|
||||
index--
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
}
|
||||
|
||||
// Exit when not in pedantic mode without spacing.
|
||||
if (!pedantic && queue.length === 0 && character && character !== lineFeed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Eat content.
|
||||
subvalue += queue
|
||||
queue = ''
|
||||
content = ''
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!character || character === lineFeed) {
|
||||
break
|
||||
}
|
||||
|
||||
if (character !== space && character !== tab && character !== numberSign) {
|
||||
content += queue + character
|
||||
queue = ''
|
||||
continue
|
||||
}
|
||||
|
||||
while (character === space || character === tab) {
|
||||
queue += character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
// `#` without a queue is part of the content.
|
||||
if (!pedantic && content && !queue && character === numberSign) {
|
||||
content += character
|
||||
continue
|
||||
}
|
||||
|
||||
while (character === numberSign) {
|
||||
queue += character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
while (character === space || character === tab) {
|
||||
queue += character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
index--
|
||||
}
|
||||
|
||||
now.column += subvalue.length
|
||||
now.offset += subvalue.length
|
||||
subvalue += content + queue
|
||||
|
||||
return eat(subvalue)({
|
||||
type: 'heading',
|
||||
depth: depth,
|
||||
children: self.tokenizeInline(content, now)
|
||||
})
|
||||
}
|
||||
102
node_modules/remark-parse/lib/tokenize/heading-setext.js
generated
vendored
Normal file
102
node_modules/remark-parse/lib/tokenize/heading-setext.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = setextHeading
|
||||
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
var equalsTo = '='
|
||||
var dash = '-'
|
||||
|
||||
var maxIndent = 3
|
||||
|
||||
var equalsToDepth = 1
|
||||
var dashDepth = 2
|
||||
|
||||
function setextHeading(eat, value, silent) {
|
||||
var self = this
|
||||
var now = eat.now()
|
||||
var length = value.length
|
||||
var index = -1
|
||||
var subvalue = ''
|
||||
var content
|
||||
var queue
|
||||
var character
|
||||
var marker
|
||||
var depth
|
||||
|
||||
// Eat initial indentation.
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== space || index >= maxIndent) {
|
||||
index--
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
}
|
||||
|
||||
// Eat content.
|
||||
content = ''
|
||||
queue = ''
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === lineFeed) {
|
||||
index--
|
||||
break
|
||||
}
|
||||
|
||||
if (character === space || character === tab) {
|
||||
queue += character
|
||||
} else {
|
||||
content += queue + character
|
||||
queue = ''
|
||||
}
|
||||
}
|
||||
|
||||
now.column += subvalue.length
|
||||
now.offset += subvalue.length
|
||||
subvalue += content + queue
|
||||
|
||||
// Ensure the content is followed by a newline and a valid marker.
|
||||
character = value.charAt(++index)
|
||||
marker = value.charAt(++index)
|
||||
|
||||
if (character !== lineFeed || (marker !== equalsTo && marker !== dash)) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
|
||||
// Eat Setext-line.
|
||||
queue = marker
|
||||
depth = marker === equalsTo ? equalsToDepth : dashDepth
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== marker) {
|
||||
if (character !== lineFeed) {
|
||||
return
|
||||
}
|
||||
|
||||
index--
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
return eat(subvalue + queue)({
|
||||
type: 'heading',
|
||||
depth: depth,
|
||||
children: self.tokenizeInline(content, now)
|
||||
})
|
||||
}
|
||||
111
node_modules/remark-parse/lib/tokenize/html-block.js
generated
vendored
Normal file
111
node_modules/remark-parse/lib/tokenize/html-block.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
'use strict'
|
||||
|
||||
var openCloseTag = require('../util/html').openCloseTag
|
||||
|
||||
module.exports = blockHtml
|
||||
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
var lineFeed = '\n'
|
||||
var lessThan = '<'
|
||||
|
||||
var rawOpenExpression = /^<(script|pre|style)(?=(\s|>|$))/i
|
||||
var rawCloseExpression = /<\/(script|pre|style)>/i
|
||||
var commentOpenExpression = /^<!--/
|
||||
var commentCloseExpression = /-->/
|
||||
var instructionOpenExpression = /^<\?/
|
||||
var instructionCloseExpression = /\?>/
|
||||
var directiveOpenExpression = /^<![A-Za-z]/
|
||||
var directiveCloseExpression = />/
|
||||
var cdataOpenExpression = /^<!\[CDATA\[/
|
||||
var cdataCloseExpression = /\]\]>/
|
||||
var elementCloseExpression = /^$/
|
||||
var otherElementOpenExpression = new RegExp(openCloseTag.source + '\\s*$')
|
||||
|
||||
function blockHtml(eat, value, silent) {
|
||||
var self = this
|
||||
var blocks = self.options.blocks.join('|')
|
||||
var elementOpenExpression = new RegExp(
|
||||
'^</?(' + blocks + ')(?=(\\s|/?>|$))',
|
||||
'i'
|
||||
)
|
||||
var length = value.length
|
||||
var index = 0
|
||||
var next
|
||||
var line
|
||||
var offset
|
||||
var character
|
||||
var count
|
||||
var sequence
|
||||
var subvalue
|
||||
|
||||
var sequences = [
|
||||
[rawOpenExpression, rawCloseExpression, true],
|
||||
[commentOpenExpression, commentCloseExpression, true],
|
||||
[instructionOpenExpression, instructionCloseExpression, true],
|
||||
[directiveOpenExpression, directiveCloseExpression, true],
|
||||
[cdataOpenExpression, cdataCloseExpression, true],
|
||||
[elementOpenExpression, elementCloseExpression, true],
|
||||
[otherElementOpenExpression, elementCloseExpression, false]
|
||||
]
|
||||
|
||||
// Eat initial spacing.
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== tab && character !== space) {
|
||||
break
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
if (value.charAt(index) !== lessThan) {
|
||||
return
|
||||
}
|
||||
|
||||
next = value.indexOf(lineFeed, index + 1)
|
||||
next = next === -1 ? length : next
|
||||
line = value.slice(index, next)
|
||||
offset = -1
|
||||
count = sequences.length
|
||||
|
||||
while (++offset < count) {
|
||||
if (sequences[offset][0].test(line)) {
|
||||
sequence = sequences[offset]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!sequence) {
|
||||
return
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
return sequence[2]
|
||||
}
|
||||
|
||||
index = next
|
||||
|
||||
if (!sequence[1].test(line)) {
|
||||
while (index < length) {
|
||||
next = value.indexOf(lineFeed, index + 1)
|
||||
next = next === -1 ? length : next
|
||||
line = value.slice(index + 1, next)
|
||||
|
||||
if (sequence[1].test(line)) {
|
||||
if (line) {
|
||||
index = next
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
index = next
|
||||
}
|
||||
}
|
||||
|
||||
subvalue = value.slice(0, index)
|
||||
|
||||
return eat(subvalue)({type: 'html', value: subvalue})
|
||||
}
|
||||
59
node_modules/remark-parse/lib/tokenize/html-inline.js
generated
vendored
Normal file
59
node_modules/remark-parse/lib/tokenize/html-inline.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict'
|
||||
|
||||
var alphabetical = require('is-alphabetical')
|
||||
var locate = require('../locate/tag')
|
||||
var tag = require('../util/html').tag
|
||||
|
||||
module.exports = inlineHTML
|
||||
inlineHTML.locator = locate
|
||||
|
||||
var lessThan = '<'
|
||||
var questionMark = '?'
|
||||
var exclamationMark = '!'
|
||||
var slash = '/'
|
||||
|
||||
var htmlLinkOpenExpression = /^<a /i
|
||||
var htmlLinkCloseExpression = /^<\/a>/i
|
||||
|
||||
function inlineHTML(eat, value, silent) {
|
||||
var self = this
|
||||
var length = value.length
|
||||
var character
|
||||
var subvalue
|
||||
|
||||
if (value.charAt(0) !== lessThan || length < 3) {
|
||||
return
|
||||
}
|
||||
|
||||
character = value.charAt(1)
|
||||
|
||||
if (
|
||||
!alphabetical(character) &&
|
||||
character !== questionMark &&
|
||||
character !== exclamationMark &&
|
||||
character !== slash
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue = value.match(tag)
|
||||
|
||||
if (!subvalue) {
|
||||
return
|
||||
}
|
||||
|
||||
/* istanbul ignore if - not used yet. */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
subvalue = subvalue[0]
|
||||
|
||||
if (!self.inLink && htmlLinkOpenExpression.test(subvalue)) {
|
||||
self.inLink = true
|
||||
} else if (self.inLink && htmlLinkCloseExpression.test(subvalue)) {
|
||||
self.inLink = false
|
||||
}
|
||||
|
||||
return eat(subvalue)({type: 'html', value: subvalue})
|
||||
}
|
||||
381
node_modules/remark-parse/lib/tokenize/link.js
generated
vendored
Normal file
381
node_modules/remark-parse/lib/tokenize/link.js
generated
vendored
Normal file
@@ -0,0 +1,381 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var locate = require('../locate/link')
|
||||
|
||||
module.exports = link
|
||||
link.locator = locate
|
||||
|
||||
var lineFeed = '\n'
|
||||
var exclamationMark = '!'
|
||||
var quotationMark = '"'
|
||||
var apostrophe = "'"
|
||||
var leftParenthesis = '('
|
||||
var rightParenthesis = ')'
|
||||
var lessThan = '<'
|
||||
var greaterThan = '>'
|
||||
var leftSquareBracket = '['
|
||||
var backslash = '\\'
|
||||
var rightSquareBracket = ']'
|
||||
var graveAccent = '`'
|
||||
|
||||
function link(eat, value, silent) {
|
||||
var self = this
|
||||
var subvalue = ''
|
||||
var index = 0
|
||||
var character = value.charAt(0)
|
||||
var pedantic = self.options.pedantic
|
||||
var commonmark = self.options.commonmark
|
||||
var gfm = self.options.gfm
|
||||
var closed
|
||||
var count
|
||||
var opening
|
||||
var beforeURL
|
||||
var beforeTitle
|
||||
var subqueue
|
||||
var hasMarker
|
||||
var isImage
|
||||
var content
|
||||
var marker
|
||||
var length
|
||||
var title
|
||||
var depth
|
||||
var queue
|
||||
var url
|
||||
var now
|
||||
var exit
|
||||
var node
|
||||
|
||||
// Detect whether this is an image.
|
||||
if (character === exclamationMark) {
|
||||
isImage = true
|
||||
subvalue = character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
// Eat the opening.
|
||||
if (character !== leftSquareBracket) {
|
||||
return
|
||||
}
|
||||
|
||||
// Exit when this is a link and we’re already inside a link.
|
||||
if (!isImage && self.inLink) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
queue = ''
|
||||
index++
|
||||
|
||||
// Eat the content.
|
||||
length = value.length
|
||||
now = eat.now()
|
||||
depth = 0
|
||||
|
||||
now.column += index
|
||||
now.offset += index
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
subqueue = character
|
||||
|
||||
if (character === graveAccent) {
|
||||
// Inline-code in link content.
|
||||
count = 1
|
||||
|
||||
while (value.charAt(index + 1) === graveAccent) {
|
||||
subqueue += character
|
||||
index++
|
||||
count++
|
||||
}
|
||||
|
||||
if (!opening) {
|
||||
opening = count
|
||||
} else if (count >= opening) {
|
||||
opening = 0
|
||||
}
|
||||
} else if (character === backslash) {
|
||||
// Allow brackets to be escaped.
|
||||
index++
|
||||
subqueue += value.charAt(index)
|
||||
} else if ((!opening || gfm) && character === leftSquareBracket) {
|
||||
// In GFM mode, brackets in code still count. In all other modes,
|
||||
// they don’t.
|
||||
depth++
|
||||
} else if ((!opening || gfm) && character === rightSquareBracket) {
|
||||
if (depth) {
|
||||
depth--
|
||||
} else {
|
||||
// Allow white-space between content and url in GFM mode.
|
||||
if (!pedantic) {
|
||||
while (index < length) {
|
||||
character = value.charAt(index + 1)
|
||||
|
||||
if (!whitespace(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
subqueue += character
|
||||
index++
|
||||
}
|
||||
}
|
||||
|
||||
if (value.charAt(index + 1) !== leftParenthesis) {
|
||||
return
|
||||
}
|
||||
|
||||
subqueue += leftParenthesis
|
||||
closed = true
|
||||
index++
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
queue += subqueue
|
||||
subqueue = ''
|
||||
index++
|
||||
}
|
||||
|
||||
// Eat the content closing.
|
||||
if (!closed) {
|
||||
return
|
||||
}
|
||||
|
||||
content = queue
|
||||
subvalue += queue + subqueue
|
||||
index++
|
||||
|
||||
// Eat white-space.
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!whitespace(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
|
||||
// Eat the URL.
|
||||
character = value.charAt(index)
|
||||
queue = ''
|
||||
beforeURL = subvalue
|
||||
|
||||
if (character === lessThan) {
|
||||
index++
|
||||
beforeURL += lessThan
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === greaterThan) {
|
||||
break
|
||||
}
|
||||
|
||||
if (commonmark && character === lineFeed) {
|
||||
return
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (value.charAt(index) !== greaterThan) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue += lessThan + queue + greaterThan
|
||||
url = queue
|
||||
index++
|
||||
} else {
|
||||
character = null
|
||||
subqueue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (
|
||||
subqueue &&
|
||||
(character === quotationMark ||
|
||||
character === apostrophe ||
|
||||
(commonmark && character === leftParenthesis))
|
||||
) {
|
||||
break
|
||||
}
|
||||
|
||||
if (whitespace(character)) {
|
||||
if (!pedantic) {
|
||||
break
|
||||
}
|
||||
|
||||
subqueue += character
|
||||
} else {
|
||||
if (character === leftParenthesis) {
|
||||
depth++
|
||||
} else if (character === rightParenthesis) {
|
||||
if (depth === 0) {
|
||||
break
|
||||
}
|
||||
|
||||
depth--
|
||||
}
|
||||
|
||||
queue += subqueue
|
||||
subqueue = ''
|
||||
|
||||
if (character === backslash) {
|
||||
queue += backslash
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
queue += character
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
subvalue += queue
|
||||
url = queue
|
||||
index = subvalue.length
|
||||
}
|
||||
|
||||
// Eat white-space.
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!whitespace(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
subvalue += queue
|
||||
|
||||
// Eat the title.
|
||||
if (
|
||||
queue &&
|
||||
(character === quotationMark ||
|
||||
character === apostrophe ||
|
||||
(commonmark && character === leftParenthesis))
|
||||
) {
|
||||
index++
|
||||
subvalue += character
|
||||
queue = ''
|
||||
marker = character === leftParenthesis ? rightParenthesis : character
|
||||
beforeTitle = subvalue
|
||||
|
||||
// In commonmark-mode, things are pretty easy: the marker cannot occur
|
||||
// inside the title. Non-commonmark does, however, support nested
|
||||
// delimiters.
|
||||
if (commonmark) {
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === marker) {
|
||||
break
|
||||
}
|
||||
|
||||
if (character === backslash) {
|
||||
queue += backslash
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
index++
|
||||
queue += character
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== marker) {
|
||||
return
|
||||
}
|
||||
|
||||
title = queue
|
||||
subvalue += queue + character
|
||||
index++
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!whitespace(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
index++
|
||||
}
|
||||
} else {
|
||||
subqueue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === marker) {
|
||||
if (hasMarker) {
|
||||
queue += marker + subqueue
|
||||
subqueue = ''
|
||||
}
|
||||
|
||||
hasMarker = true
|
||||
} else if (!hasMarker) {
|
||||
queue += character
|
||||
} else if (character === rightParenthesis) {
|
||||
subvalue += queue + marker + subqueue
|
||||
title = queue
|
||||
break
|
||||
} else if (whitespace(character)) {
|
||||
subqueue += character
|
||||
} else {
|
||||
queue += marker + subqueue + character
|
||||
subqueue = ''
|
||||
hasMarker = false
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value.charAt(index) !== rightParenthesis) {
|
||||
return
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
subvalue += rightParenthesis
|
||||
|
||||
url = self.decode.raw(self.unescape(url), eat(beforeURL).test().end, {
|
||||
nonTerminated: false
|
||||
})
|
||||
|
||||
if (title) {
|
||||
beforeTitle = eat(beforeTitle).test().end
|
||||
title = self.decode.raw(self.unescape(title), beforeTitle)
|
||||
}
|
||||
|
||||
node = {
|
||||
type: isImage ? 'image' : 'link',
|
||||
title: title || null,
|
||||
url: url
|
||||
}
|
||||
|
||||
if (isImage) {
|
||||
node.alt = self.decode.raw(self.unescape(content), now) || null
|
||||
} else {
|
||||
exit = self.enterLink()
|
||||
node.children = self.tokenizeInline(content, now)
|
||||
exit()
|
||||
}
|
||||
|
||||
return eat(subvalue)(node)
|
||||
}
|
||||
452
node_modules/remark-parse/lib/tokenize/list.js
generated
vendored
Normal file
452
node_modules/remark-parse/lib/tokenize/list.js
generated
vendored
Normal file
@@ -0,0 +1,452 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint-disable max-params */
|
||||
|
||||
var trim = require('trim')
|
||||
var repeat = require('repeat-string')
|
||||
var decimal = require('is-decimal')
|
||||
var getIndent = require('../util/get-indentation')
|
||||
var removeIndent = require('../util/remove-indentation')
|
||||
var interrupt = require('../util/interrupt')
|
||||
|
||||
module.exports = list
|
||||
|
||||
var asterisk = '*'
|
||||
var underscore = '_'
|
||||
var plusSign = '+'
|
||||
var dash = '-'
|
||||
var dot = '.'
|
||||
var space = ' '
|
||||
var lineFeed = '\n'
|
||||
var tab = '\t'
|
||||
var rightParenthesis = ')'
|
||||
var lowercaseX = 'x'
|
||||
|
||||
var tabSize = 4
|
||||
var looseListItemExpression = /\n\n(?!\s*$)/
|
||||
var taskItemExpression = /^\[([ \t]|x|X)][ \t]/
|
||||
var bulletExpression = /^([ \t]*)([*+-]|\d+[.)])( {1,4}(?! )| |\t|$|(?=\n))([^\n]*)/
|
||||
var pedanticBulletExpression = /^([ \t]*)([*+-]|\d+[.)])([ \t]+)/
|
||||
var initialIndentExpression = /^( {1,4}|\t)?/gm
|
||||
|
||||
function list(eat, value, silent) {
|
||||
var self = this
|
||||
var commonmark = self.options.commonmark
|
||||
var pedantic = self.options.pedantic
|
||||
var tokenizers = self.blockTokenizers
|
||||
var interuptors = self.interruptList
|
||||
var index = 0
|
||||
var length = value.length
|
||||
var start = null
|
||||
var size = 0
|
||||
var queue
|
||||
var ordered
|
||||
var character
|
||||
var marker
|
||||
var nextIndex
|
||||
var startIndex
|
||||
var prefixed
|
||||
var currentMarker
|
||||
var content
|
||||
var line
|
||||
var prevEmpty
|
||||
var empty
|
||||
var items
|
||||
var allLines
|
||||
var emptyLines
|
||||
var item
|
||||
var enterTop
|
||||
var exitBlockquote
|
||||
var spread = false
|
||||
var node
|
||||
var now
|
||||
var end
|
||||
var indented
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === tab) {
|
||||
size += tabSize - (size % tabSize)
|
||||
} else if (character === space) {
|
||||
size++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
if (size >= tabSize) {
|
||||
return
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === asterisk || character === plusSign || character === dash) {
|
||||
marker = character
|
||||
ordered = false
|
||||
} else {
|
||||
ordered = true
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!decimal(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (
|
||||
!queue ||
|
||||
!(character === dot || (commonmark && character === rightParenthesis))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
start = parseInt(queue, 10)
|
||||
marker = character
|
||||
}
|
||||
|
||||
character = value.charAt(++index)
|
||||
|
||||
if (
|
||||
character !== space &&
|
||||
character !== tab &&
|
||||
(pedantic || (character !== lineFeed && character !== ''))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
index = 0
|
||||
items = []
|
||||
allLines = []
|
||||
emptyLines = []
|
||||
|
||||
while (index < length) {
|
||||
nextIndex = value.indexOf(lineFeed, index)
|
||||
startIndex = index
|
||||
prefixed = false
|
||||
indented = false
|
||||
|
||||
if (nextIndex === -1) {
|
||||
nextIndex = length
|
||||
}
|
||||
|
||||
end = index + tabSize
|
||||
size = 0
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === tab) {
|
||||
size += tabSize - (size % tabSize)
|
||||
} else if (character === space) {
|
||||
size++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
if (size >= tabSize) {
|
||||
indented = true
|
||||
}
|
||||
|
||||
if (item && size >= item.indent) {
|
||||
indented = true
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
currentMarker = null
|
||||
|
||||
if (!indented) {
|
||||
if (
|
||||
character === asterisk ||
|
||||
character === plusSign ||
|
||||
character === dash
|
||||
) {
|
||||
currentMarker = character
|
||||
index++
|
||||
size++
|
||||
} else {
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!decimal(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
index++
|
||||
|
||||
if (
|
||||
queue &&
|
||||
(character === dot || (commonmark && character === rightParenthesis))
|
||||
) {
|
||||
currentMarker = character
|
||||
size += queue.length + 1
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMarker) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === tab) {
|
||||
size += tabSize - (size % tabSize)
|
||||
index++
|
||||
} else if (character === space) {
|
||||
end = index + tabSize
|
||||
|
||||
while (index < end) {
|
||||
if (value.charAt(index) !== space) {
|
||||
break
|
||||
}
|
||||
|
||||
index++
|
||||
size++
|
||||
}
|
||||
|
||||
if (index === end && value.charAt(index) === space) {
|
||||
index -= tabSize - 1
|
||||
size -= tabSize - 1
|
||||
}
|
||||
} else if (character !== lineFeed && character !== '') {
|
||||
currentMarker = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMarker) {
|
||||
if (!pedantic && marker !== currentMarker) {
|
||||
break
|
||||
}
|
||||
|
||||
prefixed = true
|
||||
} else {
|
||||
if (!commonmark && !indented && value.charAt(startIndex) === space) {
|
||||
indented = true
|
||||
} else if (commonmark && item) {
|
||||
indented = size >= item.indent || size > tabSize
|
||||
}
|
||||
|
||||
prefixed = false
|
||||
index = startIndex
|
||||
}
|
||||
|
||||
line = value.slice(startIndex, nextIndex)
|
||||
content = startIndex === index ? line : value.slice(index, nextIndex)
|
||||
|
||||
if (
|
||||
currentMarker === asterisk ||
|
||||
currentMarker === underscore ||
|
||||
currentMarker === dash
|
||||
) {
|
||||
if (tokenizers.thematicBreak.call(self, eat, line, true)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
prevEmpty = empty
|
||||
empty = !prefixed && !trim(content).length
|
||||
|
||||
if (indented && item) {
|
||||
item.value = item.value.concat(emptyLines, line)
|
||||
allLines = allLines.concat(emptyLines, line)
|
||||
emptyLines = []
|
||||
} else if (prefixed) {
|
||||
if (emptyLines.length !== 0) {
|
||||
spread = true
|
||||
item.value.push('')
|
||||
item.trail = emptyLines.concat()
|
||||
}
|
||||
|
||||
item = {
|
||||
value: [line],
|
||||
indent: size,
|
||||
trail: []
|
||||
}
|
||||
|
||||
items.push(item)
|
||||
allLines = allLines.concat(emptyLines, line)
|
||||
emptyLines = []
|
||||
} else if (empty) {
|
||||
if (prevEmpty && !commonmark) {
|
||||
break
|
||||
}
|
||||
|
||||
emptyLines.push(line)
|
||||
} else {
|
||||
if (prevEmpty) {
|
||||
break
|
||||
}
|
||||
|
||||
if (interrupt(interuptors, tokenizers, self, [eat, line, true])) {
|
||||
break
|
||||
}
|
||||
|
||||
item.value = item.value.concat(emptyLines, line)
|
||||
allLines = allLines.concat(emptyLines, line)
|
||||
emptyLines = []
|
||||
}
|
||||
|
||||
index = nextIndex + 1
|
||||
}
|
||||
|
||||
node = eat(allLines.join(lineFeed)).reset({
|
||||
type: 'list',
|
||||
ordered: ordered,
|
||||
start: start,
|
||||
spread: spread,
|
||||
children: []
|
||||
})
|
||||
|
||||
enterTop = self.enterList()
|
||||
exitBlockquote = self.enterBlock()
|
||||
index = -1
|
||||
length = items.length
|
||||
|
||||
while (++index < length) {
|
||||
item = items[index].value.join(lineFeed)
|
||||
now = eat.now()
|
||||
|
||||
eat(item)(listItem(self, item, now), node)
|
||||
|
||||
item = items[index].trail.join(lineFeed)
|
||||
|
||||
if (index !== length - 1) {
|
||||
item += lineFeed
|
||||
}
|
||||
|
||||
eat(item)
|
||||
}
|
||||
|
||||
enterTop()
|
||||
exitBlockquote()
|
||||
|
||||
return node
|
||||
}
|
||||
|
||||
function listItem(ctx, value, position) {
|
||||
var offsets = ctx.offset
|
||||
var fn = ctx.options.pedantic ? pedanticListItem : normalListItem
|
||||
var checked = null
|
||||
var task
|
||||
var indent
|
||||
|
||||
value = fn.apply(null, arguments)
|
||||
|
||||
if (ctx.options.gfm) {
|
||||
task = value.match(taskItemExpression)
|
||||
|
||||
if (task) {
|
||||
indent = task[0].length
|
||||
checked = task[1].toLowerCase() === lowercaseX
|
||||
offsets[position.line] += indent
|
||||
value = value.slice(indent)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'listItem',
|
||||
spread: looseListItemExpression.test(value),
|
||||
checked: checked,
|
||||
children: ctx.tokenizeBlock(value, position)
|
||||
}
|
||||
}
|
||||
|
||||
// Create a list-item using overly simple mechanics.
|
||||
function pedanticListItem(ctx, value, position) {
|
||||
var offsets = ctx.offset
|
||||
var line = position.line
|
||||
|
||||
// Remove the list-item’s bullet.
|
||||
value = value.replace(pedanticBulletExpression, replacer)
|
||||
|
||||
// The initial line was also matched by the below, so we reset the `line`.
|
||||
line = position.line
|
||||
|
||||
return value.replace(initialIndentExpression, replacer)
|
||||
|
||||
// A simple replacer which removed all matches, and adds their length to
|
||||
// `offset`.
|
||||
function replacer($0) {
|
||||
offsets[line] = (offsets[line] || 0) + $0.length
|
||||
line++
|
||||
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
// Create a list-item using sane mechanics.
|
||||
function normalListItem(ctx, value, position) {
|
||||
var offsets = ctx.offset
|
||||
var line = position.line
|
||||
var max
|
||||
var bullet
|
||||
var rest
|
||||
var lines
|
||||
var trimmedLines
|
||||
var index
|
||||
var length
|
||||
|
||||
// Remove the list-item’s bullet.
|
||||
value = value.replace(bulletExpression, replacer)
|
||||
|
||||
lines = value.split(lineFeed)
|
||||
|
||||
trimmedLines = removeIndent(value, getIndent(max).indent).split(lineFeed)
|
||||
|
||||
// We replaced the initial bullet with something else above, which was used
|
||||
// to trick `removeIndentation` into removing some more characters when
|
||||
// possible. However, that could result in the initial line to be stripped
|
||||
// more than it should be.
|
||||
trimmedLines[0] = rest
|
||||
|
||||
offsets[line] = (offsets[line] || 0) + bullet.length
|
||||
line++
|
||||
|
||||
index = 0
|
||||
length = lines.length
|
||||
|
||||
while (++index < length) {
|
||||
offsets[line] =
|
||||
(offsets[line] || 0) + lines[index].length - trimmedLines[index].length
|
||||
line++
|
||||
}
|
||||
|
||||
return trimmedLines.join(lineFeed)
|
||||
|
||||
function replacer($0, $1, $2, $3, $4) {
|
||||
bullet = $1 + $2 + $3
|
||||
rest = $4
|
||||
|
||||
// Make sure that the first nine numbered list items can indent with an
|
||||
// extra space. That is, when the bullet did not receive an extra final
|
||||
// space.
|
||||
if (Number($2) < 10 && bullet.length % 2 === 1) {
|
||||
$2 = space + $2
|
||||
}
|
||||
|
||||
max = $1 + repeat(space, $2.length) + $3
|
||||
|
||||
return max + rest
|
||||
}
|
||||
}
|
||||
48
node_modules/remark-parse/lib/tokenize/newline.js
generated
vendored
Normal file
48
node_modules/remark-parse/lib/tokenize/newline.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
|
||||
module.exports = newline
|
||||
|
||||
var lineFeed = '\n'
|
||||
|
||||
function newline(eat, value, silent) {
|
||||
var character = value.charAt(0)
|
||||
var length
|
||||
var subvalue
|
||||
var queue
|
||||
var index
|
||||
|
||||
if (character !== lineFeed) {
|
||||
return
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
index = 1
|
||||
length = value.length
|
||||
subvalue = character
|
||||
queue = ''
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!whitespace(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
|
||||
if (character === lineFeed) {
|
||||
subvalue += queue
|
||||
queue = ''
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
eat(subvalue)
|
||||
}
|
||||
117
node_modules/remark-parse/lib/tokenize/paragraph.js
generated
vendored
Normal file
117
node_modules/remark-parse/lib/tokenize/paragraph.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
'use strict'
|
||||
|
||||
var trim = require('trim')
|
||||
var decimal = require('is-decimal')
|
||||
var trimTrailingLines = require('trim-trailing-lines')
|
||||
var interrupt = require('../util/interrupt')
|
||||
|
||||
module.exports = paragraph
|
||||
|
||||
var tab = '\t'
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
|
||||
var tabSize = 4
|
||||
|
||||
// Tokenise paragraph.
|
||||
function paragraph(eat, value, silent) {
|
||||
var self = this
|
||||
var settings = self.options
|
||||
var commonmark = settings.commonmark
|
||||
var gfm = settings.gfm
|
||||
var tokenizers = self.blockTokenizers
|
||||
var interruptors = self.interruptParagraph
|
||||
var index = value.indexOf(lineFeed)
|
||||
var length = value.length
|
||||
var position
|
||||
var subvalue
|
||||
var character
|
||||
var size
|
||||
var now
|
||||
|
||||
while (index < length) {
|
||||
// Eat everything if there’s no following newline.
|
||||
if (index === -1) {
|
||||
index = length
|
||||
break
|
||||
}
|
||||
|
||||
// Stop if the next character is NEWLINE.
|
||||
if (value.charAt(index + 1) === lineFeed) {
|
||||
break
|
||||
}
|
||||
|
||||
// In commonmark-mode, following indented lines are part of the paragraph.
|
||||
if (commonmark) {
|
||||
size = 0
|
||||
position = index + 1
|
||||
|
||||
while (position < length) {
|
||||
character = value.charAt(position)
|
||||
|
||||
if (character === tab) {
|
||||
size = tabSize
|
||||
break
|
||||
} else if (character === space) {
|
||||
size++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
position++
|
||||
}
|
||||
|
||||
if (size >= tabSize && character !== lineFeed) {
|
||||
index = value.indexOf(lineFeed, index + 1)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
subvalue = value.slice(index + 1)
|
||||
|
||||
// Check if the following code contains a possible block.
|
||||
if (interrupt(interruptors, tokenizers, self, [eat, subvalue, true])) {
|
||||
break
|
||||
}
|
||||
|
||||
// Break if the following line starts a list, when already in a list, or
|
||||
// when in commonmark, or when in gfm mode and the bullet is *not* numeric.
|
||||
if (
|
||||
tokenizers.list.call(self, eat, subvalue, true) &&
|
||||
(self.inList ||
|
||||
commonmark ||
|
||||
(gfm && !decimal(trim.left(subvalue).charAt(0))))
|
||||
) {
|
||||
break
|
||||
}
|
||||
|
||||
position = index
|
||||
index = value.indexOf(lineFeed, index + 1)
|
||||
|
||||
if (index !== -1 && trim(value.slice(position, index)) === '') {
|
||||
index = position
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
subvalue = value.slice(0, index)
|
||||
|
||||
if (trim(subvalue) === '') {
|
||||
eat(subvalue)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
now = eat.now()
|
||||
subvalue = trimTrailingLines(subvalue)
|
||||
|
||||
return eat(subvalue)({
|
||||
type: 'paragraph',
|
||||
children: self.tokenizeInline(subvalue, now)
|
||||
})
|
||||
}
|
||||
215
node_modules/remark-parse/lib/tokenize/reference.js
generated
vendored
Normal file
215
node_modules/remark-parse/lib/tokenize/reference.js
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var locate = require('../locate/link')
|
||||
var normalize = require('../util/normalize')
|
||||
|
||||
module.exports = reference
|
||||
reference.locator = locate
|
||||
|
||||
var link = 'link'
|
||||
var image = 'image'
|
||||
var footnote = 'footnote'
|
||||
var shortcut = 'shortcut'
|
||||
var collapsed = 'collapsed'
|
||||
var full = 'full'
|
||||
var space = ' '
|
||||
var exclamationMark = '!'
|
||||
var leftSquareBracket = '['
|
||||
var backslash = '\\'
|
||||
var rightSquareBracket = ']'
|
||||
var caret = '^'
|
||||
|
||||
function reference(eat, value, silent) {
|
||||
var self = this
|
||||
var commonmark = self.options.commonmark
|
||||
var character = value.charAt(0)
|
||||
var index = 0
|
||||
var length = value.length
|
||||
var subvalue = ''
|
||||
var intro = ''
|
||||
var type = link
|
||||
var referenceType = shortcut
|
||||
var content
|
||||
var identifier
|
||||
var now
|
||||
var node
|
||||
var exit
|
||||
var queue
|
||||
var bracketed
|
||||
var depth
|
||||
|
||||
// Check whether we’re eating an image.
|
||||
if (character === exclamationMark) {
|
||||
type = image
|
||||
intro = character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
if (character !== leftSquareBracket) {
|
||||
return
|
||||
}
|
||||
|
||||
index++
|
||||
intro += character
|
||||
queue = ''
|
||||
|
||||
// Check whether we’re eating a footnote.
|
||||
if (self.options.footnotes && value.charAt(index) === caret) {
|
||||
// Exit if `![^` is found, so the `!` will be seen as text after this,
|
||||
// and we’ll enter this function again when `[^` is found.
|
||||
if (type === image) {
|
||||
return
|
||||
}
|
||||
|
||||
intro += caret
|
||||
index++
|
||||
type = footnote
|
||||
}
|
||||
|
||||
// Eat the text.
|
||||
depth = 0
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === leftSquareBracket) {
|
||||
bracketed = true
|
||||
depth++
|
||||
} else if (character === rightSquareBracket) {
|
||||
if (!depth) {
|
||||
break
|
||||
}
|
||||
|
||||
depth--
|
||||
}
|
||||
|
||||
if (character === backslash) {
|
||||
queue += backslash
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
subvalue = queue
|
||||
content = queue
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== rightSquareBracket) {
|
||||
return
|
||||
}
|
||||
|
||||
index++
|
||||
subvalue += character
|
||||
queue = ''
|
||||
|
||||
if (!commonmark) {
|
||||
// The original markdown syntax definition explicitly allows for whitespace
|
||||
// between the link text and link label; commonmark departs from this, in
|
||||
// part to improve support for shortcut reference links
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (!whitespace(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
// Inline footnotes cannot have an identifier.
|
||||
if (type !== footnote && character === leftSquareBracket) {
|
||||
identifier = ''
|
||||
queue += character
|
||||
index++
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === leftSquareBracket || character === rightSquareBracket) {
|
||||
break
|
||||
}
|
||||
|
||||
if (character === backslash) {
|
||||
identifier += backslash
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
identifier += character
|
||||
index++
|
||||
}
|
||||
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === rightSquareBracket) {
|
||||
referenceType = identifier ? full : collapsed
|
||||
queue += identifier + character
|
||||
index++
|
||||
} else {
|
||||
identifier = ''
|
||||
}
|
||||
|
||||
subvalue += queue
|
||||
queue = ''
|
||||
} else {
|
||||
if (!content) {
|
||||
return
|
||||
}
|
||||
|
||||
identifier = content
|
||||
}
|
||||
|
||||
// Brackets cannot be inside the identifier.
|
||||
if (referenceType !== full && bracketed) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue = intro + subvalue
|
||||
|
||||
if (type === link && self.inLink) {
|
||||
return null
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (type === footnote && content.indexOf(space) !== -1) {
|
||||
return eat(subvalue)({
|
||||
type: footnote,
|
||||
children: this.tokenizeInline(content, eat.now())
|
||||
})
|
||||
}
|
||||
|
||||
now = eat.now()
|
||||
now.column += intro.length
|
||||
now.offset += intro.length
|
||||
identifier = referenceType === full ? identifier : content
|
||||
|
||||
node = {
|
||||
type: type + 'Reference',
|
||||
identifier: normalize(identifier),
|
||||
label: identifier
|
||||
}
|
||||
|
||||
if (type === link || type === image) {
|
||||
node.referenceType = referenceType
|
||||
}
|
||||
|
||||
if (type === link) {
|
||||
exit = self.enterLink()
|
||||
node.children = self.tokenizeInline(content, now)
|
||||
exit()
|
||||
} else if (type === image) {
|
||||
node.alt = self.decode.raw(self.unescape(content), now) || null
|
||||
}
|
||||
|
||||
return eat(subvalue)(node)
|
||||
}
|
||||
85
node_modules/remark-parse/lib/tokenize/strong.js
generated
vendored
Normal file
85
node_modules/remark-parse/lib/tokenize/strong.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
'use strict'
|
||||
|
||||
var trim = require('trim')
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var locate = require('../locate/strong')
|
||||
|
||||
module.exports = strong
|
||||
strong.locator = locate
|
||||
|
||||
var backslash = '\\'
|
||||
var asterisk = '*'
|
||||
var underscore = '_'
|
||||
|
||||
function strong(eat, value, silent) {
|
||||
var self = this
|
||||
var index = 0
|
||||
var character = value.charAt(index)
|
||||
var now
|
||||
var pedantic
|
||||
var marker
|
||||
var queue
|
||||
var subvalue
|
||||
var length
|
||||
var prev
|
||||
|
||||
if (
|
||||
(character !== asterisk && character !== underscore) ||
|
||||
value.charAt(++index) !== character
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
pedantic = self.options.pedantic
|
||||
marker = character
|
||||
subvalue = marker + marker
|
||||
length = value.length
|
||||
index++
|
||||
queue = ''
|
||||
character = ''
|
||||
|
||||
if (pedantic && whitespace(value.charAt(index))) {
|
||||
return
|
||||
}
|
||||
|
||||
while (index < length) {
|
||||
prev = character
|
||||
character = value.charAt(index)
|
||||
|
||||
if (
|
||||
character === marker &&
|
||||
value.charAt(index + 1) === marker &&
|
||||
(!pedantic || !whitespace(prev))
|
||||
) {
|
||||
character = value.charAt(index + 2)
|
||||
|
||||
if (character !== marker) {
|
||||
if (!trim(queue)) {
|
||||
return
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
now = eat.now()
|
||||
now.column += 2
|
||||
now.offset += 2
|
||||
|
||||
return eat(subvalue + queue + subvalue)({
|
||||
type: 'strong',
|
||||
children: self.tokenizeInline(queue, now)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!pedantic && character === backslash) {
|
||||
queue += character
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
}
|
||||
259
node_modules/remark-parse/lib/tokenize/table.js
generated
vendored
Normal file
259
node_modules/remark-parse/lib/tokenize/table.js
generated
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
'use strict'
|
||||
|
||||
var whitespace = require('is-whitespace-character')
|
||||
|
||||
module.exports = table
|
||||
|
||||
var tab = '\t'
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var dash = '-'
|
||||
var colon = ':'
|
||||
var backslash = '\\'
|
||||
var graveAccent = '`'
|
||||
var verticalBar = '|'
|
||||
|
||||
var minColumns = 1
|
||||
var minRows = 2
|
||||
|
||||
var left = 'left'
|
||||
var center = 'center'
|
||||
var right = 'right'
|
||||
|
||||
function table(eat, value, silent) {
|
||||
var self = this
|
||||
var index
|
||||
var alignments
|
||||
var alignment
|
||||
var subvalue
|
||||
var row
|
||||
var length
|
||||
var lines
|
||||
var queue
|
||||
var character
|
||||
var hasDash
|
||||
var align
|
||||
var cell
|
||||
var preamble
|
||||
var count
|
||||
var opening
|
||||
var now
|
||||
var position
|
||||
var lineCount
|
||||
var line
|
||||
var rows
|
||||
var table
|
||||
var lineIndex
|
||||
var pipeIndex
|
||||
var first
|
||||
|
||||
// Exit when not in gfm-mode.
|
||||
if (!self.options.gfm) {
|
||||
return
|
||||
}
|
||||
|
||||
// Get the rows.
|
||||
// Detecting tables soon is hard, so there are some checks for performance
|
||||
// here, such as the minimum number of rows, and allowed characters in the
|
||||
// alignment row.
|
||||
index = 0
|
||||
lineCount = 0
|
||||
length = value.length + 1
|
||||
lines = []
|
||||
|
||||
while (index < length) {
|
||||
lineIndex = value.indexOf(lineFeed, index)
|
||||
pipeIndex = value.indexOf(verticalBar, index + 1)
|
||||
|
||||
if (lineIndex === -1) {
|
||||
lineIndex = value.length
|
||||
}
|
||||
|
||||
if (pipeIndex === -1 || pipeIndex > lineIndex) {
|
||||
if (lineCount < minRows) {
|
||||
return
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
lines.push(value.slice(index, lineIndex))
|
||||
lineCount++
|
||||
index = lineIndex + 1
|
||||
}
|
||||
|
||||
// Parse the alignment row.
|
||||
subvalue = lines.join(lineFeed)
|
||||
alignments = lines.splice(1, 1)[0] || []
|
||||
index = 0
|
||||
length = alignments.length
|
||||
lineCount--
|
||||
alignment = false
|
||||
align = []
|
||||
|
||||
while (index < length) {
|
||||
character = alignments.charAt(index)
|
||||
|
||||
if (character === verticalBar) {
|
||||
hasDash = null
|
||||
|
||||
if (alignment === false) {
|
||||
if (first === false) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
align.push(alignment)
|
||||
alignment = false
|
||||
}
|
||||
|
||||
first = false
|
||||
} else if (character === dash) {
|
||||
hasDash = true
|
||||
alignment = alignment || null
|
||||
} else if (character === colon) {
|
||||
if (alignment === left) {
|
||||
alignment = center
|
||||
} else if (hasDash && alignment === null) {
|
||||
alignment = right
|
||||
} else {
|
||||
alignment = left
|
||||
}
|
||||
} else if (!whitespace(character)) {
|
||||
return
|
||||
}
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
if (alignment !== false) {
|
||||
align.push(alignment)
|
||||
}
|
||||
|
||||
// Exit when without enough columns.
|
||||
if (align.length < minColumns) {
|
||||
return
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Parse the rows.
|
||||
position = -1
|
||||
rows = []
|
||||
|
||||
table = eat(subvalue).reset({type: 'table', align: align, children: rows})
|
||||
|
||||
while (++position < lineCount) {
|
||||
line = lines[position]
|
||||
row = {type: 'tableRow', children: []}
|
||||
|
||||
// Eat a newline character when this is not the first row.
|
||||
if (position) {
|
||||
eat(lineFeed)
|
||||
}
|
||||
|
||||
// Eat the row.
|
||||
eat(line).reset(row, table)
|
||||
|
||||
length = line.length + 1
|
||||
index = 0
|
||||
queue = ''
|
||||
cell = ''
|
||||
preamble = true
|
||||
count = null
|
||||
opening = null
|
||||
|
||||
while (index < length) {
|
||||
character = line.charAt(index)
|
||||
|
||||
if (character === tab || character === space) {
|
||||
if (cell) {
|
||||
queue += character
|
||||
} else {
|
||||
eat(character)
|
||||
}
|
||||
|
||||
index++
|
||||
continue
|
||||
}
|
||||
|
||||
if (character === '' || character === verticalBar) {
|
||||
if (preamble) {
|
||||
eat(character)
|
||||
} else {
|
||||
if (character && opening) {
|
||||
queue += character
|
||||
index++
|
||||
continue
|
||||
}
|
||||
|
||||
if ((cell || character) && !preamble) {
|
||||
subvalue = cell
|
||||
|
||||
if (queue.length > 1) {
|
||||
if (character) {
|
||||
subvalue += queue.slice(0, queue.length - 1)
|
||||
queue = queue.charAt(queue.length - 1)
|
||||
} else {
|
||||
subvalue += queue
|
||||
queue = ''
|
||||
}
|
||||
}
|
||||
|
||||
now = eat.now()
|
||||
|
||||
eat(subvalue)(
|
||||
{type: 'tableCell', children: self.tokenizeInline(cell, now)},
|
||||
row
|
||||
)
|
||||
}
|
||||
|
||||
eat(queue + character)
|
||||
|
||||
queue = ''
|
||||
cell = ''
|
||||
}
|
||||
} else {
|
||||
if (queue) {
|
||||
cell += queue
|
||||
queue = ''
|
||||
}
|
||||
|
||||
cell += character
|
||||
|
||||
if (character === backslash && index !== length - 2) {
|
||||
cell += line.charAt(index + 1)
|
||||
index++
|
||||
}
|
||||
|
||||
if (character === graveAccent) {
|
||||
count = 1
|
||||
|
||||
while (line.charAt(index + 1) === character) {
|
||||
cell += character
|
||||
index++
|
||||
count++
|
||||
}
|
||||
|
||||
if (!opening) {
|
||||
opening = count
|
||||
} else if (count >= opening) {
|
||||
opening = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preamble = false
|
||||
index++
|
||||
}
|
||||
|
||||
// Eat the alignment row.
|
||||
if (!position) {
|
||||
eat(lineFeed + alignments)
|
||||
}
|
||||
}
|
||||
|
||||
return table
|
||||
}
|
||||
57
node_modules/remark-parse/lib/tokenize/text.js
generated
vendored
Normal file
57
node_modules/remark-parse/lib/tokenize/text.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = text
|
||||
|
||||
function text(eat, value, silent) {
|
||||
var self = this
|
||||
var methods
|
||||
var tokenizers
|
||||
var index
|
||||
var length
|
||||
var subvalue
|
||||
var position
|
||||
var tokenizer
|
||||
var name
|
||||
var min
|
||||
var now
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
methods = self.inlineMethods
|
||||
length = methods.length
|
||||
tokenizers = self.inlineTokenizers
|
||||
index = -1
|
||||
min = value.length
|
||||
|
||||
while (++index < length) {
|
||||
name = methods[index]
|
||||
|
||||
if (name === 'text' || !tokenizers[name]) {
|
||||
continue
|
||||
}
|
||||
|
||||
tokenizer = tokenizers[name].locator
|
||||
|
||||
if (!tokenizer) {
|
||||
eat.file.fail('Missing locator: `' + name + '`')
|
||||
}
|
||||
|
||||
position = tokenizer.call(self, value, 1)
|
||||
|
||||
if (position !== -1 && position < min) {
|
||||
min = position
|
||||
}
|
||||
}
|
||||
|
||||
subvalue = value.slice(0, min)
|
||||
now = eat.now()
|
||||
|
||||
self.decode(subvalue, now, handler)
|
||||
|
||||
function handler(content, position, source) {
|
||||
eat(source || content)({type: 'text', value: content})
|
||||
}
|
||||
}
|
||||
70
node_modules/remark-parse/lib/tokenize/thematic-break.js
generated
vendored
Normal file
70
node_modules/remark-parse/lib/tokenize/thematic-break.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = thematicBreak
|
||||
|
||||
var tab = '\t'
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var asterisk = '*'
|
||||
var dash = '-'
|
||||
var underscore = '_'
|
||||
|
||||
var maxCount = 3
|
||||
|
||||
function thematicBreak(eat, value, silent) {
|
||||
var index = -1
|
||||
var length = value.length + 1
|
||||
var subvalue = ''
|
||||
var character
|
||||
var marker
|
||||
var markerCount
|
||||
var queue
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character !== tab && character !== space) {
|
||||
break
|
||||
}
|
||||
|
||||
subvalue += character
|
||||
}
|
||||
|
||||
if (
|
||||
character !== asterisk &&
|
||||
character !== dash &&
|
||||
character !== underscore
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
marker = character
|
||||
subvalue += character
|
||||
markerCount = 1
|
||||
queue = ''
|
||||
|
||||
while (++index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (character === marker) {
|
||||
markerCount++
|
||||
subvalue += queue + marker
|
||||
queue = ''
|
||||
} else if (character === space) {
|
||||
queue += character
|
||||
} else if (
|
||||
markerCount >= maxCount &&
|
||||
(!character || character === lineFeed)
|
||||
) {
|
||||
subvalue += queue
|
||||
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
return eat(subvalue)({type: 'thematicBreak'})
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
153
node_modules/remark-parse/lib/tokenize/url.js
generated
vendored
Normal file
153
node_modules/remark-parse/lib/tokenize/url.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
'use strict'
|
||||
|
||||
var decode = require('parse-entities')
|
||||
var whitespace = require('is-whitespace-character')
|
||||
var locate = require('../locate/url')
|
||||
|
||||
module.exports = url
|
||||
url.locator = locate
|
||||
url.notInLink = true
|
||||
|
||||
var quotationMark = '"'
|
||||
var apostrophe = "'"
|
||||
var leftParenthesis = '('
|
||||
var rightParenthesis = ')'
|
||||
var comma = ','
|
||||
var dot = '.'
|
||||
var colon = ':'
|
||||
var semicolon = ';'
|
||||
var lessThan = '<'
|
||||
var atSign = '@'
|
||||
var leftSquareBracket = '['
|
||||
var rightSquareBracket = ']'
|
||||
|
||||
var http = 'http://'
|
||||
var https = 'https://'
|
||||
var mailto = 'mailto:'
|
||||
|
||||
var protocols = [http, https, mailto]
|
||||
|
||||
var protocolsLength = protocols.length
|
||||
|
||||
function url(eat, value, silent) {
|
||||
var self = this
|
||||
var subvalue
|
||||
var content
|
||||
var character
|
||||
var index
|
||||
var position
|
||||
var protocol
|
||||
var match
|
||||
var length
|
||||
var queue
|
||||
var parenCount
|
||||
var nextCharacter
|
||||
var tokenizers
|
||||
var exit
|
||||
|
||||
if (!self.options.gfm) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue = ''
|
||||
index = -1
|
||||
|
||||
while (++index < protocolsLength) {
|
||||
protocol = protocols[index]
|
||||
match = value.slice(0, protocol.length)
|
||||
|
||||
if (match.toLowerCase() === protocol) {
|
||||
subvalue = match
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!subvalue) {
|
||||
return
|
||||
}
|
||||
|
||||
index = subvalue.length
|
||||
length = value.length
|
||||
queue = ''
|
||||
parenCount = 0
|
||||
|
||||
while (index < length) {
|
||||
character = value.charAt(index)
|
||||
|
||||
if (whitespace(character) || character === lessThan) {
|
||||
break
|
||||
}
|
||||
|
||||
if (
|
||||
character === dot ||
|
||||
character === comma ||
|
||||
character === colon ||
|
||||
character === semicolon ||
|
||||
character === quotationMark ||
|
||||
character === apostrophe ||
|
||||
character === rightParenthesis ||
|
||||
character === rightSquareBracket
|
||||
) {
|
||||
nextCharacter = value.charAt(index + 1)
|
||||
|
||||
if (!nextCharacter || whitespace(nextCharacter)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (character === leftParenthesis || character === leftSquareBracket) {
|
||||
parenCount++
|
||||
}
|
||||
|
||||
if (character === rightParenthesis || character === rightSquareBracket) {
|
||||
parenCount--
|
||||
|
||||
if (parenCount < 0) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
queue += character
|
||||
index++
|
||||
}
|
||||
|
||||
if (!queue) {
|
||||
return
|
||||
}
|
||||
|
||||
subvalue += queue
|
||||
content = subvalue
|
||||
|
||||
if (protocol === mailto) {
|
||||
position = queue.indexOf(atSign)
|
||||
|
||||
if (position === -1 || position === length - 1) {
|
||||
return
|
||||
}
|
||||
|
||||
content = content.substr(mailto.length)
|
||||
}
|
||||
|
||||
/* istanbul ignore if - never used (yet) */
|
||||
if (silent) {
|
||||
return true
|
||||
}
|
||||
|
||||
exit = self.enterLink()
|
||||
|
||||
// Temporarily remove all tokenizers except text in url.
|
||||
tokenizers = self.inlineTokenizers
|
||||
self.inlineTokenizers = {text: tokenizers.text}
|
||||
|
||||
content = self.tokenizeInline(content, eat.now())
|
||||
|
||||
self.inlineTokenizers = tokenizers
|
||||
exit()
|
||||
|
||||
return eat(subvalue)({
|
||||
type: 'link',
|
||||
title: null,
|
||||
url: decode(subvalue, {nonTerminated: false}),
|
||||
children: content
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user