This commit is contained in:
33
node_modules/remark-parse/lib/util/get-indentation.js
generated
vendored
Normal file
33
node_modules/remark-parse/lib/util/get-indentation.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = indentation
|
||||
|
||||
var tab = '\t'
|
||||
var space = ' '
|
||||
|
||||
var spaceSize = 1
|
||||
var tabSize = 4
|
||||
|
||||
// Gets indentation information for a line.
|
||||
function indentation(value) {
|
||||
var index = 0
|
||||
var indent = 0
|
||||
var character = value.charAt(index)
|
||||
var stops = {}
|
||||
var size
|
||||
|
||||
while (character === tab || character === space) {
|
||||
size = character === tab ? tabSize : spaceSize
|
||||
|
||||
indent += size
|
||||
|
||||
if (size > 1) {
|
||||
indent = Math.floor(indent / size) * size
|
||||
}
|
||||
|
||||
stops[indent] = index
|
||||
character = value.charAt(++index)
|
||||
}
|
||||
|
||||
return {indent: indent, stops: stops}
|
||||
}
|
||||
34
node_modules/remark-parse/lib/util/html.js
generated
vendored
Normal file
34
node_modules/remark-parse/lib/util/html.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict'
|
||||
|
||||
var attributeName = '[a-zA-Z_:][a-zA-Z0-9:._-]*'
|
||||
var unquoted = '[^"\'=<>`\\u0000-\\u0020]+'
|
||||
var singleQuoted = "'[^']*'"
|
||||
var doubleQuoted = '"[^"]*"'
|
||||
var attributeValue =
|
||||
'(?:' + unquoted + '|' + singleQuoted + '|' + doubleQuoted + ')'
|
||||
var attribute =
|
||||
'(?:\\s+' + attributeName + '(?:\\s*=\\s*' + attributeValue + ')?)'
|
||||
var openTag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'
|
||||
var closeTag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'
|
||||
var comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->'
|
||||
var processing = '<[?].*?[?]>'
|
||||
var declaration = '<![A-Za-z]+\\s+[^>]*>'
|
||||
var cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'
|
||||
|
||||
exports.openCloseTag = new RegExp('^(?:' + openTag + '|' + closeTag + ')')
|
||||
|
||||
exports.tag = new RegExp(
|
||||
'^(?:' +
|
||||
openTag +
|
||||
'|' +
|
||||
closeTag +
|
||||
'|' +
|
||||
comment +
|
||||
'|' +
|
||||
processing +
|
||||
'|' +
|
||||
declaration +
|
||||
'|' +
|
||||
cdata +
|
||||
')'
|
||||
)
|
||||
35
node_modules/remark-parse/lib/util/interrupt.js
generated
vendored
Normal file
35
node_modules/remark-parse/lib/util/interrupt.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = interrupt
|
||||
|
||||
function interrupt(interruptors, tokenizers, ctx, params) {
|
||||
var length = interruptors.length
|
||||
var index = -1
|
||||
var interruptor
|
||||
var config
|
||||
|
||||
while (++index < length) {
|
||||
interruptor = interruptors[index]
|
||||
config = interruptor[1] || {}
|
||||
|
||||
if (
|
||||
config.pedantic !== undefined &&
|
||||
config.pedantic !== ctx.options.pedantic
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (
|
||||
config.commonmark !== undefined &&
|
||||
config.commonmark !== ctx.options.commonmark
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (tokenizers[interruptor[0]].apply(ctx, params)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
11
node_modules/remark-parse/lib/util/normalize.js
generated
vendored
Normal file
11
node_modules/remark-parse/lib/util/normalize.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
var collapseWhiteSpace = require('collapse-white-space')
|
||||
|
||||
module.exports = normalize
|
||||
|
||||
// Normalize an identifier. Collapses multiple white space characters into a
|
||||
// single space, and removes casing.
|
||||
function normalize(value) {
|
||||
return collapseWhiteSpace(value).toLowerCase()
|
||||
}
|
||||
77
node_modules/remark-parse/lib/util/remove-indentation.js
generated
vendored
Normal file
77
node_modules/remark-parse/lib/util/remove-indentation.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
'use strict'
|
||||
|
||||
var trim = require('trim')
|
||||
var repeat = require('repeat-string')
|
||||
var getIndent = require('./get-indentation')
|
||||
|
||||
module.exports = indentation
|
||||
|
||||
var tab = '\t'
|
||||
var lineFeed = '\n'
|
||||
var space = ' '
|
||||
var exclamationMark = '!'
|
||||
|
||||
// Remove the minimum indent from every line in `value`. Supports both tab,
|
||||
// spaced, and mixed indentation (as well as possible).
|
||||
function indentation(value, maximum) {
|
||||
var values = value.split(lineFeed)
|
||||
var position = values.length + 1
|
||||
var minIndent = Infinity
|
||||
var matrix = []
|
||||
var index
|
||||
var indentation
|
||||
var stops
|
||||
var padding
|
||||
|
||||
values.unshift(repeat(space, maximum) + exclamationMark)
|
||||
|
||||
while (position--) {
|
||||
indentation = getIndent(values[position])
|
||||
|
||||
matrix[position] = indentation.stops
|
||||
|
||||
if (trim(values[position]).length === 0) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (indentation.indent) {
|
||||
if (indentation.indent > 0 && indentation.indent < minIndent) {
|
||||
minIndent = indentation.indent
|
||||
}
|
||||
} else {
|
||||
minIndent = Infinity
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (minIndent !== Infinity) {
|
||||
position = values.length
|
||||
|
||||
while (position--) {
|
||||
stops = matrix[position]
|
||||
index = minIndent
|
||||
|
||||
while (index && !(index in stops)) {
|
||||
index--
|
||||
}
|
||||
|
||||
if (
|
||||
trim(values[position]).length !== 0 &&
|
||||
minIndent &&
|
||||
index !== minIndent
|
||||
) {
|
||||
padding = tab
|
||||
} else {
|
||||
padding = ''
|
||||
}
|
||||
|
||||
values[position] =
|
||||
padding + values[position].slice(index in stops ? stops[index] + 1 : 0)
|
||||
}
|
||||
}
|
||||
|
||||
values.shift()
|
||||
|
||||
return values.join(lineFeed)
|
||||
}
|
||||
Reference in New Issue
Block a user