planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
module.exports = association
var decode = require('parse-entities/decode-entity')
var characterEscape = /\\([!-/:-@[-`{-~])/g
var characterReference = /&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi
// The `label` of an association is the string value: character escapes and
// references work, and casing is intact.
// The `identifier` is used to match one association to another: controversially,
// character escapes and references dont work in this matching: `©` does
// not match `©`, and `\+` does not match `+`.
// But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb`
// matches `a b`.
// So, we do prefer the label when figuring out how were going to serialize:
// it has whitespace, casing, and we can ignore most useless character escapes
// and all character references.
function association(node) {
if (node.label || !node.identifier) {
return node.label || ''
}
return node.identifier
.replace(characterEscape, '$1')
.replace(characterReference, decodeIfPossible)
}
function decodeIfPossible($0, $1) {
return decode($1) || $0
}

View File

@@ -0,0 +1,15 @@
module.exports = checkBullet
function checkBullet(context) {
var marker = context.options.bullet || '*'
if (marker !== '*' && marker !== '+' && marker !== '-') {
throw new Error(
'Cannot serialize items with `' +
marker +
'` for `options.bullet`, expected `*`, `+`, or `-`'
)
}
return marker
}

View File

@@ -0,0 +1,15 @@
module.exports = checkEmphasis
function checkEmphasis(context) {
var marker = context.options.emphasis || '*'
if (marker !== '*' && marker !== '_') {
throw new Error(
'Cannot serialize emphasis with `' +
marker +
'` for `options.emphasis`, expected `*`, or `_`'
)
}
return marker
}

View File

@@ -0,0 +1,15 @@
module.exports = checkFence
function checkFence(context) {
var marker = context.options.fence || '`'
if (marker !== '`' && marker !== '~') {
throw new Error(
'Cannot serialize code with `' +
marker +
'` for `options.fence`, expected `` ` `` or `~`'
)
}
return marker
}

View File

@@ -0,0 +1,19 @@
module.exports = checkListItemIndent
function checkListItemIndent(context) {
var style = context.options.listItemIndent || 'tab'
if (style === 1 || style === '1') {
return 'one'
}
if (style !== 'tab' && style !== 'one' && style !== 'mixed') {
throw new Error(
'Cannot serialize items with `' +
style +
'` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`'
)
}
return style
}

View File

@@ -0,0 +1,15 @@
module.exports = checkQuote
function checkQuote(context) {
var marker = context.options.quote || '"'
if (marker !== '"' && marker !== "'") {
throw new Error(
'Cannot serialize title with `' +
marker +
'` for `options.quote`, expected `"`, or `\'`'
)
}
return marker
}

View File

@@ -0,0 +1,15 @@
module.exports = checkRule
function checkRule(context) {
var repetition = context.options.ruleRepetition || 3
if (repetition < 3) {
throw new Error(
'Cannot serialize rules with repetition `' +
repetition +
'` for `options.ruleRepetition`, expected `3` or more'
)
}
return repetition
}

View File

@@ -0,0 +1,15 @@
module.exports = checkRule
function checkRule(context) {
var marker = context.options.rule || '*'
if (marker !== '*' && marker !== '-' && marker !== '_') {
throw new Error(
'Cannot serialize rules with `' +
marker +
'` for `options.rule`, expected `*`, `-`, or `_`'
)
}
return marker
}

View File

@@ -0,0 +1,15 @@
module.exports = checkStrong
function checkStrong(context) {
var marker = context.options.strong || '*'
if (marker !== '*' && marker !== '_') {
throw new Error(
'Cannot serialize strong with `' +
marker +
'` for `options.strong`, expected `*`, or `_`'
)
}
return marker
}

View File

@@ -0,0 +1,47 @@
module.exports = flow
var repeat = require('repeat-string')
function flow(parent, context) {
var children = parent.children || []
var results = []
var index = -1
var child
while (++index < children.length) {
child = children[index]
results.push(
context.handle(child, parent, context, {before: '\n', after: '\n'})
)
if (index + 1 < children.length) {
results.push(between(child, children[index + 1]))
}
}
return results.join('')
function between(left, right) {
var index = -1
var result
while (++index < context.join.length) {
result = context.join[index](left, right, parent, context)
if (result === true || result === 1) {
break
}
if (typeof result === 'number') {
return repeat('\n', 1 + Number(result))
}
if (result === false) {
return '\n\n<!---->\n\n'
}
}
return '\n\n'
}
}

View File

@@ -0,0 +1,57 @@
module.exports = phrasing
function phrasing(parent, context, safeOptions) {
var children = parent.children || []
var results = []
var index = -1
var before = safeOptions.before
var after
var handle
var child
while (++index < children.length) {
child = children[index]
if (index + 1 < children.length) {
handle = context.handle.handlers[children[index + 1].type]
if (handle && handle.peek) handle = handle.peek
after = handle
? handle(children[index + 1], parent, context, {
before: '',
after: ''
}).charAt(0)
: ''
} else {
after = safeOptions.after
}
// In some cases, html (text) can be found in phrasing right after an eol.
// When wed serialize that, in most cases that would be seen as html
// (flow).
// As we cant escape or so to prevent it from happening, we take a somewhat
// reasonable approach: replace that eol with a space.
// See: <https://github.com/syntax-tree/mdast-util-to-markdown/issues/15>
if (
results.length > 0 &&
(before === '\r' || before === '\n') &&
child.type === 'html'
) {
results[results.length - 1] = results[results.length - 1].replace(
/(\r?\n|\r)$/,
' '
)
before = ' '
}
results.push(
context.handle(child, parent, context, {
before: before,
after: after
})
)
before = results[results.length - 1].slice(-1)
}
return results.join('')
}

View File

@@ -0,0 +1,14 @@
module.exports = formatCodeAsIndented
function formatCodeAsIndented(node, context) {
return (
!context.options.fences &&
node.value &&
// If theres no info…
!node.lang &&
// And theres a non-whitespace character…
/[^ \r\n]/.test(node.value) &&
// And the value doesnt start or end in a blank…
!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node.value)
)
}

View File

@@ -0,0 +1,9 @@
module.exports = formatHeadingAsSetext
var toString = require('mdast-util-to-string')
function formatHeadingAsSetext(node, context) {
return (
context.options.setext && (!node.depth || node.depth < 3) && toString(node)
)
}

View File

@@ -0,0 +1,26 @@
module.exports = formatLinkAsAutolink
var toString = require('mdast-util-to-string')
function formatLinkAsAutolink(node, context) {
var raw = toString(node)
return (
!context.options.resourceLink &&
// If theres a url…
node.url &&
// And theres a no title…
!node.title &&
// And the content of `node` is a single text node…
node.children &&
node.children.length === 1 &&
node.children[0].type === 'text' &&
// And if the url is the same as the content…
(raw === node.url || 'mailto:' + raw === node.url) &&
// And that starts w/ a protocol…
/^[a-z][a-z+.-]+:/i.test(node.url) &&
// And that doesnt contain ASCII control codes (character escapes and
// references dont work) or angle brackets…
!/[\0- <>\u007F]/.test(node.url)
)
}

View File

@@ -0,0 +1,25 @@
module.exports = indentLines
var eol = /\r?\n|\r/g
function indentLines(value, map) {
var result = []
var start = 0
var line = 0
var match
while ((match = eol.exec(value))) {
one(value.slice(start, match.index))
result.push(match[0])
start = match.index + match[0].length
line++
}
one(value.slice(start))
return result.join('')
function one(value) {
result.push(map(value, line, !value))
}
}

View File

@@ -0,0 +1,25 @@
module.exports = patternCompile
function patternCompile(pattern) {
var before
var after
if (!pattern._compiled) {
before = pattern.before ? '(?:' + pattern.before + ')' : ''
after = pattern.after ? '(?:' + pattern.after + ')' : ''
if (pattern.atBreak) {
before = '[\\r\\n][\\t ]*' + before
}
pattern._compiled = new RegExp(
(before ? '(' + before + ')' : '') +
(/[|\\{}()[\]^$+*?.-]/.test(pattern.character) ? '\\' : '') +
pattern.character +
(after || ''),
'g'
)
}
return pattern._compiled
}

View File

@@ -0,0 +1,30 @@
module.exports = patternInScope
function patternInScope(stack, pattern) {
return (
listInScope(stack, pattern.inConstruct, true) &&
!listInScope(stack, pattern.notInConstruct)
)
}
function listInScope(stack, list, none) {
var index
if (!list) {
return none
}
if (typeof list === 'string') {
list = [list]
}
index = -1
while (++index < list.length) {
if (stack.indexOf(list[index]) !== -1) {
return true
}
}
return false
}

139
node_modules/mdast-util-to-markdown/lib/util/safe.js generated vendored Normal file
View File

@@ -0,0 +1,139 @@
module.exports = safe
var patternCompile = require('./pattern-compile')
var patternInScope = require('./pattern-in-scope')
function safe(context, input, config) {
var value = (config.before || '') + (input || '') + (config.after || '')
var positions = []
var result = []
var infos = {}
var index = -1
var before
var after
var position
var pattern
var expression
var match
var start
var end
while (++index < context.unsafe.length) {
pattern = context.unsafe[index]
if (!patternInScope(context.stack, pattern)) {
continue
}
expression = patternCompile(pattern)
while ((match = expression.exec(value))) {
before = 'before' in pattern || pattern.atBreak
after = 'after' in pattern
position = match.index + (before ? match[1].length : 0)
if (positions.indexOf(position) === -1) {
positions.push(position)
infos[position] = {before: before, after: after}
} else {
if (infos[position].before && !before) {
infos[position].before = false
}
if (infos[position].after && !after) {
infos[position].after = false
}
}
}
}
positions.sort(numerical)
start = config.before ? config.before.length : 0
end = value.length - (config.after ? config.after.length : 0)
index = -1
while (++index < positions.length) {
position = positions[index]
if (
// Character before or after matched:
position < start ||
position >= end
) {
continue
}
// If this character is supposed to be escaped because it has a condition on
// the next character, and the next character is definitly being escaped,
// then skip this escape.
if (
position + 1 < end &&
positions[index + 1] === position + 1 &&
infos[position].after &&
!infos[position + 1].before &&
!infos[position + 1].after
) {
continue
}
if (start !== position) {
// If we have to use a character reference, an ampersand would be more
// correct, but as backslashes only care about punctuation, either will
// do the trick
result.push(escapeBackslashes(value.slice(start, position), '\\'))
}
start = position
if (
/[!-/:-@[-`{-~]/.test(value.charAt(position)) &&
(!config.encode || config.encode.indexOf(value.charAt(position)) === -1)
) {
// Character escape.
result.push('\\')
} else {
// Character reference.
result.push(
'&#x' + value.charCodeAt(position).toString(16).toUpperCase() + ';'
)
start++
}
}
result.push(escapeBackslashes(value.slice(start, end), config.after))
return result.join('')
}
function numerical(a, b) {
return a - b
}
function escapeBackslashes(value, after) {
var expression = /\\(?=[!-/:-@[-`{-~])/g
var positions = []
var results = []
var index = -1
var start = 0
var whole = value + after
var match
while ((match = expression.exec(whole))) {
positions.push(match.index)
}
while (++index < positions.length) {
if (start !== positions[index]) {
results.push(value.slice(start, positions[index]))
}
results.push('\\')
start = positions[index]
}
results.push(value.slice(start))
return results.join('')
}