完成世界书、骰子、apiconfig页面处理
This commit is contained in:
3
frontend/node_modules/mdast-util-to-markdown/index.js
generated
vendored
Normal file
3
frontend/node_modules/mdast-util-to-markdown/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// Note: extra types exposed from `index.d.ts`.
|
||||
export {toMarkdown} from './lib/index.js'
|
||||
export {handle as defaultHandlers} from './lib/handle/index.js'
|
||||
17
frontend/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts
generated
vendored
Normal file
17
frontend/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @import {Blockquote, Parents} from 'mdast'
|
||||
* @import {Info, Map, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
/**
|
||||
* @param {Blockquote} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function blockquote(node: Blockquote, _: Parents | undefined, state: State, info: Info): string;
|
||||
import type { Blockquote } from 'mdast';
|
||||
import type { Parents } from 'mdast';
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
import type { Info } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=blockquote.d.ts.map
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"blockquote.d.ts","sourceRoot":"","sources":["blockquote.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,iCANW,UAAU,KACV,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CAalB;gCAtBqC,OAAO;6BAAP,OAAO;2BACV,wBAAwB;0BAAxB,wBAAwB"}
|
||||
13
frontend/node_modules/mdast-util-to-markdown/lib/handle/break.d.ts
generated
vendored
Normal file
13
frontend/node_modules/mdast-util-to-markdown/lib/handle/break.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @param {Break} _
|
||||
* @param {Parents | undefined} _1
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function hardBreak(_: Break, _1: Parents | undefined, state: State, info: Info): string;
|
||||
import type { Break } from 'mdast';
|
||||
import type { Parents } from 'mdast';
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
import type { Info } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=break.d.ts.map
|
||||
13
frontend/node_modules/mdast-util-to-markdown/lib/handle/code.d.ts
generated
vendored
Normal file
13
frontend/node_modules/mdast-util-to-markdown/lib/handle/code.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @param {Code} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function code(node: Code, _: Parents | undefined, state: State, info: Info): string;
|
||||
import type { Code } from 'mdast';
|
||||
import type { Parents } from 'mdast';
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
import type { Info } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=code.d.ts.map
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["definition.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,iCANW,UAAU,KACV,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CA+DlB;gCAzEqC,OAAO;6BAAP,OAAO;2BADf,wBAAwB;0BAAxB,wBAAwB"}
|
||||
76
frontend/node_modules/mdast-util-to-markdown/lib/handle/definition.js
generated
vendored
Normal file
76
frontend/node_modules/mdast-util-to-markdown/lib/handle/definition.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {Definition, Parents} from 'mdast'
|
||||
*/
|
||||
|
||||
import {checkQuote} from '../util/check-quote.js'
|
||||
|
||||
/**
|
||||
* @param {Definition} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function definition(node, _, state, info) {
|
||||
const quote = checkQuote(state)
|
||||
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
||||
const exit = state.enter('definition')
|
||||
let subexit = state.enter('label')
|
||||
const tracker = state.createTracker(info)
|
||||
let value = tracker.move('[')
|
||||
value += tracker.move(
|
||||
state.safe(state.associationId(node), {
|
||||
before: value,
|
||||
after: ']',
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
value += tracker.move(']: ')
|
||||
|
||||
subexit()
|
||||
|
||||
if (
|
||||
// If there’s no url, or…
|
||||
!node.url ||
|
||||
// If there are control characters or whitespace.
|
||||
/[\0- \u007F]/.test(node.url)
|
||||
) {
|
||||
subexit = state.enter('destinationLiteral')
|
||||
value += tracker.move('<')
|
||||
value += tracker.move(
|
||||
state.safe(node.url, {before: value, after: '>', ...tracker.current()})
|
||||
)
|
||||
value += tracker.move('>')
|
||||
} else {
|
||||
// No whitespace, raw is prettier.
|
||||
subexit = state.enter('destinationRaw')
|
||||
value += tracker.move(
|
||||
state.safe(node.url, {
|
||||
before: value,
|
||||
after: node.title ? ' ' : '\n',
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
subexit()
|
||||
|
||||
if (node.title) {
|
||||
subexit = state.enter(`title${suffix}`)
|
||||
value += tracker.move(' ' + quote)
|
||||
value += tracker.move(
|
||||
state.safe(node.title, {
|
||||
before: value,
|
||||
after: quote,
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
value += tracker.move(quote)
|
||||
subexit()
|
||||
}
|
||||
|
||||
exit()
|
||||
|
||||
return value
|
||||
}
|
||||
69
frontend/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
generated
vendored
Normal file
69
frontend/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {Emphasis, Parents} from 'mdast'
|
||||
*/
|
||||
|
||||
import {checkEmphasis} from '../util/check-emphasis.js'
|
||||
import {encodeCharacterReference} from '../util/encode-character-reference.js'
|
||||
import {encodeInfo} from '../util/encode-info.js'
|
||||
|
||||
emphasis.peek = emphasisPeek
|
||||
|
||||
/**
|
||||
* @param {Emphasis} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function emphasis(node, _, state, info) {
|
||||
const marker = checkEmphasis(state)
|
||||
const exit = state.enter('emphasis')
|
||||
const tracker = state.createTracker(info)
|
||||
const before = tracker.move(marker)
|
||||
|
||||
let between = tracker.move(
|
||||
state.containerPhrasing(node, {
|
||||
after: marker,
|
||||
before,
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
const betweenHead = between.charCodeAt(0)
|
||||
const open = encodeInfo(
|
||||
info.before.charCodeAt(info.before.length - 1),
|
||||
betweenHead,
|
||||
marker
|
||||
)
|
||||
|
||||
if (open.inside) {
|
||||
between = encodeCharacterReference(betweenHead) + between.slice(1)
|
||||
}
|
||||
|
||||
const betweenTail = between.charCodeAt(between.length - 1)
|
||||
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker)
|
||||
|
||||
if (close.inside) {
|
||||
between = between.slice(0, -1) + encodeCharacterReference(betweenTail)
|
||||
}
|
||||
|
||||
const after = tracker.move(marker)
|
||||
|
||||
exit()
|
||||
|
||||
state.attentionEncodeSurroundingInfo = {
|
||||
after: close.outside,
|
||||
before: open.outside
|
||||
}
|
||||
return before + between + after
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Emphasis} _
|
||||
* @param {Parents | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
function emphasisPeek(_, _1, state) {
|
||||
return state.options.emphasis || '*'
|
||||
}
|
||||
75
frontend/node_modules/mdast-util-to-markdown/lib/handle/heading.js
generated
vendored
Normal file
75
frontend/node_modules/mdast-util-to-markdown/lib/handle/heading.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {Heading, Parents} from 'mdast'
|
||||
*/
|
||||
|
||||
import {encodeCharacterReference} from '../util/encode-character-reference.js'
|
||||
import {formatHeadingAsSetext} from '../util/format-heading-as-setext.js'
|
||||
|
||||
/**
|
||||
* @param {Heading} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function heading(node, _, state, info) {
|
||||
const rank = Math.max(Math.min(6, node.depth || 1), 1)
|
||||
const tracker = state.createTracker(info)
|
||||
|
||||
if (formatHeadingAsSetext(node, state)) {
|
||||
const exit = state.enter('headingSetext')
|
||||
const subexit = state.enter('phrasing')
|
||||
const value = state.containerPhrasing(node, {
|
||||
...tracker.current(),
|
||||
before: '\n',
|
||||
after: '\n'
|
||||
})
|
||||
subexit()
|
||||
exit()
|
||||
|
||||
return (
|
||||
value +
|
||||
'\n' +
|
||||
(rank === 1 ? '=' : '-').repeat(
|
||||
// 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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const sequence = '#'.repeat(rank)
|
||||
const exit = state.enter('headingAtx')
|
||||
const subexit = state.enter('phrasing')
|
||||
|
||||
// Note: for proper tracking, we should reset the output positions when there
|
||||
// is no content returned, because then the space is not output.
|
||||
// Practically, in that case, there is no content, so it doesn’t matter that
|
||||
// we’ve tracked one too many characters.
|
||||
tracker.move(sequence + ' ')
|
||||
|
||||
let value = state.containerPhrasing(node, {
|
||||
before: '# ',
|
||||
after: '\n',
|
||||
...tracker.current()
|
||||
})
|
||||
|
||||
if (/^[\t ]/.test(value)) {
|
||||
// To do: what effect has the character reference on tracking?
|
||||
value = encodeCharacterReference(value.charCodeAt(0)) + value.slice(1)
|
||||
}
|
||||
|
||||
value = value ? sequence + ' ' + value : sequence
|
||||
|
||||
if (state.options.closeAtx) {
|
||||
value += ' ' + sequence
|
||||
}
|
||||
|
||||
subexit()
|
||||
exit()
|
||||
|
||||
return value
|
||||
}
|
||||
20
frontend/node_modules/mdast-util-to-markdown/lib/handle/html.js
generated
vendored
Normal file
20
frontend/node_modules/mdast-util-to-markdown/lib/handle/html.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @import {Html} from 'mdast'
|
||||
*/
|
||||
|
||||
html.peek = htmlPeek
|
||||
|
||||
/**
|
||||
* @param {Html} node
|
||||
* @returns {string}
|
||||
*/
|
||||
export function html(node) {
|
||||
return node.value || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function htmlPeek() {
|
||||
return '<'
|
||||
}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/index.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;2BAAyB,iBAAiB;0BAClB,YAAY;qBACjB,WAAW;2BACL,iBAAiB;yBACnB,eAAe;wBAChB,cAAc;qBACjB,WAAW;sBACV,YAAY;+BACH,sBAAsB;2BAC1B,kBAAkB;qBACxB,WAAW;8BACF,qBAAqB;qBAC9B,WAAW;yBACP,gBAAgB;0BACf,gBAAgB;qBACrB,WAAW;uBACT,aAAa;qBACf,WAAW;8BACF,qBAAqB"}
|
||||
63
frontend/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
generated
vendored
Normal file
63
frontend/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {LinkReference, Parents} from 'mdast'
|
||||
*/
|
||||
|
||||
linkReference.peek = linkReferencePeek
|
||||
|
||||
/**
|
||||
* @param {LinkReference} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function linkReference(node, _, state, info) {
|
||||
const type = node.referenceType
|
||||
const exit = state.enter('linkReference')
|
||||
let subexit = state.enter('label')
|
||||
const tracker = state.createTracker(info)
|
||||
let value = tracker.move('[')
|
||||
const text = state.containerPhrasing(node, {
|
||||
before: value,
|
||||
after: ']',
|
||||
...tracker.current()
|
||||
})
|
||||
value += tracker.move(text + '][')
|
||||
|
||||
subexit()
|
||||
// Hide the fact that we’re in phrasing, because escapes don’t work.
|
||||
const stack = state.stack
|
||||
state.stack = []
|
||||
subexit = state.enter('reference')
|
||||
// Note: for proper tracking, we should reset the output positions when we end
|
||||
// up making a `shortcut` reference, because then there is no brace output.
|
||||
// Practically, in that case, there is no content, so it doesn’t matter that
|
||||
// we’ve tracked one too many characters.
|
||||
const reference = state.safe(state.associationId(node), {
|
||||
before: value,
|
||||
after: ']',
|
||||
...tracker.current()
|
||||
})
|
||||
subexit()
|
||||
state.stack = stack
|
||||
exit()
|
||||
|
||||
if (type === 'full' || !text || text !== reference) {
|
||||
value += tracker.move(reference + ']')
|
||||
} else if (type === 'shortcut') {
|
||||
// Remove the unwanted `[`.
|
||||
value = value.slice(0, -1)
|
||||
} else {
|
||||
value += tracker.move(']')
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function linkReferencePeek() {
|
||||
return '['
|
||||
}
|
||||
114
frontend/node_modules/mdast-util-to-markdown/lib/handle/link.js
generated
vendored
Normal file
114
frontend/node_modules/mdast-util-to-markdown/lib/handle/link.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {Link, Parents} from 'mdast'
|
||||
* @import {Exit} from '../types.js'
|
||||
*/
|
||||
|
||||
import {checkQuote} from '../util/check-quote.js'
|
||||
import {formatLinkAsAutolink} from '../util/format-link-as-autolink.js'
|
||||
|
||||
link.peek = linkPeek
|
||||
|
||||
/**
|
||||
* @param {Link} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function link(node, _, state, info) {
|
||||
const quote = checkQuote(state)
|
||||
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
||||
const tracker = state.createTracker(info)
|
||||
/** @type {Exit} */
|
||||
let exit
|
||||
/** @type {Exit} */
|
||||
let subexit
|
||||
|
||||
if (formatLinkAsAutolink(node, state)) {
|
||||
// Hide the fact that we’re in phrasing, because escapes don’t work.
|
||||
const stack = state.stack
|
||||
state.stack = []
|
||||
exit = state.enter('autolink')
|
||||
let value = tracker.move('<')
|
||||
value += tracker.move(
|
||||
state.containerPhrasing(node, {
|
||||
before: value,
|
||||
after: '>',
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
value += tracker.move('>')
|
||||
exit()
|
||||
state.stack = stack
|
||||
return value
|
||||
}
|
||||
|
||||
exit = state.enter('link')
|
||||
subexit = state.enter('label')
|
||||
let value = tracker.move('[')
|
||||
value += tracker.move(
|
||||
state.containerPhrasing(node, {
|
||||
before: value,
|
||||
after: '](',
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
value += tracker.move('](')
|
||||
subexit()
|
||||
|
||||
if (
|
||||
// If there’s no url but there is a title…
|
||||
(!node.url && node.title) ||
|
||||
// If there are control characters or whitespace.
|
||||
/[\0- \u007F]/.test(node.url)
|
||||
) {
|
||||
subexit = state.enter('destinationLiteral')
|
||||
value += tracker.move('<')
|
||||
value += tracker.move(
|
||||
state.safe(node.url, {before: value, after: '>', ...tracker.current()})
|
||||
)
|
||||
value += tracker.move('>')
|
||||
} else {
|
||||
// No whitespace, raw is prettier.
|
||||
subexit = state.enter('destinationRaw')
|
||||
value += tracker.move(
|
||||
state.safe(node.url, {
|
||||
before: value,
|
||||
after: node.title ? ' ' : ')',
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
subexit()
|
||||
|
||||
if (node.title) {
|
||||
subexit = state.enter(`title${suffix}`)
|
||||
value += tracker.move(' ' + quote)
|
||||
value += tracker.move(
|
||||
state.safe(node.title, {
|
||||
before: value,
|
||||
after: quote,
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
value += tracker.move(quote)
|
||||
subexit()
|
||||
}
|
||||
|
||||
value += tracker.move(')')
|
||||
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Link} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
function linkPeek(node, _, state) {
|
||||
return formatLinkAsAutolink(node, state) ? '<' : '['
|
||||
}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["list-item.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,+BANW,QAAQ,UACR,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CAgDlB;8BA3DmC,OAAO;6BAAP,OAAO;2BADR,wBAAwB;0BAAxB,wBAAwB"}
|
||||
100
frontend/node_modules/mdast-util-to-markdown/lib/handle/list.js
generated
vendored
Normal file
100
frontend/node_modules/mdast-util-to-markdown/lib/handle/list.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {List, Parents} from 'mdast'
|
||||
*/
|
||||
|
||||
import {checkBullet} from '../util/check-bullet.js'
|
||||
import {checkBulletOther} from '../util/check-bullet-other.js'
|
||||
import {checkBulletOrdered} from '../util/check-bullet-ordered.js'
|
||||
import {checkRule} from '../util/check-rule.js'
|
||||
|
||||
/**
|
||||
* @param {List} node
|
||||
* @param {Parents | undefined} parent
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function list(node, parent, state, info) {
|
||||
const exit = state.enter('list')
|
||||
const bulletCurrent = state.bulletCurrent
|
||||
/** @type {string} */
|
||||
let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state)
|
||||
/** @type {string} */
|
||||
const bulletOther = node.ordered
|
||||
? bullet === '.'
|
||||
? ')'
|
||||
: '.'
|
||||
: checkBulletOther(state)
|
||||
let useDifferentMarker =
|
||||
parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false
|
||||
|
||||
if (!node.ordered) {
|
||||
const firstListItem = node.children ? node.children[0] : undefined
|
||||
|
||||
// If there’s an empty first list item directly in two list items,
|
||||
// we have to use a different bullet:
|
||||
//
|
||||
// ```markdown
|
||||
// * - *
|
||||
// ```
|
||||
//
|
||||
// …because otherwise it would become one big thematic break.
|
||||
if (
|
||||
// Bullet could be used as a thematic break marker:
|
||||
(bullet === '*' || bullet === '-') &&
|
||||
// Empty first list item:
|
||||
firstListItem &&
|
||||
(!firstListItem.children || !firstListItem.children[0]) &&
|
||||
// Directly in two other list items:
|
||||
state.stack[state.stack.length - 1] === 'list' &&
|
||||
state.stack[state.stack.length - 2] === 'listItem' &&
|
||||
state.stack[state.stack.length - 3] === 'list' &&
|
||||
state.stack[state.stack.length - 4] === 'listItem' &&
|
||||
// That are each the first child.
|
||||
state.indexStack[state.indexStack.length - 1] === 0 &&
|
||||
state.indexStack[state.indexStack.length - 2] === 0 &&
|
||||
state.indexStack[state.indexStack.length - 3] === 0
|
||||
) {
|
||||
useDifferentMarker = true
|
||||
}
|
||||
|
||||
// If there’s a thematic break at the start of the first list item,
|
||||
// we have to use a different bullet:
|
||||
//
|
||||
// ```markdown
|
||||
// * ---
|
||||
// ```
|
||||
//
|
||||
// …because otherwise it would become one big thematic break.
|
||||
if (checkRule(state) === bullet && firstListItem) {
|
||||
let index = -1
|
||||
|
||||
while (++index < node.children.length) {
|
||||
const item = node.children[index]
|
||||
|
||||
if (
|
||||
item &&
|
||||
item.type === 'listItem' &&
|
||||
item.children &&
|
||||
item.children[0] &&
|
||||
item.children[0].type === 'thematicBreak'
|
||||
) {
|
||||
useDifferentMarker = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useDifferentMarker) {
|
||||
bullet = bulletOther
|
||||
}
|
||||
|
||||
state.bulletCurrent = bullet
|
||||
const value = state.containerFlow(node, info)
|
||||
state.bulletLastUsed = bullet
|
||||
state.bulletCurrent = bulletCurrent
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
20
frontend/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
generated
vendored
Normal file
20
frontend/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {Paragraph, Parents} from 'mdast'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Paragraph} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function paragraph(node, _, state, info) {
|
||||
const exit = state.enter('paragraph')
|
||||
const subexit = state.enter('phrasing')
|
||||
const value = state.containerPhrasing(node, info)
|
||||
subexit()
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
69
frontend/node_modules/mdast-util-to-markdown/lib/handle/strong.js
generated
vendored
Normal file
69
frontend/node_modules/mdast-util-to-markdown/lib/handle/strong.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {Parents, Strong} from 'mdast'
|
||||
*/
|
||||
|
||||
import {checkStrong} from '../util/check-strong.js'
|
||||
import {encodeCharacterReference} from '../util/encode-character-reference.js'
|
||||
import {encodeInfo} from '../util/encode-info.js'
|
||||
|
||||
strong.peek = strongPeek
|
||||
|
||||
/**
|
||||
* @param {Strong} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function strong(node, _, state, info) {
|
||||
const marker = checkStrong(state)
|
||||
const exit = state.enter('strong')
|
||||
const tracker = state.createTracker(info)
|
||||
const before = tracker.move(marker + marker)
|
||||
|
||||
let between = tracker.move(
|
||||
state.containerPhrasing(node, {
|
||||
after: marker,
|
||||
before,
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
const betweenHead = between.charCodeAt(0)
|
||||
const open = encodeInfo(
|
||||
info.before.charCodeAt(info.before.length - 1),
|
||||
betweenHead,
|
||||
marker
|
||||
)
|
||||
|
||||
if (open.inside) {
|
||||
between = encodeCharacterReference(betweenHead) + between.slice(1)
|
||||
}
|
||||
|
||||
const betweenTail = between.charCodeAt(between.length - 1)
|
||||
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker)
|
||||
|
||||
if (close.inside) {
|
||||
between = between.slice(0, -1) + encodeCharacterReference(betweenTail)
|
||||
}
|
||||
|
||||
const after = tracker.move(marker + marker)
|
||||
|
||||
exit()
|
||||
|
||||
state.attentionEncodeSurroundingInfo = {
|
||||
after: close.outside,
|
||||
before: open.outside
|
||||
}
|
||||
return before + between + after
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Strong} _
|
||||
* @param {Parents | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
function strongPeek(_, _1, state) {
|
||||
return state.options.strong || '*'
|
||||
}
|
||||
17
frontend/node_modules/mdast-util-to-markdown/lib/handle/text.d.ts
generated
vendored
Normal file
17
frontend/node_modules/mdast-util-to-markdown/lib/handle/text.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @import {Info, State} from 'mdast-util-to-markdown'
|
||||
* @import {Parents, Text} from 'mdast'
|
||||
*/
|
||||
/**
|
||||
* @param {Text} node
|
||||
* @param {Parents | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function text(node: Text, _: Parents | undefined, state: State, info: Info): string;
|
||||
import type { Text } from 'mdast';
|
||||
import type { Parents } from 'mdast';
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
import type { Info } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=text.d.ts.map
|
||||
14
frontend/node_modules/mdast-util-to-markdown/lib/index.d.ts
generated
vendored
Normal file
14
frontend/node_modules/mdast-util-to-markdown/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Turn an mdast syntax tree into markdown.
|
||||
*
|
||||
* @param {Nodes} tree
|
||||
* Tree to serialize.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {string}
|
||||
* Serialized markdown representing `tree`.
|
||||
*/
|
||||
export function toMarkdown(tree: Nodes, options?: Options | null | undefined): string;
|
||||
import type { Nodes } from 'mdast';
|
||||
import type { Options } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/index.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,iCAPW,KAAK,YAEL,OAAO,GAAG,IAAI,GAAG,SAAS,GAExB,MAAM,CAoElB;2BA5FuB,OAAO;6BAD0B,wBAAwB"}
|
||||
4
frontend/node_modules/mdast-util-to-markdown/lib/join.d.ts
generated
vendored
Normal file
4
frontend/node_modules/mdast-util-to-markdown/lib/join.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/** @type {Array<Join>} */
|
||||
export const join: Array<Join>;
|
||||
import type { Join } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=join.d.ts.map
|
||||
39
frontend/node_modules/mdast-util-to-markdown/lib/join.js
generated
vendored
Normal file
39
frontend/node_modules/mdast-util-to-markdown/lib/join.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @import {Join} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
|
||||
import {formatCodeAsIndented} from './util/format-code-as-indented.js'
|
||||
import {formatHeadingAsSetext} from './util/format-heading-as-setext.js'
|
||||
|
||||
/** @type {Array<Join>} */
|
||||
export const join = [joinDefaults]
|
||||
|
||||
/** @type {Join} */
|
||||
function joinDefaults(left, right, parent, state) {
|
||||
// Indented code after list or another indented code.
|
||||
if (
|
||||
right.type === 'code' &&
|
||||
formatCodeAsIndented(right, state) &&
|
||||
(left.type === 'list' ||
|
||||
(left.type === right.type && formatCodeAsIndented(left, state)))
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Join children of a list or an item.
|
||||
// In which case, `parent` has a `spread` field.
|
||||
if ('spread' in parent && 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, state)))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
return parent.spread ? 1 : 0
|
||||
}
|
||||
}
|
||||
4
frontend/node_modules/mdast-util-to-markdown/lib/unsafe.d.ts
generated
vendored
Normal file
4
frontend/node_modules/mdast-util-to-markdown/lib/unsafe.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/** @type {Array<Unsafe>} */
|
||||
export const unsafe: Array<Unsafe>;
|
||||
import type { Unsafe } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=unsafe.d.ts.map
|
||||
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
generated
vendored
Normal file
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @import {Options, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {State} state
|
||||
* @returns {Exclude<Options['bulletOrdered'], null | undefined>}
|
||||
*/
|
||||
export function checkBulletOrdered(state) {
|
||||
const marker = state.options.bulletOrdered || '.'
|
||||
|
||||
if (marker !== '.' && marker !== ')') {
|
||||
throw new Error(
|
||||
'Cannot serialize items with `' +
|
||||
marker +
|
||||
'` for `options.bulletOrdered`, expected `.` or `)`'
|
||||
)
|
||||
}
|
||||
|
||||
return marker
|
||||
}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"check-bullet-other.d.ts","sourceRoot":"","sources":["check-bullet-other.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wCAHW,KAAK,GACH,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CA6BxD;2BApCgC,wBAAwB;6BAAxB,wBAAwB"}
|
||||
38
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
generated
vendored
Normal file
38
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @import {Options, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
|
||||
import {checkBullet} from './check-bullet.js'
|
||||
|
||||
/**
|
||||
* @param {State} state
|
||||
* @returns {Exclude<Options['bullet'], null | undefined>}
|
||||
*/
|
||||
export function checkBulletOther(state) {
|
||||
const bullet = checkBullet(state)
|
||||
const bulletOther = state.options.bulletOther
|
||||
|
||||
if (!bulletOther) {
|
||||
return bullet === '*' ? '-' : '*'
|
||||
}
|
||||
|
||||
if (bulletOther !== '*' && bulletOther !== '+' && bulletOther !== '-') {
|
||||
throw new Error(
|
||||
'Cannot serialize items with `' +
|
||||
bulletOther +
|
||||
'` for `options.bulletOther`, expected `*`, `+`, or `-`'
|
||||
)
|
||||
}
|
||||
|
||||
if (bulletOther === bullet) {
|
||||
throw new Error(
|
||||
'Expected `bullet` (`' +
|
||||
bullet +
|
||||
'`) and `bulletOther` (`' +
|
||||
bulletOther +
|
||||
'`) to be different'
|
||||
)
|
||||
}
|
||||
|
||||
return bulletOther
|
||||
}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"check-bullet.d.ts","sourceRoot":"","sources":["check-bullet.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,mCAHW,KAAK,GACH,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CAcxD;2BAnBgC,wBAAwB;6BAAxB,wBAAwB"}
|
||||
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
generated
vendored
Normal file
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @import {Options, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {State} state
|
||||
* @returns {Exclude<Options['bullet'], null | undefined>}
|
||||
*/
|
||||
export function checkBullet(state) {
|
||||
const marker = state.options.bullet || '*'
|
||||
|
||||
if (marker !== '*' && marker !== '+' && marker !== '-') {
|
||||
throw new Error(
|
||||
'Cannot serialize items with `' +
|
||||
marker +
|
||||
'` for `options.bullet`, expected `*`, `+`, or `-`'
|
||||
)
|
||||
}
|
||||
|
||||
return marker
|
||||
}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"check-list-item-indent.d.ts","sourceRoot":"","sources":["check-list-item-indent.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,2CAHW,KAAK,GACH,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CAchE;2BAnBgC,wBAAwB;6BAAxB,wBAAwB"}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-quote.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-quote.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"check-quote.d.ts","sourceRoot":"","sources":["check-quote.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,kCAHW,KAAK,GACH,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CAcvD;2BAnBgC,wBAAwB;6BAAxB,wBAAwB"}
|
||||
11
frontend/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.d.ts
generated
vendored
Normal file
11
frontend/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @import {Options, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
/**
|
||||
* @param {State} state
|
||||
* @returns {Exclude<Options['ruleRepetition'], null | undefined>}
|
||||
*/
|
||||
export function checkRuleRepetition(state: State): Exclude<Options["ruleRepetition"], null | undefined>;
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
import type { Options } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=check-rule-repetition.d.ts.map
|
||||
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
generated
vendored
Normal file
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @import {Options, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {State} state
|
||||
* @returns {Exclude<Options['ruleRepetition'], null | undefined>}
|
||||
*/
|
||||
export function checkRuleRepetition(state) {
|
||||
const repetition = state.options.ruleRepetition || 3
|
||||
|
||||
if (repetition < 3) {
|
||||
throw new Error(
|
||||
'Cannot serialize rules with repetition `' +
|
||||
repetition +
|
||||
'` for `options.ruleRepetition`, expected `3` or more'
|
||||
)
|
||||
}
|
||||
|
||||
return repetition
|
||||
}
|
||||
11
frontend/node_modules/mdast-util-to-markdown/lib/util/check-rule.d.ts
generated
vendored
Normal file
11
frontend/node_modules/mdast-util-to-markdown/lib/util/check-rule.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @import {Options, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
/**
|
||||
* @param {State} state
|
||||
* @returns {Exclude<Options['rule'], null | undefined>}
|
||||
*/
|
||||
export function checkRule(state: State): Exclude<Options["rule"], null | undefined>;
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
import type { Options } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=check-rule.d.ts.map
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-strong.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/check-strong.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"check-strong.d.ts","sourceRoot":"","sources":["check-strong.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,mCAHW,KAAK,GACH,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CAcxD;2BAnBgC,wBAAwB;6BAAxB,wBAAwB"}
|
||||
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-strong.js
generated
vendored
Normal file
21
frontend/node_modules/mdast-util-to-markdown/lib/util/check-strong.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @import {Options, State} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {State} state
|
||||
* @returns {Exclude<Options['strong'], null | undefined>}
|
||||
*/
|
||||
export function checkStrong(state) {
|
||||
const marker = state.options.strong || '*'
|
||||
|
||||
if (marker !== '*' && marker !== '_') {
|
||||
throw new Error(
|
||||
'Cannot serialize strong with `' +
|
||||
marker +
|
||||
'` for `options.strong`, expected `*`, or `_`'
|
||||
)
|
||||
}
|
||||
|
||||
return marker
|
||||
}
|
||||
19
frontend/node_modules/mdast-util-to-markdown/lib/util/container-flow.d.ts
generated
vendored
Normal file
19
frontend/node_modules/mdast-util-to-markdown/lib/util/container-flow.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @import {State} from 'mdast-util-to-markdown'
|
||||
* @import {FlowChildren, FlowParents, TrackFields} from '../types.js'
|
||||
*/
|
||||
/**
|
||||
* @param {FlowParents} parent
|
||||
* Parent of flow nodes.
|
||||
* @param {State} state
|
||||
* Info passed around about the current state.
|
||||
* @param {TrackFields} info
|
||||
* Info on where we are in the document we are generating.
|
||||
* @returns {string}
|
||||
* Serialized children, joined by (blank) lines.
|
||||
*/
|
||||
export function containerFlow(parent: FlowParents, state: State, info: TrackFields): string;
|
||||
import type { FlowParents } from '../types.js';
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
import type { TrackFields } from '../types.js';
|
||||
//# sourceMappingURL=container-flow.d.ts.map
|
||||
84
frontend/node_modules/mdast-util-to-markdown/lib/util/container-flow.js
generated
vendored
Normal file
84
frontend/node_modules/mdast-util-to-markdown/lib/util/container-flow.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @import {State} from 'mdast-util-to-markdown'
|
||||
* @import {FlowChildren, FlowParents, TrackFields} from '../types.js'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {FlowParents} parent
|
||||
* Parent of flow nodes.
|
||||
* @param {State} state
|
||||
* Info passed around about the current state.
|
||||
* @param {TrackFields} info
|
||||
* Info on where we are in the document we are generating.
|
||||
* @returns {string}
|
||||
* Serialized children, joined by (blank) lines.
|
||||
*/
|
||||
export function containerFlow(parent, state, info) {
|
||||
const indexStack = state.indexStack
|
||||
const children = parent.children || []
|
||||
const tracker = state.createTracker(info)
|
||||
/** @type {Array<string>} */
|
||||
const results = []
|
||||
let index = -1
|
||||
|
||||
indexStack.push(-1)
|
||||
|
||||
while (++index < children.length) {
|
||||
const child = children[index]
|
||||
|
||||
indexStack[indexStack.length - 1] = index
|
||||
|
||||
results.push(
|
||||
tracker.move(
|
||||
state.handle(child, parent, state, {
|
||||
before: '\n',
|
||||
after: '\n',
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
if (child.type !== 'list') {
|
||||
state.bulletLastUsed = undefined
|
||||
}
|
||||
|
||||
if (index < children.length - 1) {
|
||||
results.push(
|
||||
tracker.move(between(child, children[index + 1], parent, state))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
indexStack.pop()
|
||||
|
||||
return results.join('')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {FlowChildren} left
|
||||
* @param {FlowChildren} right
|
||||
* @param {FlowParents} parent
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
function between(left, right, parent, state) {
|
||||
let index = state.join.length
|
||||
|
||||
while (index--) {
|
||||
const result = state.join[index](left, right, parent, state)
|
||||
|
||||
if (result === true || result === 1) {
|
||||
break
|
||||
}
|
||||
|
||||
if (typeof result === 'number') {
|
||||
return '\n'.repeat(1 + result)
|
||||
}
|
||||
|
||||
if (result === false) {
|
||||
return '\n\n<!---->\n\n'
|
||||
}
|
||||
}
|
||||
|
||||
return '\n\n'
|
||||
}
|
||||
7
frontend/node_modules/mdast-util-to-markdown/lib/util/emphasis-strong-marker.d.ts
generated
vendored
Normal file
7
frontend/node_modules/mdast-util-to-markdown/lib/util/emphasis-strong-marker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @this {State}
|
||||
* @returns {'*' | '_'}
|
||||
*/
|
||||
export function emphasisStrongMarker(this: State): "*" | "_";
|
||||
import type { State } from '../types.js';
|
||||
//# sourceMappingURL=emphasis-strong-marker.d.ts.map
|
||||
10
frontend/node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.d.ts
generated
vendored
Normal file
10
frontend/node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Encode a code point as a character reference.
|
||||
*
|
||||
* @param {number} code
|
||||
* Code point to encode.
|
||||
* @returns {string}
|
||||
* Encoded character reference.
|
||||
*/
|
||||
export function encodeCharacterReference(code: number): string;
|
||||
//# sourceMappingURL=encode-character-reference.d.ts.map
|
||||
11
frontend/node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
generated
vendored
Normal file
11
frontend/node_modules/mdast-util-to-markdown/lib/util/encode-character-reference.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Encode a code point as a character reference.
|
||||
*
|
||||
* @param {number} code
|
||||
* Code point to encode.
|
||||
* @returns {string}
|
||||
* Encoded character reference.
|
||||
*/
|
||||
export function encodeCharacterReference(code) {
|
||||
return '&#x' + code.toString(16).toUpperCase() + ';'
|
||||
}
|
||||
13
frontend/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.d.ts
generated
vendored
Normal file
13
frontend/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @import {State} from 'mdast-util-to-markdown'
|
||||
* @import {Code} from 'mdast'
|
||||
*/
|
||||
/**
|
||||
* @param {Code} node
|
||||
* @param {State} state
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function formatCodeAsIndented(node: Code, state: State): boolean;
|
||||
import type { Code } from 'mdast';
|
||||
import type { State } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=format-code-as-indented.d.ts.map
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"format-heading-as-setext.d.ts","sourceRoot":"","sources":["format-heading-as-setext.js"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,4CAJW,OAAO,SACP,KAAK,GACH,OAAO,CAsBnB;6BA/ByB,OAAO;2BADT,wBAAwB"}
|
||||
34
frontend/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
generated
vendored
Normal file
34
frontend/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @import {State} from 'mdast-util-to-markdown'
|
||||
* @import {Heading} from 'mdast'
|
||||
*/
|
||||
|
||||
import {EXIT, visit} from 'unist-util-visit'
|
||||
import {toString} from 'mdast-util-to-string'
|
||||
|
||||
/**
|
||||
* @param {Heading} node
|
||||
* @param {State} state
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function formatHeadingAsSetext(node, state) {
|
||||
let literalWithBreak = false
|
||||
|
||||
// Look for literals with a line break.
|
||||
// Note that this also
|
||||
visit(node, function (node) {
|
||||
if (
|
||||
('value' in node && /\r?\n|\r/.test(node.value)) ||
|
||||
node.type === 'break'
|
||||
) {
|
||||
literalWithBreak = true
|
||||
return EXIT
|
||||
}
|
||||
})
|
||||
|
||||
return Boolean(
|
||||
(!node.depth || node.depth < 3) &&
|
||||
toString(node) &&
|
||||
(state.options.setext || literalWithBreak)
|
||||
)
|
||||
}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"format-link-as-autolink.d.ts","sourceRoot":"","sources":["format-link-as-autolink.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,2CAJW,IAAI,SACJ,KAAK,GACH,OAAO,CAuBnB;0BA/BsB,OAAO;2BADN,wBAAwB"}
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/indent-lines.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/indent-lines.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"indent-lines.d.ts","sourceRoot":"","sources":["indent-lines.js"],"names":[],"mappings":""}
|
||||
12
frontend/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.d.ts
generated
vendored
Normal file
12
frontend/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @import {ConstructName, Unsafe} from 'mdast-util-to-markdown'
|
||||
*/
|
||||
/**
|
||||
* @param {Array<ConstructName>} stack
|
||||
* @param {Unsafe} pattern
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function patternInScope(stack: Array<ConstructName>, pattern: Unsafe): boolean;
|
||||
import type { ConstructName } from 'mdast-util-to-markdown';
|
||||
import type { Unsafe } from 'mdast-util-to-markdown';
|
||||
//# sourceMappingURL=pattern-in-scope.d.ts.map
|
||||
1
frontend/node_modules/mdast-util-to-markdown/lib/util/track.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/mdast-util-to-markdown/lib/util/track.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["track.js"],"names":[],"mappings":""}
|
||||
22
frontend/node_modules/mdast-util-to-markdown/license
generated
vendored
Normal file
22
frontend/node_modules/mdast-util-to-markdown/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 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.
|
||||
750
frontend/node_modules/mdast-util-to-markdown/readme.md
generated
vendored
Normal file
750
frontend/node_modules/mdast-util-to-markdown/readme.md
generated
vendored
Normal file
@@ -0,0 +1,750 @@
|
||||
# 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 that turns a syntax tree into markdown.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When should I use this?](#when-should-i-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`toMarkdown(tree[, options])`](#tomarkdowntree-options)
|
||||
* [`defaultHandlers`](#defaulthandlers)
|
||||
* [`ConstructName`](#constructname)
|
||||
* [`ConstructNameMap`](#constructnamemap)
|
||||
* [`Handle`](#handle)
|
||||
* [`Handlers`](#handlers)
|
||||
* [`Info`](#info)
|
||||
* [`Join`](#join)
|
||||
* [`Map`](#map)
|
||||
* [`Options`](#options)
|
||||
* [`SafeConfig`](#safeconfig)
|
||||
* [`State`](#state)
|
||||
* [`Tracker`](#tracker)
|
||||
* [`Unsafe`](#unsafe)
|
||||
* [List of extensions](#list-of-extensions)
|
||||
* [Syntax](#syntax)
|
||||
* [Syntax tree](#syntax-tree)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Security](#security)
|
||||
* [Related](#related)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a utility that takes an [mdast][] syntax tree as input and turns
|
||||
it into serialized markdown.
|
||||
|
||||
This utility is a low level project.
|
||||
It’s used in [`remark-stringify`][remark-stringify], which focusses on making it
|
||||
easier to transform content by abstracting these internals away.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
If you want to handle syntax trees manually, use this.
|
||||
For an easier time processing content, use the **[remark][]** ecosystem instead.
|
||||
|
||||
You can combine this utility with other utilities to add syntax extensions.
|
||||
Notable examples that deeply integrate with it are
|
||||
[`mdast-util-gfm`][mdast-util-gfm],
|
||||
[`mdast-util-mdx`][mdast-util-mdx],
|
||||
[`mdast-util-frontmatter`][mdast-util-frontmatter],
|
||||
[`mdast-util-math`][mdast-util-math], and
|
||||
[`mdast-util-directive`][mdast-util-directive].
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 16+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install mdast-util-to-markdown
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {toMarkdown} from 'https://esm.sh/mdast-util-to-markdown@2'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {toMarkdown} from 'https://esm.sh/mdast-util-to-markdown@2?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
Say our module `example.js` looks as follows:
|
||||
|
||||
```js
|
||||
/**
|
||||
* @import {Root} from 'mdast'
|
||||
*/
|
||||
|
||||
import {toMarkdown} from 'mdast-util-to-markdown'
|
||||
|
||||
/** @type {Root} */
|
||||
const 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.js` yields:
|
||||
|
||||
```markdown
|
||||
> ***
|
||||
>
|
||||
> \- a
|
||||
> b \
|
||||
```
|
||||
|
||||
> 👉 **Note**: observe the properly escaped characters which would otherwise
|
||||
> turn into a list and image respectively.
|
||||
|
||||
## API
|
||||
|
||||
This package exports the identifiers [`defaultHandlers`][api-default-handlers]
|
||||
and [`toMarkdown`][api-to-markdown].
|
||||
There is no default export.
|
||||
|
||||
### `toMarkdown(tree[, options])`
|
||||
|
||||
Turn an **[mdast][]** syntax tree into markdown.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `tree` ([`Node`][node])
|
||||
— tree to serialize
|
||||
* `options` ([`Options`][api-options], optional)
|
||||
— configuration
|
||||
|
||||
###### Returns
|
||||
|
||||
Serialized markdown representing `tree` (`string`).
|
||||
|
||||
### `defaultHandlers`
|
||||
|
||||
Default (CommonMark) handlers ([`Handlers`][api-handlers]).
|
||||
|
||||
### `ConstructName`
|
||||
|
||||
Construct names for things generated by `mdast-util-to-markdown` (TypeScript
|
||||
type).
|
||||
|
||||
This is an enum of strings, each being a semantic label, useful to know when
|
||||
serializing whether we’re for example in a double (`"`) or single (`'`) quoted
|
||||
title.
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type ConstructName = ConstructNameMap[keyof ConstructNameMap]
|
||||
```
|
||||
|
||||
### `ConstructNameMap`
|
||||
|
||||
Interface of registered constructs (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
interface ConstructNameMap { /* see code */ }
|
||||
```
|
||||
|
||||
When working on extensions that use new constructs, extend the corresponding
|
||||
interface to register its name:
|
||||
|
||||
```ts
|
||||
declare module 'mdast-util-to-markdown' {
|
||||
interface ConstructNameMap {
|
||||
// Register a new construct name (value is used, key should match it).
|
||||
gfmStrikethrough: 'gfmStrikethrough'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `Handle`
|
||||
|
||||
Handle a particular node (TypeScript type).
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `node` (`any`)
|
||||
— expected mdast node
|
||||
* `parent` ([`Node`][node], optional)
|
||||
— parent of `node`
|
||||
* `state` ([`State`][api-state])
|
||||
— info passed around about the current state
|
||||
* `info` ([`Info`][api-info])
|
||||
— info on the surrounding of the node that is serialized
|
||||
|
||||
###### Returns
|
||||
|
||||
Serialized markdown representing `node` (`string`).
|
||||
|
||||
### `Handlers`
|
||||
|
||||
Handle particular nodes (TypeScript type).
|
||||
|
||||
Each key is a node type (`Node['type']`), each value its corresponding handler
|
||||
([`Handle`][api-handle]).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Handlers = Record<Node['type'], Handle>
|
||||
```
|
||||
|
||||
### `Info`
|
||||
|
||||
Info on the surrounding of the node that is serialized (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `now` ([`Point`][point])
|
||||
— current point
|
||||
* `lineShift` (`number`)
|
||||
— number of columns each line will be shifted by wrapping nodes
|
||||
* `before` (`string`)
|
||||
— characters before this (guaranteed to be one, can be more)
|
||||
* `after` (`string`)
|
||||
— characters after this (guaranteed to be one, can be more)
|
||||
|
||||
### `Join`
|
||||
|
||||
How to join two blocks (TypeScript type).
|
||||
|
||||
“Blocks” are typically joined by one blank line.
|
||||
Sometimes it’s nicer to have them flush next to each other, yet other times
|
||||
they cannot occur together at all.
|
||||
|
||||
Join functions receive two adjacent siblings and their parent and what they
|
||||
return defines how many blank lines to use between them.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `left` ([`Node`][node])
|
||||
— first of two adjacent siblings
|
||||
* `right` ([`Node`][node])
|
||||
— second of two adjacent siblings
|
||||
* `parent` ([`Node`][node])
|
||||
— parent of the two siblings
|
||||
* `state` ([`State`][api-state])
|
||||
— info passed around about the current state
|
||||
|
||||
###### Returns
|
||||
|
||||
How many blank lines to use between the siblings (`boolean`, `number`,
|
||||
optional).
|
||||
|
||||
Where `true` is as passing `1` and `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
|
||||
```
|
||||
|
||||
> 👉 **Note**: abusing this feature will break markdown.
|
||||
> One such example is when returning `0` for two paragraphs, which will result
|
||||
> in the text running together, and in the future to be seen as one paragraph.
|
||||
|
||||
### `Map`
|
||||
|
||||
Map function to pad a single line (TypeScript type).
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `value` (`string`)
|
||||
— a single line of serialized markdown
|
||||
* `line` (`number`)
|
||||
— line number relative to the fragment
|
||||
* `blank` (`boolean`)
|
||||
— whether the line is considered blank in markdown
|
||||
|
||||
###### Returns
|
||||
|
||||
Padded line (`string`).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
##### Fields
|
||||
|
||||
The following fields influence how markdown is serialized.
|
||||
|
||||
###### `options.bullet`
|
||||
|
||||
Marker to use for bullets of items in unordered lists (`'*'`, `'+'`, or `'-'`,
|
||||
default: `'*'`).
|
||||
|
||||
There are three cases where the primary bullet cannot be used:
|
||||
|
||||
* when three or more list items are on their own, the last one is empty, and
|
||||
`bullet` is also a valid `rule`: `* - +`; this would turn into a thematic
|
||||
break if serialized with three primary bullets; `bulletOther` is used for
|
||||
the last item
|
||||
* when a thematic break is the first child of a list item and `bullet` is the
|
||||
same character as `rule`: `- ***`; this would turn into a single thematic
|
||||
break if serialized with primary bullets; `bulletOther` is used for the
|
||||
item
|
||||
* when two unordered lists appear next to each other: `* a\n- b`;
|
||||
`bulletOther` is used for such lists
|
||||
|
||||
###### `options.bulletOther`
|
||||
|
||||
Marker to use in certain cases where the primary bullet doesn’t work (`'*'`,
|
||||
`'+'`, or `'-'`, default: `'-'` when `bullet` is `'*'`, `'*'` otherwise).
|
||||
|
||||
Cannot be equal to `bullet`.
|
||||
|
||||
###### `options.bulletOrdered`
|
||||
|
||||
Marker to use for bullets of items in ordered lists (`'.'` or `')'`, default:
|
||||
`'.'`).
|
||||
|
||||
There is one case where the primary bullet for ordered items cannot be used:
|
||||
|
||||
* when two ordered lists appear next to each other: `1. a\n2) b`; to solve
|
||||
that, `'.'` will be used when `bulletOrdered` is `')'`, and `'.'` otherwise
|
||||
|
||||
###### `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 for emphasis (`'*'` or `'_'`, default: `'*'`).
|
||||
|
||||
###### `options.fence`
|
||||
|
||||
Marker to use for fenced code (``'`'`` or `'~'`, default: ``'`'``).
|
||||
|
||||
###### `options.fences`
|
||||
|
||||
Whether to use fenced code always (`boolean`, default: `true`).
|
||||
The default is to use fenced code if there is a language defined, if the code is
|
||||
empty, or if it starts or ends in blank lines.
|
||||
|
||||
###### `options.incrementListMarker`
|
||||
|
||||
Whether to increment the counter of ordered lists items (`boolean`, default:
|
||||
`true`).
|
||||
|
||||
###### `options.listItemIndent`
|
||||
|
||||
How to indent the content of list items (`'mixed'`, `'one'`, or `'tab'`,
|
||||
default: `'one'`).
|
||||
Either with the size of the bullet plus one space (when `'one'`), 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).
|
||||
|
||||
###### `options.quote`
|
||||
|
||||
Marker to use for titles (`'"'` or `"'"`, default: `'"'`).
|
||||
|
||||
###### `options.resourceLink`
|
||||
|
||||
Whether to always use resource links (`boolean`, default: `false`).
|
||||
The default is to use autolinks (`<https://example.com>`) when possible
|
||||
and resource links (`[text](url)`) otherwise.
|
||||
|
||||
###### `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`).
|
||||
The default is to always use ATX headings (`# heading`) instead of setext
|
||||
headings (`heading\n=======`).
|
||||
Setext headings cannot be used for empty headings or headings with a rank of
|
||||
three or more.
|
||||
|
||||
###### `options.strong`
|
||||
|
||||
Marker to use for strong (`'*'` or `'_'`, default: `'*'`).
|
||||
|
||||
###### `options.tightDefinitions`
|
||||
|
||||
Whether to join definitions without a blank line (`boolean`, default: `false`).
|
||||
|
||||
The default is to add blank lines between any flow (“block”) construct.
|
||||
Turning this option on is a shortcut for a [`Join`][api-join] function like so:
|
||||
|
||||
```js
|
||||
function joinTightDefinitions(left, right) {
|
||||
if (left.type === 'definition' && right.type === 'definition') {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
###### `options.handlers`
|
||||
|
||||
Handle particular nodes ([`Handlers`][api-handlers], optional).
|
||||
|
||||
###### `options.join`
|
||||
|
||||
How to join blocks ([`Array<Join>`][api-join], optional).
|
||||
|
||||
###### `options.unsafe`
|
||||
|
||||
Schemas that define when characters cannot occur
|
||||
([`Array<Unsafe>`][api-unsafe], optional).
|
||||
|
||||
###### `options.extensions`
|
||||
|
||||
List of extensions (`Array<Options>`, default: `[]`).
|
||||
Each extension is an object with the same interface as `Options` itself.
|
||||
|
||||
### `SafeConfig`
|
||||
|
||||
Configuration passed to `state.safe` (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `before` (`string`)
|
||||
— characters before this (guaranteed to be one, can be more)
|
||||
* `after` (`string`)
|
||||
— characters after this (guaranteed to be one, can be more)
|
||||
* `encode` (`Array<string>`, optional)
|
||||
— extra characters that *must* be encoded (as character references) instead
|
||||
of escaped (character escapes).
|
||||
Only ASCII punctuation will use character escapes, so you never need to
|
||||
pass non-ASCII-punctuation here
|
||||
|
||||
### `State`
|
||||
|
||||
Info passed around about the current state (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `stack` ([`Array<ConstructName>`][api-construct-name])
|
||||
— stack of constructs we’re in
|
||||
* `indexStack` (`Array<number>`)
|
||||
— positions of child nodes in their parents
|
||||
* `associationId` (`(node: Association) => string`)
|
||||
— get an identifier from an association to match it to others (see
|
||||
[`Association`][association])
|
||||
* `enter` (`(construct: ConstructName) => () => undefined`)
|
||||
— enter a construct (returns a corresponding exit function)
|
||||
(see [`ConstructName`][api-construct-name])
|
||||
* `indentLines` (`(value: string, map: Map) => string`)
|
||||
— pad serialized markdown (see [`Map`][api-map])
|
||||
* `compilePattern` (`(pattern: Unsafe) => RegExp`)
|
||||
— compile an unsafe pattern to a regex (see [`Unsafe`][api-unsafe])
|
||||
* `containerFlow` (`(parent: Node, info: Info) => string`)
|
||||
— serialize flow children (see [`Info`][api-info])
|
||||
* `containerPhrasing` (`(parent: Node, info: Info) => string`)
|
||||
— serialize phrasing children (see [`Info`][api-info])
|
||||
* `createTracker` (`(info: Info) => Tracker`)
|
||||
— track positional info in the output (see [`Info`][api-info],
|
||||
[`Tracker`][api-tracker])
|
||||
* `safe` (`(value: string, config: SafeConfig) => string`)
|
||||
— make a string safe for embedding (see [`SafeConfig`][api-safe-config])
|
||||
* `options` ([`Options`][api-options])
|
||||
— applied user configuration
|
||||
* `unsafe` ([`Array<Unsafe>`][api-unsafe])
|
||||
— applied unsafe patterns
|
||||
* `join` ([`Array<Join>`][api-join])
|
||||
— applied join handlers
|
||||
* `handle` ([`Handle`][api-handle])
|
||||
— call the configured handler for the given node
|
||||
* `handlers` ([`Handlers`][api-handlers])
|
||||
— applied handlers
|
||||
* `bulletCurrent` (`string` or `undefined`)
|
||||
— list marker currently in use
|
||||
* `bulletLastUsed` (`string` or `undefined`)
|
||||
— list marker previously in use
|
||||
|
||||
### `Tracker`
|
||||
|
||||
Track positional info in the output (TypeScript type).
|
||||
|
||||
This info isn’t used yet but such functionality will allow line wrapping,
|
||||
source maps, etc.
|
||||
|
||||
###### Fields
|
||||
|
||||
* `current` (`() => Info`)
|
||||
— get current tracked info
|
||||
* `shift` (`(value: number) => undefined`)
|
||||
— define a relative increased line shift (the typical indent for lines)
|
||||
* `move` (`(value: string) => string`)
|
||||
— move past some generated markdown
|
||||
|
||||
### `Unsafe`
|
||||
|
||||
Schema that defines when a character cannot occur (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `character` (`string`)
|
||||
— single unsafe character
|
||||
* `inConstruct` ([`Array<ConstructName>`][api-construct-name],
|
||||
`ConstructName`, optional)
|
||||
— constructs where this is bad
|
||||
* `notInConstruct` ([`Array<ConstructName>`][api-construct-name],
|
||||
`ConstructName`, optional)
|
||||
— constructs where this is fine again
|
||||
* `before` (`string`, optional)
|
||||
— `character` is bad when this is before it (cannot be used together with
|
||||
`atBreak`)
|
||||
* `after` (`string`, optional)
|
||||
— `character` is bad when this is after it
|
||||
* `atBreak` (`boolean`, optional)
|
||||
— `character` is bad at a break (cannot be used together with `before`)
|
||||
|
||||
## List of extensions
|
||||
|
||||
* [`syntax-tree/mdast-util-directive`](https://github.com/syntax-tree/mdast-util-directive)
|
||||
— directives
|
||||
* [`syntax-tree/mdast-util-frontmatter`](https://github.com/syntax-tree/mdast-util-frontmatter)
|
||||
— frontmatter (YAML, TOML, more)
|
||||
* [`syntax-tree/mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm)
|
||||
— GFM
|
||||
* [`syntax-tree/mdast-util-gfm-autolink-literal`](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal)
|
||||
— GFM autolink literals
|
||||
* [`syntax-tree/mdast-util-gfm-footnote`](https://github.com/syntax-tree/mdast-util-gfm-footnote)
|
||||
— GFM footnotes
|
||||
* [`syntax-tree/mdast-util-gfm-strikethrough`](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)
|
||||
— GFM strikethrough
|
||||
* [`syntax-tree/mdast-util-gfm-table`](https://github.com/syntax-tree/mdast-util-gfm-table)
|
||||
— GFM tables
|
||||
* [`syntax-tree/mdast-util-gfm-task-list-item`](https://github.com/syntax-tree/mdast-util-gfm-task-list-item)
|
||||
— GFM task list items
|
||||
* [`syntax-tree/mdast-util-math`](https://github.com/syntax-tree/mdast-util-math)
|
||||
— math
|
||||
* [`syntax-tree/mdast-util-mdx`](https://github.com/syntax-tree/mdast-util-mdx)
|
||||
— MDX
|
||||
* [`syntax-tree/mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression)
|
||||
— MDX expressions
|
||||
* [`syntax-tree/mdast-util-mdx-jsx`](https://github.com/syntax-tree/mdast-util-mdx-jsx)
|
||||
— MDX JSX
|
||||
* [`syntax-tree/mdast-util-mdxjs-esm`](https://github.com/syntax-tree/mdast-util-mdxjs-esm)
|
||||
— MDX ESM
|
||||
|
||||
## Syntax
|
||||
|
||||
Markdown is serialized according to CommonMark but care is taken to format in
|
||||
such a way that the resulting markdown should work with most markdown parsers.
|
||||
Extensions can add support for custom syntax.
|
||||
|
||||
## Syntax tree
|
||||
|
||||
The syntax tree is [mdast][].
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
It exports the additional types
|
||||
[`ConstructName`][api-construct-name],
|
||||
[`ConstructNameMap`][api-construct-name-map],
|
||||
[`Handle`][api-handle],
|
||||
[`Handlers`][api-handlers],
|
||||
[`Info`][api-info],
|
||||
[`Join`][api-join],
|
||||
[`Map`][api-map],
|
||||
[`Options`][api-options],
|
||||
[`SafeConfig`][api-safe-config],
|
||||
[`State`][api-State], and
|
||||
[`Unsafe`][api-Unsafe].
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
|
||||
When we cut a new major release, we drop support for unmaintained versions of
|
||||
Node.
|
||||
This means we try to keep the current release line, `mdast-util-to-markdown@^2`,
|
||||
compatible with Node.js 16.
|
||||
|
||||
## 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.
|
||||
It’ll 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`][hast-util-sanitize] to make the tree safe.
|
||||
|
||||
## Related
|
||||
|
||||
* [`syntax-tree/mdast-util-from-markdown`](https://github.com/syntax-tree/mdast-util-from-markdown)
|
||||
— parse markdown to mdast
|
||||
* [`micromark/micromark`](https://github.com/micromark/micromark)
|
||||
— parse markdown
|
||||
* [`remarkjs/remark`](https://github.com/remarkjs/remark)
|
||||
— process markdown
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] 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/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-to-markdown
|
||||
|
||||
[size]: https://bundlejs.com/?q=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
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[health]: https://github.com/syntax-tree/.github
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
||||
|
||||
[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize
|
||||
|
||||
[point]: https://github.com/syntax-tree/unist#point
|
||||
|
||||
[mdast]: https://github.com/syntax-tree/mdast
|
||||
|
||||
[node]: https://github.com/syntax-tree/mdast#nodes
|
||||
|
||||
[association]: https://github.com/syntax-tree/mdast#association
|
||||
|
||||
[mdast-util-gfm]: https://github.com/syntax-tree/mdast-util-gfm
|
||||
|
||||
[mdast-util-mdx]: https://github.com/syntax-tree/mdast-util-mdx
|
||||
|
||||
[mdast-util-frontmatter]: https://github.com/syntax-tree/mdast-util-frontmatter
|
||||
|
||||
[mdast-util-math]: https://github.com/syntax-tree/mdast-util-math
|
||||
|
||||
[mdast-util-directive]: https://github.com/syntax-tree/mdast-util-directive
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[api-construct-name]: #constructname
|
||||
|
||||
[api-construct-name-map]: #constructnamemap
|
||||
|
||||
[api-default-handlers]: #defaulthandlers
|
||||
|
||||
[api-handle]: #handle
|
||||
|
||||
[api-handlers]: #handlers
|
||||
|
||||
[api-info]: #info
|
||||
|
||||
[api-join]: #join
|
||||
|
||||
[api-map]: #map
|
||||
|
||||
[api-options]: #options
|
||||
|
||||
[api-safe-config]: #safeconfig
|
||||
|
||||
[api-state]: #state
|
||||
|
||||
[api-to-markdown]: #tomarkdowntree-options
|
||||
|
||||
[api-tracker]: #tracker
|
||||
|
||||
[api-unsafe]: #unsafe
|
||||
Reference in New Issue
Block a user