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

1
node_modules/mdast-util-to-markdown/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./lib')

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

@@ -0,0 +1,27 @@
module.exports = configure
function configure(base, extension) {
var index = -1
var key
// First do subextensions.
if (extension.extensions) {
while (++index < extension.extensions.length) {
configure(base, extension.extensions[index])
}
}
for (key in extension) {
if (key === 'extensions') {
// Empty.
} else if (key === 'unsafe' || key === 'join') {
base[key] = base[key].concat(extension[key] || [])
} else if (key === 'handlers') {
base[key] = Object.assign(base[key], extension[key] || {})
} else {
base.options[key] = extension[key]
}
}
return base
}

View File

@@ -0,0 +1,15 @@
module.exports = blockquote
var flow = require('../util/container-flow')
var indentLines = require('../util/indent-lines')
function blockquote(node, _, context) {
var exit = context.enter('blockquote')
var value = indentLines(flow(node, context), map)
exit()
return value
}
function map(line, index, blank) {
return '>' + (blank ? '' : ' ') + line
}

View File

@@ -0,0 +1,20 @@
module.exports = hardBreak
var patternInScope = require('../util/pattern-in-scope')
function hardBreak(node, _, context, safe) {
var index = -1
while (++index < context.unsafe.length) {
// If we cant put eols in this construct (setext headings, tables), use a
// space instead.
if (
context.unsafe[index].character === '\n' &&
patternInScope(context.stack, context.unsafe[index])
) {
return /[ \t]/.test(safe.before) ? '' : ' '
}
}
return '\\\n'
}

64
node_modules/mdast-util-to-markdown/lib/handle/code.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
module.exports = code
var repeat = require('repeat-string')
var streak = require('longest-streak')
var formatCodeAsIndented = require('../util/format-code-as-indented')
var checkFence = require('../util/check-fence')
var indentLines = require('../util/indent-lines')
var safe = require('../util/safe')
function code(node, _, context) {
var marker = checkFence(context)
var raw = node.value || ''
var suffix = marker === '`' ? 'GraveAccent' : 'Tilde'
var value
var sequence
var exit
var subexit
if (formatCodeAsIndented(node, context)) {
exit = context.enter('codeIndented')
value = indentLines(raw, map)
} else {
sequence = repeat(marker, Math.max(streak(raw, marker) + 1, 3))
exit = context.enter('codeFenced')
value = sequence
if (node.lang) {
subexit = context.enter('codeFencedLang' + suffix)
value += safe(context, node.lang, {
before: '`',
after: ' ',
encode: ['`']
})
subexit()
}
if (node.lang && node.meta) {
subexit = context.enter('codeFencedMeta' + suffix)
value +=
' ' +
safe(context, node.meta, {
before: ' ',
after: '\n',
encode: ['`']
})
subexit()
}
value += '\n'
if (raw) {
value += raw + '\n'
}
value += sequence
}
exit()
return value
}
function map(line, _, blank) {
return (blank ? '' : ' ') + line
}

View File

@@ -0,0 +1,46 @@
module.exports = definition
var association = require('../util/association')
var checkQuote = require('../util/check-quote')
var safe = require('../util/safe')
function definition(node, _, context) {
var marker = checkQuote(context)
var suffix = marker === '"' ? 'Quote' : 'Apostrophe'
var exit = context.enter('definition')
var subexit = context.enter('label')
var value =
'[' + safe(context, association(node), {before: '[', after: ']'}) + ']: '
subexit()
if (
// If theres no url, or…
!node.url ||
// If theres whitespace, enclosed is prettier.
/[ \t\r\n]/.test(node.url)
) {
subexit = context.enter('destinationLiteral')
value += '<' + safe(context, node.url, {before: '<', after: '>'}) + '>'
} else {
// No whitespace, raw is prettier.
subexit = context.enter('destinationRaw')
value += safe(context, node.url, {before: ' ', after: ' '})
}
subexit()
if (node.title) {
subexit = context.enter('title' + suffix)
value +=
' ' +
marker +
safe(context, node.title, {before: marker, after: marker}) +
marker
subexit()
}
exit()
return value
}

View File

@@ -0,0 +1,21 @@
module.exports = emphasis
emphasis.peek = emphasisPeek
var checkEmphasis = require('../util/check-emphasis')
var phrasing = require('../util/container-phrasing')
// To do: there are cases where emphasis cannot “form” depending on the
// previous or next character of sequences.
// Theres no way around that though, except for injecting zero-width stuff.
// Do we need to safeguard against that?
function emphasis(node, _, context) {
var marker = checkEmphasis(context)
var exit = context.enter('emphasis')
var value = phrasing(node, context, {before: marker, after: marker})
exit()
return marker + value + marker
}
function emphasisPeek(node, _, context) {
return context.options.emphasis || '*'
}

View File

@@ -0,0 +1,48 @@
module.exports = heading
var repeat = require('repeat-string')
var formatHeadingAsSetext = require('../util/format-heading-as-setext')
var phrasing = require('../util/container-phrasing')
function heading(node, _, context) {
var rank = Math.max(Math.min(6, node.depth || 1), 1)
var exit
var subexit
var value
var sequence
if (formatHeadingAsSetext(node, context)) {
exit = context.enter('headingSetext')
subexit = context.enter('phrasing')
value = phrasing(node, context, {before: '\n', after: '\n'})
subexit()
exit()
return (
value +
'\n' +
repeat(
rank === 1 ? '=' : '-',
// The whole size…
value.length -
// Minus the position of the character after the last EOL (or
// 0 if there is none)…
(Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1)
)
)
}
sequence = repeat('#', rank)
exit = context.enter('headingAtx')
subexit = context.enter('phrasing')
value = phrasing(node, context, {before: '# ', after: '\n'})
value = value ? sequence + ' ' + value : sequence
if (context.options.closeAtx) {
value += ' ' + sequence
}
subexit()
exit()
return value
}

10
node_modules/mdast-util-to-markdown/lib/handle/html.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
module.exports = html
html.peek = htmlPeek
function html(node) {
return node.value || ''
}
function htmlPeek() {
return '<'
}

View File

@@ -0,0 +1,37 @@
module.exports = imageReference
imageReference.peek = imageReferencePeek
var association = require('../util/association')
var safe = require('../util/safe')
function imageReference(node, _, context) {
var type = node.referenceType
var exit = context.enter('imageReference')
var subexit = context.enter('label')
var alt = safe(context, node.alt, {before: '[', after: ']'})
var value = '![' + alt + ']'
var reference
var stack
subexit()
// Hide the fact that were in phrasing, because escapes dont work.
stack = context.stack
context.stack = []
subexit = context.enter('reference')
reference = safe(context, association(node), {before: '[', after: ']'})
subexit()
context.stack = stack
exit()
if (type === 'full' || !alt || alt !== reference) {
value += '[' + reference + ']'
} else if (type !== 'shortcut') {
value += '[]'
}
return value
}
function imageReferencePeek() {
return '!'
}

View File

@@ -0,0 +1,53 @@
module.exports = image
image.peek = imagePeek
var checkQuote = require('../util/check-quote')
var safe = require('../util/safe')
function image(node, _, context) {
var quote = checkQuote(context)
var suffix = quote === '"' ? 'Quote' : 'Apostrophe'
var exit = context.enter('image')
var subexit = context.enter('label')
var value = '![' + safe(context, node.alt, {before: '[', after: ']'}) + ']('
subexit()
if (
// If theres no url but there is a title…
(!node.url && node.title) ||
// Or if theres markdown whitespace or an eol, enclose.
/[ \t\r\n]/.test(node.url)
) {
subexit = context.enter('destinationLiteral')
value += '<' + safe(context, node.url, {before: '<', after: '>'}) + '>'
} else {
// No whitespace, raw is prettier.
subexit = context.enter('destinationRaw')
value += safe(context, node.url, {
before: '(',
after: node.title ? ' ' : ')'
})
}
subexit()
if (node.title) {
subexit = context.enter('title' + suffix)
value +=
' ' +
quote +
safe(context, node.title, {before: quote, after: quote}) +
quote
subexit()
}
value += ')'
exit()
return value
}
function imagePeek() {
return '!'
}

View File

@@ -0,0 +1,20 @@
exports.blockquote = require('./blockquote')
exports.break = require('./break')
exports.code = require('./code')
exports.definition = require('./definition')
exports.emphasis = require('./emphasis')
exports.hardBreak = require('./break')
exports.heading = require('./heading')
exports.html = require('./html')
exports.image = require('./image')
exports.imageReference = require('./image-reference')
exports.inlineCode = require('./inline-code')
exports.link = require('./link')
exports.linkReference = require('./link-reference')
exports.list = require('./list')
exports.listItem = require('./list-item')
exports.paragraph = require('./paragraph')
exports.root = require('./root')
exports.strong = require('./strong')
exports.text = require('./text')
exports.thematicBreak = require('./thematic-break')

View File

@@ -0,0 +1,69 @@
module.exports = inlineCode
inlineCode.peek = inlineCodePeek
var patternCompile = require('../util/pattern-compile')
function inlineCode(node, parent, context) {
var value = node.value || ''
var sequence = '`'
var index = -1
var pattern
var expression
var match
var position
// If there is a single grave accent on its own in the code, use a fence of
// two.
// If there are two in a row, use one.
while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) {
sequence += '`'
}
// If this is not just spaces or eols (tabs dont count), and either the
// first or last character are a space, eol, or tick, then pad with spaces.
if (
/[^ \r\n]/.test(value) &&
(/[ \r\n`]/.test(value.charAt(0)) ||
/[ \r\n`]/.test(value.charAt(value.length - 1)))
) {
value = ' ' + value + ' '
}
// We have a potential problem: certain characters after eols could result in
// blocks being seen.
// For example, if someone injected the string `'\n# b'`, then that would
// result in an ATX heading.
// We cant escape characters in `inlineCode`, but because eols are
// transformed to spaces when going from markdown to HTML anyway, we can swap
// them out.
while (++index < context.unsafe.length) {
pattern = context.unsafe[index]
// Only look for `atBreak`s.
// Btw: note that `atBreak` patterns will always start the regex at LF or
// CR.
if (!pattern.atBreak) continue
expression = patternCompile(pattern)
while ((match = expression.exec(value))) {
position = match.index
// Support CRLF (patterns only look for one of the characters).
if (
value.charCodeAt(position) === 10 /* `\n` */ &&
value.charCodeAt(position - 1) === 13 /* `\r` */
) {
position--
}
value = value.slice(0, position) + ' ' + value.slice(match.index + 1)
}
}
return sequence + value + sequence
}
function inlineCodePeek() {
return '`'
}

View File

@@ -0,0 +1,38 @@
module.exports = linkReference
linkReference.peek = linkReferencePeek
var association = require('../util/association')
var phrasing = require('../util/container-phrasing')
var safe = require('../util/safe')
function linkReference(node, _, context) {
var type = node.referenceType
var exit = context.enter('linkReference')
var subexit = context.enter('label')
var text = phrasing(node, context, {before: '[', after: ']'})
var value = '[' + text + ']'
var reference
var stack
subexit()
// Hide the fact that were in phrasing, because escapes dont work.
stack = context.stack
context.stack = []
subexit = context.enter('reference')
reference = safe(context, association(node), {before: '[', after: ']'})
subexit()
context.stack = stack
exit()
if (type === 'full' || !text || text !== reference) {
value += '[' + reference + ']'
} else if (type !== 'shortcut') {
value += '[]'
}
return value
}
function linkReferencePeek() {
return '['
}

70
node_modules/mdast-util-to-markdown/lib/handle/link.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
module.exports = link
link.peek = linkPeek
var checkQuote = require('../util/check-quote')
var formatLinkAsAutolink = require('../util/format-link-as-autolink')
var phrasing = require('../util/container-phrasing')
var safe = require('../util/safe')
function link(node, _, context) {
var quote = checkQuote(context)
var suffix = quote === '"' ? 'Quote' : 'Apostrophe'
var exit
var subexit
var value
var stack
if (formatLinkAsAutolink(node, context)) {
// Hide the fact that were in phrasing, because escapes dont work.
stack = context.stack
context.stack = []
exit = context.enter('autolink')
value = '<' + phrasing(node, context, {before: '<', after: '>'}) + '>'
exit()
context.stack = stack
return value
}
exit = context.enter('link')
subexit = context.enter('label')
value = '[' + phrasing(node, context, {before: '[', after: ']'}) + ']('
subexit()
if (
// If theres no url but there is a title…
(!node.url && node.title) ||
// Or if theres markdown whitespace or an eol, enclose.
/[ \t\r\n]/.test(node.url)
) {
subexit = context.enter('destinationLiteral')
value += '<' + safe(context, node.url, {before: '<', after: '>'}) + '>'
} else {
// No whitespace, raw is prettier.
subexit = context.enter('destinationRaw')
value += safe(context, node.url, {
before: '(',
after: node.title ? ' ' : ')'
})
}
subexit()
if (node.title) {
subexit = context.enter('title' + suffix)
value +=
' ' +
quote +
safe(context, node.title, {before: quote, after: quote}) +
quote
subexit()
}
value += ')'
exit()
return value
}
function linkPeek(node, _, context) {
return formatLinkAsAutolink(node, context) ? '<' : '['
}

View File

@@ -0,0 +1,47 @@
module.exports = listItem
var repeat = require('repeat-string')
var checkBullet = require('../util/check-bullet')
var checkListItemIndent = require('../util/check-list-item-indent')
var flow = require('../util/container-flow')
var indentLines = require('../util/indent-lines')
function listItem(node, parent, context) {
var bullet = checkBullet(context)
var listItemIndent = checkListItemIndent(context)
var size
var value
var exit
if (parent && parent.ordered) {
bullet =
(parent.start > -1 ? parent.start : 1) +
(context.options.incrementListMarker === false
? 0
: parent.children.indexOf(node)) +
'.'
}
size = bullet.length + 1
if (
listItemIndent === 'tab' ||
(listItemIndent === 'mixed' && ((parent && parent.spread) || node.spread))
) {
size = Math.ceil(size / 4) * 4
}
exit = context.enter('listItem')
value = indentLines(flow(node, context), map)
exit()
return value
function map(line, index, blank) {
if (index) {
return (blank ? '' : repeat(' ', size)) + line
}
return (blank ? bullet : bullet + repeat(' ', size - bullet.length)) + line
}
}

10
node_modules/mdast-util-to-markdown/lib/handle/list.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
module.exports = list
var flow = require('../util/container-flow')
function list(node, _, context) {
var exit = context.enter('list')
var value = flow(node, context)
exit()
return value
}

View File

@@ -0,0 +1,12 @@
module.exports = paragraph
var phrasing = require('../util/container-phrasing')
function paragraph(node, _, context) {
var exit = context.enter('paragraph')
var subexit = context.enter('phrasing')
var value = phrasing(node, context, {before: '\n', after: '\n'})
subexit()
exit()
return value
}

View File

@@ -0,0 +1,7 @@
module.exports = root
var flow = require('../util/container-flow')
function root(node, _, context) {
return flow(node, context)
}

View File

@@ -0,0 +1,21 @@
module.exports = strong
strong.peek = strongPeek
var checkStrong = require('../util/check-strong')
var phrasing = require('../util/container-phrasing')
// To do: there are cases where emphasis cannot “form” depending on the
// previous or next character of sequences.
// Theres no way around that though, except for injecting zero-width stuff.
// Do we need to safeguard against that?
function strong(node, _, context) {
var marker = checkStrong(context)
var exit = context.enter('strong')
var value = phrasing(node, context, {before: marker, after: marker})
exit()
return marker + marker + value + marker + marker
}
function strongPeek(node, _, context) {
return context.options.strong || '*'
}

View File

@@ -0,0 +1,7 @@
module.exports = text
var safe = require('../util/safe')
function text(node, parent, context, safeOptions) {
return safe(context, node.value, safeOptions)
}

View File

@@ -0,0 +1,14 @@
module.exports = thematicBreak
var repeat = require('repeat-string')
var checkRepeat = require('../util/check-rule-repeat')
var checkRule = require('../util/check-rule')
function thematicBreak(node, parent, context) {
var value = repeat(
checkRule(context) + (context.options.ruleSpaces ? ' ' : ''),
checkRepeat(context)
)
return context.options.ruleSpaces ? value.slice(0, -1) : value
}

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

@@ -0,0 +1,73 @@
module.exports = toMarkdown
var zwitch = require('zwitch')
var configure = require('./configure')
var defaultHandlers = require('./handle')
var defaultJoin = require('./join')
var defaultUnsafe = require('./unsafe')
function toMarkdown(tree, options) {
var settings = options || {}
var context = {
enter: enter,
stack: [],
unsafe: [],
join: [],
handlers: {},
options: {}
}
var result
configure(context, {
unsafe: defaultUnsafe,
join: defaultJoin,
handlers: defaultHandlers
})
configure(context, settings)
if (context.options.tightDefinitions) {
context.join = [joinDefinition].concat(context.join)
}
context.handle = zwitch('type', {
invalid: invalid,
unknown: unknown,
handlers: context.handlers
})
result = context.handle(tree, null, context, {before: '\n', after: '\n'})
if (
result &&
result.charCodeAt(result.length - 1) !== 10 &&
result.charCodeAt(result.length - 1) !== 13
) {
result += '\n'
}
return result
function enter(name) {
context.stack.push(name)
return exit
function exit() {
context.stack.pop()
}
}
}
function invalid(value) {
throw new Error('Cannot handle value `' + value + '`, expected node')
}
function unknown(node) {
throw new Error('Cannot handle unknown node `' + node.type + '`')
}
function joinDefinition(left, right) {
// No blank line between adjacent definitions.
if (left.type === 'definition' && left.type === right.type) {
return 0
}
}

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

@@ -0,0 +1,37 @@
module.exports = [joinDefaults]
var formatCodeAsIndented = require('./util/format-code-as-indented')
var formatHeadingAsSetext = require('./util/format-heading-as-setext')
function joinDefaults(left, right, parent, context) {
if (
// Two lists with the same marker.
(right.type === 'list' &&
right.type === left.type &&
Boolean(left.ordered) === Boolean(right.ordered)) ||
// Indented code after list or another indented code.
(right.type === 'code' &&
formatCodeAsIndented(right, context) &&
(left.type === 'list' ||
(left.type === right.type && formatCodeAsIndented(left, context))))
) {
return false
}
// Join children of a list or an item.
// In which case, `parent` has a `spread` field.
if (typeof parent.spread === 'boolean') {
if (
left.type === 'paragraph' &&
// Two paragraphs.
(left.type === right.type ||
right.type === 'definition' ||
// Paragraph followed by a setext heading.
(right.type === 'heading' && formatHeadingAsSetext(right, context)))
) {
return
}
return parent.spread ? 1 : 0
}
}

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

@@ -0,0 +1,110 @@
module.exports = [
{
character: '\t',
inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde']
},
{
character: '\r',
inConstruct: [
'codeFencedLangGraveAccent',
'codeFencedLangTilde',
'codeFencedMetaGraveAccent',
'codeFencedMetaTilde',
'destinationLiteral',
'headingAtx'
]
},
{
character: '\n',
inConstruct: [
'codeFencedLangGraveAccent',
'codeFencedLangTilde',
'codeFencedMetaGraveAccent',
'codeFencedMetaTilde',
'destinationLiteral',
'headingAtx'
]
},
{
character: ' ',
inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde']
},
// An exclamation mark can start an image, if it is followed by a link or
// a link reference.
{character: '!', after: '\\[', inConstruct: 'phrasing'},
// A quote can break out of a title.
{character: '"', inConstruct: 'titleQuote'},
// A number sign could start an ATX heading if it starts a line.
{atBreak: true, character: '#'},
{character: '#', inConstruct: 'headingAtx', after: '(?:[\r\n]|$)'},
// Dollar sign and percentage are not used in markdown.
// An ampersand could start a character reference.
{character: '&', after: '[#A-Za-z]', inConstruct: 'phrasing'},
// An apostrophe can break out of a title.
{character: "'", inConstruct: 'titleApostrophe'},
// A left paren could break out of a destination raw.
{character: '(', inConstruct: 'destinationRaw'},
{before: '\\]', character: '(', inConstruct: 'phrasing'},
// A right paren could start a list item or break out of a destination
// raw.
{atBreak: true, before: '\\d+', character: ')'},
{character: ')', inConstruct: 'destinationRaw'},
// An asterisk can start thematic breaks, list items, emphasis, strong.
{atBreak: true, character: '*'},
{character: '*', inConstruct: 'phrasing'},
// A plus sign could start a list item.
{atBreak: true, character: '+'},
// A dash can start thematic breaks, list items, and setext heading
// underlines.
{atBreak: true, character: '-'},
// A dot could start a list item.
{atBreak: true, before: '\\d+', character: '.', after: '(?:[ \t\r\n]|$)'},
// Slash, colon, and semicolon are not used in markdown for constructs.
// A less than can start html (flow or text) or an autolink.
// HTML could start with an exclamation mark (declaration, cdata, comment),
// slash (closing tag), question mark (instruction), or a letter (tag).
// An autolink also starts with a letter.
// Finally, it could break out of a destination literal.
{atBreak: true, character: '<', after: '[!/?A-Za-z]'},
{character: '<', after: '[!/?A-Za-z]', inConstruct: 'phrasing'},
{character: '<', inConstruct: 'destinationLiteral'},
// An equals to can start setext heading underlines.
{atBreak: true, character: '='},
// A greater than can start block quotes and it can break out of a
// destination literal.
{atBreak: true, character: '>'},
{character: '>', inConstruct: 'destinationLiteral'},
// Question mark and at sign are not used in markdown for constructs.
// A left bracket can start definitions, references, labels,
{atBreak: true, character: '['},
{character: '[', inConstruct: ['phrasing', 'label', 'reference']},
// A backslash can start an escape (when followed by punctuation) or a
// hard break (when followed by an eol).
// Note: typical escapes are handled in `safe`!
{character: '\\', after: '[\\r\\n]', inConstruct: 'phrasing'},
// A right bracket can exit labels.
{
character: ']',
inConstruct: ['label', 'reference']
},
// Caret is not used in markdown for constructs.
// An underscore can start emphasis, strong, or a thematic break.
{atBreak: true, character: '_'},
{before: '[^A-Za-z]', character: '_', inConstruct: 'phrasing'},
{character: '_', after: '[^A-Za-z]', inConstruct: 'phrasing'},
// A grave accent can start code (fenced or text), or it can break out of
// a grave accent code fence.
{atBreak: true, character: '`'},
{
character: '`',
inConstruct: [
'codeFencedLangGraveAccent',
'codeFencedMetaGraveAccent',
'phrasing'
]
},
// Left brace, vertical bar, right brace are not used in markdown for
// constructs.
// A tilde can start code (fenced).
{atBreak: true, character: '~'}
]

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: `&copy;` 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('')
}

22
node_modules/mdast-util-to-markdown/license generated vendored Normal file
View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,29 @@
'use strict'
module.exports = toString
// Get the text content of a node.
// Prefer the nodes plain-text fields, otherwise serialize its children,
// and if the given value is an array, serialize the nodes in it.
function toString(node) {
return (
(node &&
(node.value ||
node.alt ||
node.title ||
('children' in node && all(node.children)) ||
('length' in node && all(node)))) ||
''
)
}
function all(values) {
var result = []
var index = -1
while (++index < values.length) {
result[index] = toString(values[index])
}
return result.join('')
}

View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,80 @@
{
"name": "mdast-util-to-string",
"version": "2.0.0",
"description": "mdast utility to get the plain text content of a node",
"license": "MIT",
"keywords": [
"unist",
"mdast",
"mdast-util",
"util",
"utility",
"markdown",
"node",
"string",
"serialize"
],
"repository": "syntax-tree/mdast-util-to-string",
"bugs": "https://github.com/syntax-tree/mdast-util-to-string/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"files": [
"index.js",
"types/index.d.ts"
],
"types": "types/index.d.ts",
"devDependencies": {
"browserify": "^17.0.0",
"dtslint": "^4.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"xo": "^0.34.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"build-bundle": "browserify . -s mdastUtilToString -o mdast-util-to-string.js",
"build-mangle": "browserify . -s mdastUtilToString -o mdast-util-to-string.min.js -p tinyify",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test-types": "dtslint types",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"esnext": false,
"ignore": [
"mdast-util-to-string.js",
"types/test.ts"
]
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}

View File

@@ -0,0 +1,127 @@
# mdast-util-to-string
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
**[mdast][]** utility to get the plain text content of a node.
## Install
[npm][]:
```sh
npm install mdast-util-to-string
```
## Use
```js
var unified = require('unified')
var parse = require('remark-parse')
var toString = require('mdast-util-to-string')
var tree = unified()
.use(parse)
.parse('Some _emphasis_, **importance**, and `code`.')
console.log(toString(tree)) // => 'Some emphasis, importance, and code.'
```
## API
### `toString(node)`
Get the text content of a [node][] or list of nodes.
The algorithm checks `value` of `node`, then `alt`, and finally `title`.
If no value is found, the algorithm checks the children of `node` and joins them
(without spaces or newlines).
> This is not a markdown to plain-text library.
> Use [`strip-markdown`][strip-markdown] for that.
## Security
Use of `mdast-util-to-string` does not involve **[hast][]**, user content, or
change the tree, so there are no openings for [cross-site scripting (XSS)][xss]
attacks.
## Related
* [`nlcst-to-string`](https://github.com/syntax-tree/nlcst-to-string)
— Get text content in nlcst
* [`hast-util-to-string`](https://github.com/wooorm/rehype-minify/tree/HEAD/packages/hast-util-to-string)
— Get text content in hast
* [`hast-util-to-text`](https://github.com/syntax-tree/hast-util-to-text)
— Get text content in hast according to the `innerText` algorithm
* [`hast-util-from-string`](https://github.com/wooorm/rehype-minify/tree/HEAD/packages/hast-util-from-string)
— Set text content in hast
## Contribute
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`support.md`][support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://github.com/syntax-tree/mdast-util-to-string/workflows/main/badge.svg
[build]: https://github.com/syntax-tree/mdast-util-to-string/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-to-string.svg
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-to-string
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-to-string.svg
[downloads]: https://www.npmjs.com/package/mdast-util-to-string
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-to-string.svg
[size]: https://bundlephobia.com/result?p=mdast-util-to-string
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/syntax-tree/unist/discussions
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://wooorm.com
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
[mdast]: https://github.com/syntax-tree/mdast
[node]: https://github.com/syntax-tree/mdast#nodes
[strip-markdown]: https://github.com/remarkjs/strip-markdown
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[hast]: https://github.com/syntax-tree/hast

View File

@@ -0,0 +1,8 @@
// Minimum TypeScript Version: 3.0
import {Node} from 'unist'
declare namespace mdastToString {}
declare function mdastToString(node: Node | Node[]): string
export = mdastToString

96
node_modules/mdast-util-to-markdown/package.json generated vendored Normal file
View File

@@ -0,0 +1,96 @@
{
"name": "mdast-util-to-markdown",
"version": "0.6.5",
"description": "mdast utility to serialize markdown",
"license": "MIT",
"keywords": [
"unist",
"mdast",
"mdast-util",
"util",
"utility",
"markdown",
"markup",
"serialize",
"stringify",
"compile",
"syntax",
"tree",
"ast"
],
"repository": "syntax-tree/mdast-util-to-markdown",
"bugs": "https://github.com/syntax-tree/mdast-util-to-markdown/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"files": [
"index.js",
"lib/",
"types/index.d.ts"
],
"types": "types",
"dependencies": {
"@types/unist": "^2.0.0",
"longest-streak": "^2.0.0",
"mdast-util-to-string": "^2.0.0",
"parse-entities": "^2.0.0",
"repeat-string": "^1.0.0",
"zwitch": "^1.0.0"
},
"devDependencies": {
"browserify": "^17.0.0",
"dtslint": "^4.0.0",
"mdast-util-from-markdown": "^0.8.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"unist-util-remove-position": "^3.0.0",
"xo": "^0.37.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"build": "browserify . -s mdastUtilToMarkdown -p tinyify > mdast-util-to-markdown.min.js",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test-types": "dtslint types",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"complexity": "off",
"unicorn/prefer-includes": "off"
},
"ignores": [
"types/"
]
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}

312
node_modules/mdast-util-to-markdown/readme.md generated vendored Normal file
View File

@@ -0,0 +1,312 @@
# mdast-util-to-markdown
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
**[mdast][]** utility to parse markdown.
## Install
[npm][]:
```sh
npm install mdast-util-to-markdown
```
## Use
Say we have the following script, `example.js`:
```js
var toMarkdown = require('mdast-util-to-markdown')
var tree = {
type: 'root',
children: [
{
type: 'blockquote',
children: [
{type: 'thematicBreak'},
{
type: 'paragraph',
children: [
{type: 'text', value: '- a\nb !'},
{
type: 'link',
url: 'example.com',
children: [{type: 'text', value: 'd'}]
}
]
}
]
}
]
}
console.log(toMarkdown(tree))
```
Now, running `node example` yields (note the properly escaped characters which
would otherwise turn into a list and image respectively):
```markdown
> ***
>
> \- a
> b \![d](example.com)
```
## API
### `toMarkdown(tree[, options])`
Serialize **[mdast][]** to markdown.
##### Formatting options
###### `options.bullet`
Marker to use to for bullets of items in unordered lists (`'*'`, `'+'`, or `'-'`,
default: `'*'`).
###### `options.closeAtx`
Whether to add the same number of number signs (`#`) at the end of an ATX
heading as the opening sequence (`boolean`, default: `false`).
###### `options.emphasis`
Marker to use to serialize emphasis (`'*'` or `'_'`, default: `'*'`).
###### `options.fence`
Marker to use to serialize fenced code (``'`'`` or `'~'`, default: ``'`'``).
###### `options.fences`
Whether to use fenced code always (`boolean`, default: `false`).
The default is to fenced code if there is a language defined, if the code is
empty, or if it starts or ends in empty lines.
###### `options.incrementListMarker`
Whether to increment the value of bullets of items in ordered lists (`boolean`,
default: `true`).
###### `options.listItemIndent`
Whether to indent the content of list items with the size of the bullet plus one
space (when `'one'`) or a tab stop (`'tab'`), or depending on the item and its
parent list (`'mixed'`, uses `'one'` if the item and list are tight and `'tab'`
otherwise) (`'one'`, `'tab'`, or `'mixed'`, default: `'tab'`).
###### `options.quote`
Marker to use to serialize titles (`'"'` or `"'"`, default: `'"'`).
###### `options.resourceLink`
Whether to use reference links always (`boolean`, default: `false`).
The default is to use autolinks (`<https://example.com>`) when possible.
###### `options.rule`
Marker to use for thematic breaks (`'*'`, `'-'`, or `'_'`, default: `'*'`).
###### `options.ruleRepetition`
Number of markers to use for thematic breaks (`number`, default:
`3`, min: `3`).
###### `options.ruleSpaces`
Whether to add spaces between markers in thematic breaks (`boolean`, default:
`false`).
###### `options.setext`
Whether to use setext headings when possible (`boolean`, default: `false`).
Setext headings are not possible for headings with a rank more than 2 or when
theyre empty.
###### `options.strong`
Marker to use to serialize strong (`'*'` or `'_'`, default: `'*'`).
###### `options.tightDefinitions`
Whether to join definitions w/o a blank line (`boolean`, default: `false`).
Shortcut for a join function like so:
```js
function (left, right) {
if (left.type === 'definition' && right.type === 'definition') {
return 0
}
}
```
###### `options.handlers`
Object mapping node types to custom handlers.
Useful for syntax extensions.
Take a look at [`lib/handle`][handlers] for examples.
###### `options.join`
List of functions used to determine what to place between two flow nodes.
Often, they are joined by one blank line.
In certain cases, its nicer to have them next to each other.
Or, they cant occur together.
These functions receive two adjacent nodes and their parent and can return
`number` or `boolean`, referring to how many blank lines to use between them.
A return value of `true` is as passing `1`.
A return value of `false` means the nodes cannot be joined by a blank line, such
as two adjacent block quotes or indented code after a list, in which case a
comment will be injected to break them up:
```markdown
> Quote 1
<!---->
> Quote 2
```
###### `options.unsafe`
List of patterns to escape.
Useful for syntax extensions.
Take a look at [`lib/unsafe.js`][unsafe] for examples.
##### Extension options
###### `options.extensions`
List of extensions (`Array.<ToMarkdownExtension>`).
Each `ToMarkdownExtension` is an object with the same interface as `options`
here.
##### Returns
`string` — Serialized markdown.
## List of extensions
* [`syntax-tree/mdast-util-directive`](https://github.com/syntax-tree/mdast-util-directive)
— serialize directives
* [`syntax-tree/mdast-util-footnote`](https://github.com/syntax-tree/mdast-util-footnote)
— serialize footnotes
* [`syntax-tree/mdast-util-frontmatter`](https://github.com/syntax-tree/mdast-util-frontmatter)
— serialize frontmatter (YAML, TOML, more)
* [`syntax-tree/mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm)
— serialize GFM
* [`syntax-tree/mdast-util-gfm-autolink-literal`](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal)
— serialize GFM autolink literals
* [`syntax-tree/mdast-util-gfm-strikethrough`](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)
— serialize GFM strikethrough
* [`syntax-tree/mdast-util-gfm-table`](https://github.com/syntax-tree/mdast-util-gfm-table)
— serialize GFM tables
* [`syntax-tree/mdast-util-gfm-task-list-item`](https://github.com/syntax-tree/mdast-util-gfm-task-list-item)
— serialize GFM task list items
* [`syntax-tree/mdast-util-math`](https://github.com/syntax-tree/mdast-util-math)
— serialize math
* [`syntax-tree/mdast-util-mdx`](https://github.com/syntax-tree/mdast-util-mdx)
— serialize MDX or MDX.js
* [`syntax-tree/mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression)
— serialize MDX or MDX.js expressions
* [`syntax-tree/mdast-util-mdx-jsx`](https://github.com/syntax-tree/mdast-util-mdx-jsx)
— serialize MDX or MDX.js JSX
* [`syntax-tree/mdast-util-mdxjs-esm`](https://github.com/syntax-tree/mdast-util-mdxjs-esm)
— serialize MDX.js ESM
## Security
`mdast-util-to-markdown` will do its best to serialize markdown to match the
syntax tree, but there are several cases where that is impossible.
Itll do its best, but complete roundtripping is impossible given that any value
could be injected into the tree.
As Markdown is sometimes used for HTML, and improper use of HTML can open you up
to a [cross-site scripting (XSS)][xss] attack, use of `mdast-util-to-markdown`
and parsing it again later could potentially be unsafe.
When parsing markdown afterwards and then going to HTML, use something like
[`hast-util-sanitize`][sanitize] to make the tree safe.
## Related
* [`micromark/micromark`](https://github.com/micromark/micromark)
— the smallest commonmark-compliant markdown parser that exists
* [`remarkjs/remark`](https://github.com/remarkjs/remark)
— markdown processor powered by plugins
* [`syntax-tree/mdast-util-from-markdown`](https://github.com/syntax-tree/mdast-util-from-markdown)
— parse markdown to mdast
## Contribute
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`support.md`][support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://github.com/syntax-tree/mdast-util-to-markdown/workflows/main/badge.svg
[build]: https://github.com/syntax-tree/mdast-util-to-markdown/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-to-markdown.svg
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-to-markdown
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-to-markdown.svg
[downloads]: https://www.npmjs.com/package/mdast-util-to-markdown
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-to-markdown.svg
[size]: https://bundlephobia.com/result?p=mdast-util-to-markdown
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/syntax-tree/unist/discussions
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://wooorm.com
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
[mdast]: https://github.com/syntax-tree/mdast
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[sanitize]: https://github.com/syntax-tree/hast-util-sanitize
[handlers]: lib/handle
[unsafe]: lib/unsafe.js

82
node_modules/mdast-util-to-markdown/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,82 @@
// Minimum TypeScript Version: 3.0
import {Node, Parent} from 'unist'
export = toMarkdown
declare namespace toMarkdown {
interface SafeOptions {
before: string
after: string
}
type Handle = (
node: Node,
parent: Parent | null | undefined,
context: Context,
safeOptions: SafeOptions
) => string
interface Context {
stack: string[]
enter: (type: string) => () => void
options: Options
unsafe: Unsafe[]
join: Join[]
handle: Handle
}
interface Handlers {
[key: string]: Handler
}
interface Handler {
peek?: Handle
(
node: Node,
parent: Parent | null | undefined,
context: Context,
safeOptions: SafeOptions
): string
}
interface Unsafe {
character: string
inConstruct?: string | string[]
notInConstruct?: string | string[]
after?: string
before?: string
atBreak?: boolean
}
type Join = (
left: Node,
right: Node,
parent: Parent,
context: Context
) => boolean | null | void
interface Options {
bullet?: '-' | '*' | '+'
closeAtx?: boolean
emphasis?: '_' | '*'
fence?: '~' | '`'
fences?: boolean
incrementListMarker?: boolean
listItemIndent?: 'tab' | 'one' | 'mixed'
quote?: '"' | "'"
resourceLink?: boolean
rule?: '-' | '_' | '*'
ruleRepetition?: number
ruleSpaces?: boolean
setext?: boolean
strong?: '_' | '*'
tightDefinitions?: boolean
extensions?: Options[]
handlers?: Handlers
join?: Join[]
unsafe?: Unsafe[]
}
}
declare function toMarkdown(node: Node, options?: toMarkdown.Options): string