🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
25
node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts
generated
vendored
Normal file
25
node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Blockquote} Blockquote
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
* @typedef {import('../types.js').Map} Map
|
||||
*/
|
||||
/**
|
||||
* @param {Blockquote} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function blockquote(
|
||||
node: Blockquote,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Blockquote = import('mdast').Blockquote
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
export type Map = import('../types.js').Map
|
||||
32
node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
generated
vendored
Normal file
32
node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Blockquote} Blockquote
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
* @typedef {import('../types.js').Map} Map
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Blockquote} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function blockquote(node, _, state, info) {
|
||||
const exit = state.enter('blockquote')
|
||||
const tracker = state.createTracker(info)
|
||||
tracker.move('> ')
|
||||
tracker.shift(2)
|
||||
const value = state.indentLines(
|
||||
state.containerFlow(node, tracker.current()),
|
||||
map
|
||||
)
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
|
||||
/** @type {Map} */
|
||||
function map(line, _, blank) {
|
||||
return '>' + (blank ? '' : ' ') + line
|
||||
}
|
||||
17
node_modules/mdast-util-to-markdown/lib/handle/break.d.ts
generated
vendored
Normal file
17
node_modules/mdast-util-to-markdown/lib/handle/break.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @param {Break} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function hardBreak(
|
||||
_: Break,
|
||||
_1: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Break = import('mdast').Break
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
32
node_modules/mdast-util-to-markdown/lib/handle/break.js
generated
vendored
Normal file
32
node_modules/mdast-util-to-markdown/lib/handle/break.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Break} Break
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {patternInScope} from '../util/pattern-in-scope.js'
|
||||
|
||||
/**
|
||||
* @param {Break} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function hardBreak(_, _1, state, info) {
|
||||
let index = -1
|
||||
|
||||
while (++index < state.unsafe.length) {
|
||||
// If we can’t put eols in this construct (setext headings, tables), use a
|
||||
// space instead.
|
||||
if (
|
||||
state.unsafe[index].character === '\n' &&
|
||||
patternInScope(state.stack, state.unsafe[index])
|
||||
) {
|
||||
return /[ \t]/.test(info.before) ? '' : ' '
|
||||
}
|
||||
}
|
||||
|
||||
return '\\\n'
|
||||
}
|
||||
18
node_modules/mdast-util-to-markdown/lib/handle/code.d.ts
generated
vendored
Normal file
18
node_modules/mdast-util-to-markdown/lib/handle/code.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* @param {Code} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function code(
|
||||
node: Code,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Code = import('mdast').Code
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
export type Map = import('../types.js').Map
|
||||
78
node_modules/mdast-util-to-markdown/lib/handle/code.js
generated
vendored
Normal file
78
node_modules/mdast-util-to-markdown/lib/handle/code.js
generated
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Code} Code
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
* @typedef {import('../types.js').Map} Map
|
||||
*/
|
||||
|
||||
import {longestStreak} from 'longest-streak'
|
||||
import {formatCodeAsIndented} from '../util/format-code-as-indented.js'
|
||||
import {checkFence} from '../util/check-fence.js'
|
||||
|
||||
/**
|
||||
* @param {Code} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function code(node, _, state, info) {
|
||||
const marker = checkFence(state)
|
||||
const raw = node.value || ''
|
||||
const suffix = marker === '`' ? 'GraveAccent' : 'Tilde'
|
||||
|
||||
if (formatCodeAsIndented(node, state)) {
|
||||
const exit = state.enter('codeIndented')
|
||||
const value = state.indentLines(raw, map)
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
|
||||
const tracker = state.createTracker(info)
|
||||
const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3))
|
||||
const exit = state.enter('codeFenced')
|
||||
let value = tracker.move(sequence)
|
||||
|
||||
if (node.lang) {
|
||||
const subexit = state.enter(`codeFencedLang${suffix}`)
|
||||
value += tracker.move(
|
||||
state.safe(node.lang, {
|
||||
before: value,
|
||||
after: ' ',
|
||||
encode: ['`'],
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
subexit()
|
||||
}
|
||||
|
||||
if (node.lang && node.meta) {
|
||||
const subexit = state.enter(`codeFencedMeta${suffix}`)
|
||||
value += tracker.move(' ')
|
||||
value += tracker.move(
|
||||
state.safe(node.meta, {
|
||||
before: value,
|
||||
after: '\n',
|
||||
encode: ['`'],
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
subexit()
|
||||
}
|
||||
|
||||
value += tracker.move('\n')
|
||||
|
||||
if (raw) {
|
||||
value += tracker.move(raw + '\n')
|
||||
}
|
||||
|
||||
value += tracker.move(sequence)
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
|
||||
/** @type {Map} */
|
||||
function map(line, _, blank) {
|
||||
return (blank ? '' : ' ') + line
|
||||
}
|
||||
17
node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts
generated
vendored
Normal file
17
node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @param {Definition} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function definition(
|
||||
node: Definition,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Definition = import('mdast').Definition
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
78
node_modules/mdast-util-to-markdown/lib/handle/definition.js
generated
vendored
Normal file
78
node_modules/mdast-util-to-markdown/lib/handle/definition.js
generated
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Definition} Definition
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {checkQuote} from '../util/check-quote.js'
|
||||
|
||||
/**
|
||||
* @param {Definition} node
|
||||
* @param {Parent | 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
|
||||
}
|
||||
32
node_modules/mdast-util-to-markdown/lib/handle/emphasis.d.ts
generated
vendored
Normal file
32
node_modules/mdast-util-to-markdown/lib/handle/emphasis.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* @param {Emphasis} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function emphasis(
|
||||
node: Emphasis,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export namespace emphasis {
|
||||
export {emphasisPeek as peek}
|
||||
}
|
||||
export type Emphasis = import('mdast').Emphasis
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
/**
|
||||
* @param {Emphasis} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function emphasisPeek(
|
||||
_: Emphasis,
|
||||
_1: Parent | undefined,
|
||||
state: State
|
||||
): string
|
||||
export {}
|
||||
48
node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
generated
vendored
Normal file
48
node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Emphasis} Emphasis
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {checkEmphasis} from '../util/check-emphasis.js'
|
||||
|
||||
emphasis.peek = emphasisPeek
|
||||
|
||||
// To do: there are cases where emphasis cannot “form” depending on the
|
||||
// previous or next character of sequences.
|
||||
// There’s no way around that though, except for injecting zero-width stuff.
|
||||
// Do we need to safeguard against that?
|
||||
/**
|
||||
* @param {Emphasis} node
|
||||
* @param {Parent | 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)
|
||||
let value = tracker.move(marker)
|
||||
value += tracker.move(
|
||||
state.containerPhrasing(node, {
|
||||
before: value,
|
||||
after: marker,
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
value += tracker.move(marker)
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Emphasis} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
function emphasisPeek(_, _1, state) {
|
||||
return state.options.emphasis || '*'
|
||||
}
|
||||
17
node_modules/mdast-util-to-markdown/lib/handle/heading.d.ts
generated
vendored
Normal file
17
node_modules/mdast-util-to-markdown/lib/handle/heading.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @param {Heading} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function heading(
|
||||
node: Heading,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Heading = import('mdast').Heading
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
80
node_modules/mdast-util-to-markdown/lib/handle/heading.js
generated
vendored
Normal file
80
node_modules/mdast-util-to-markdown/lib/handle/heading.js
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Heading} Heading
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {formatHeadingAsSetext} from '../util/format-heading-as-setext.js'
|
||||
|
||||
/**
|
||||
* @param {Heading} node
|
||||
* @param {Parent | 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 =
|
||||
'&#x' +
|
||||
value.charCodeAt(0).toString(16).toUpperCase() +
|
||||
';' +
|
||||
value.slice(1)
|
||||
}
|
||||
|
||||
value = value ? sequence + ' ' + value : sequence
|
||||
|
||||
if (state.options.closeAtx) {
|
||||
value += ' ' + sequence
|
||||
}
|
||||
|
||||
subexit()
|
||||
exit()
|
||||
|
||||
return value
|
||||
}
|
||||
14
node_modules/mdast-util-to-markdown/lib/handle/html.d.ts
generated
vendored
Normal file
14
node_modules/mdast-util-to-markdown/lib/handle/html.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* @param {HTML} node
|
||||
* @returns {string}
|
||||
*/
|
||||
export function html(node: HTML): string
|
||||
export namespace html {
|
||||
export {htmlPeek as peek}
|
||||
}
|
||||
export type HTML = import('mdast').HTML
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function htmlPeek(): string
|
||||
export {}
|
||||
20
node_modules/mdast-util-to-markdown/lib/handle/html.js
generated
vendored
Normal file
20
node_modules/mdast-util-to-markdown/lib/handle/html.js
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* @typedef {import('mdast').HTML} HTML
|
||||
*/
|
||||
|
||||
html.peek = htmlPeek
|
||||
|
||||
/**
|
||||
* @param {HTML} node
|
||||
* @returns {string}
|
||||
*/
|
||||
export function html(node) {
|
||||
return node.value || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function htmlPeek() {
|
||||
return '<'
|
||||
}
|
||||
25
node_modules/mdast-util-to-markdown/lib/handle/image-reference.d.ts
generated
vendored
Normal file
25
node_modules/mdast-util-to-markdown/lib/handle/image-reference.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @param {ImageReference} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function imageReference(
|
||||
node: ImageReference,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export namespace imageReference {
|
||||
export {imageReferencePeek as peek}
|
||||
}
|
||||
export type ImageReference = import('mdast').ImageReference
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function imageReferencePeek(): string
|
||||
export {}
|
||||
65
node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
generated
vendored
Normal file
65
node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @typedef {import('mdast').ImageReference} ImageReference
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
imageReference.peek = imageReferencePeek
|
||||
|
||||
/**
|
||||
* @param {ImageReference} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function imageReference(node, _, state, info) {
|
||||
const type = node.referenceType
|
||||
const exit = state.enter('imageReference')
|
||||
let subexit = state.enter('label')
|
||||
const tracker = state.createTracker(info)
|
||||
let value = tracker.move('![')
|
||||
const alt = state.safe(node.alt, {
|
||||
before: value,
|
||||
after: ']',
|
||||
...tracker.current()
|
||||
})
|
||||
value += tracker.move(alt + '][')
|
||||
|
||||
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' || !alt || alt !== 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 imageReferencePeek() {
|
||||
return '!'
|
||||
}
|
||||
25
node_modules/mdast-util-to-markdown/lib/handle/image.d.ts
generated
vendored
Normal file
25
node_modules/mdast-util-to-markdown/lib/handle/image.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @param {Image} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function image(
|
||||
node: Image,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export namespace image {
|
||||
export {imagePeek as peek}
|
||||
}
|
||||
export type Image = import('mdast').Image
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function imagePeek(): string
|
||||
export {}
|
||||
84
node_modules/mdast-util-to-markdown/lib/handle/image.js
generated
vendored
Normal file
84
node_modules/mdast-util-to-markdown/lib/handle/image.js
generated
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Image} Image
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {checkQuote} from '../util/check-quote.js'
|
||||
|
||||
image.peek = imagePeek
|
||||
|
||||
/**
|
||||
* @param {Image} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function image(node, _, state, info) {
|
||||
const quote = checkQuote(state)
|
||||
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
||||
const exit = state.enter('image')
|
||||
let subexit = state.enter('label')
|
||||
const tracker = state.createTracker(info)
|
||||
let value = tracker.move('![')
|
||||
value += tracker.move(
|
||||
state.safe(node.alt, {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
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function imagePeek() {
|
||||
return '!'
|
||||
}
|
||||
41
node_modules/mdast-util-to-markdown/lib/handle/index.d.ts
generated
vendored
Normal file
41
node_modules/mdast-util-to-markdown/lib/handle/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
export namespace handle {
|
||||
export {blockquote}
|
||||
export {hardBreak as break}
|
||||
export {code}
|
||||
export {definition}
|
||||
export {emphasis}
|
||||
export {hardBreak}
|
||||
export {heading}
|
||||
export {html}
|
||||
export {image}
|
||||
export {imageReference}
|
||||
export {inlineCode}
|
||||
export {link}
|
||||
export {linkReference}
|
||||
export {list}
|
||||
export {listItem}
|
||||
export {paragraph}
|
||||
export {root}
|
||||
export {strong}
|
||||
export {text}
|
||||
export {thematicBreak}
|
||||
}
|
||||
import {blockquote} from './blockquote.js'
|
||||
import {hardBreak} from './break.js'
|
||||
import {code} from './code.js'
|
||||
import {definition} from './definition.js'
|
||||
import {emphasis} from './emphasis.js'
|
||||
import {heading} from './heading.js'
|
||||
import {html} from './html.js'
|
||||
import {image} from './image.js'
|
||||
import {imageReference} from './image-reference.js'
|
||||
import {inlineCode} from './inline-code.js'
|
||||
import {link} from './link.js'
|
||||
import {linkReference} from './link-reference.js'
|
||||
import {list} from './list.js'
|
||||
import {listItem} from './list-item.js'
|
||||
import {paragraph} from './paragraph.js'
|
||||
import {root} from './root.js'
|
||||
import {strong} from './strong.js'
|
||||
import {text} from './text.js'
|
||||
import {thematicBreak} from './thematic-break.js'
|
||||
45
node_modules/mdast-util-to-markdown/lib/handle/index.js
generated
vendored
Normal file
45
node_modules/mdast-util-to-markdown/lib/handle/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import {blockquote} from './blockquote.js'
|
||||
import {hardBreak} from './break.js'
|
||||
import {code} from './code.js'
|
||||
import {definition} from './definition.js'
|
||||
import {emphasis} from './emphasis.js'
|
||||
import {heading} from './heading.js'
|
||||
import {html} from './html.js'
|
||||
import {image} from './image.js'
|
||||
import {imageReference} from './image-reference.js'
|
||||
import {inlineCode} from './inline-code.js'
|
||||
import {link} from './link.js'
|
||||
import {linkReference} from './link-reference.js'
|
||||
import {list} from './list.js'
|
||||
import {listItem} from './list-item.js'
|
||||
import {paragraph} from './paragraph.js'
|
||||
import {root} from './root.js'
|
||||
import {strong} from './strong.js'
|
||||
import {text} from './text.js'
|
||||
import {thematicBreak} from './thematic-break.js'
|
||||
|
||||
/**
|
||||
* Default (CommonMark) handlers.
|
||||
*/
|
||||
export const handle = {
|
||||
blockquote,
|
||||
break: hardBreak,
|
||||
code,
|
||||
definition,
|
||||
emphasis,
|
||||
hardBreak,
|
||||
heading,
|
||||
html,
|
||||
image,
|
||||
imageReference,
|
||||
inlineCode,
|
||||
link,
|
||||
linkReference,
|
||||
list,
|
||||
listItem,
|
||||
paragraph,
|
||||
root,
|
||||
strong,
|
||||
text,
|
||||
thematicBreak
|
||||
}
|
||||
22
node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts
generated
vendored
Normal file
22
node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* @param {InlineCode} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
export function inlineCode(
|
||||
node: InlineCode,
|
||||
_: Parent | undefined,
|
||||
state: State
|
||||
): string
|
||||
export namespace inlineCode {
|
||||
export {inlineCodePeek as peek}
|
||||
}
|
||||
export type InlineCode = import('mdast').InlineCode
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function inlineCodePeek(): string
|
||||
export {}
|
||||
79
node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
generated
vendored
Normal file
79
node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* @typedef {import('mdast').InlineCode} InlineCode
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
*/
|
||||
|
||||
import {patternCompile} from '../util/pattern-compile.js'
|
||||
|
||||
inlineCode.peek = inlineCodePeek
|
||||
|
||||
/**
|
||||
* @param {InlineCode} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
export function inlineCode(node, _, state) {
|
||||
let value = node.value || ''
|
||||
let sequence = '`'
|
||||
let index = -1
|
||||
|
||||
// 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 don’t 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) && /[ \r\n]$/.test(value)) || /^`|`$/.test(value))
|
||||
) {
|
||||
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 can’t 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 < state.unsafe.length) {
|
||||
const pattern = state.unsafe[index]
|
||||
const expression = patternCompile(pattern)
|
||||
/** @type {RegExpExecArray | null} */
|
||||
let match
|
||||
|
||||
// Only look for `atBreak`s.
|
||||
// Btw: note that `atBreak` patterns will always start the regex at LF or
|
||||
// CR.
|
||||
if (!pattern.atBreak) continue
|
||||
|
||||
while ((match = expression.exec(value))) {
|
||||
let 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
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function inlineCodePeek() {
|
||||
return '`'
|
||||
}
|
||||
25
node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts
generated
vendored
Normal file
25
node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @param {LinkReference} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function linkReference(
|
||||
node: LinkReference,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export namespace linkReference {
|
||||
export {linkReferencePeek as peek}
|
||||
}
|
||||
export type LinkReference = import('mdast').LinkReference
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function linkReferencePeek(): string
|
||||
export {}
|
||||
65
node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
generated
vendored
Normal file
65
node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @typedef {import('mdast').LinkReference} LinkReference
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
linkReference.peek = linkReferencePeek
|
||||
|
||||
/**
|
||||
* @param {LinkReference} node
|
||||
* @param {Parent | 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 '['
|
||||
}
|
||||
33
node_modules/mdast-util-to-markdown/lib/handle/link.d.ts
generated
vendored
Normal file
33
node_modules/mdast-util-to-markdown/lib/handle/link.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* @param {Link} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function link(
|
||||
node: Link,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export namespace link {
|
||||
export {linkPeek as peek}
|
||||
}
|
||||
export type Link = import('mdast').Link
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
export type Exit = import('../types.js').Exit
|
||||
/**
|
||||
* @param {Link} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function linkPeek(
|
||||
node: Link,
|
||||
_: Parent | undefined,
|
||||
state: State
|
||||
): string
|
||||
export {}
|
||||
116
node_modules/mdast-util-to-markdown/lib/handle/link.js
generated
vendored
Normal file
116
node_modules/mdast-util-to-markdown/lib/handle/link.js
generated
vendored
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Link} Link
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
* @typedef {import('../types.js').Exit} Exit
|
||||
*/
|
||||
|
||||
import {checkQuote} from '../util/check-quote.js'
|
||||
import {formatLinkAsAutolink} from '../util/format-link-as-autolink.js'
|
||||
|
||||
link.peek = linkPeek
|
||||
|
||||
/**
|
||||
* @param {Link} node
|
||||
* @param {Parent | 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 {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
function linkPeek(node, _, state) {
|
||||
return formatLinkAsAutolink(node, state) ? '<' : '['
|
||||
}
|
||||
18
node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts
generated
vendored
Normal file
18
node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* @param {ListItem} node
|
||||
* @param {Parent | undefined} parent
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function listItem(
|
||||
node: ListItem,
|
||||
parent: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type ListItem = import('mdast').ListItem
|
||||
export type Map = import('../types.js').Map
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
65
node_modules/mdast-util-to-markdown/lib/handle/list-item.js
generated
vendored
Normal file
65
node_modules/mdast-util-to-markdown/lib/handle/list-item.js
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @typedef {import('mdast').ListItem} ListItem
|
||||
* @typedef {import('../types.js').Map} Map
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {checkBullet} from '../util/check-bullet.js'
|
||||
import {checkListItemIndent} from '../util/check-list-item-indent.js'
|
||||
|
||||
/**
|
||||
* @param {ListItem} node
|
||||
* @param {Parent | undefined} parent
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function listItem(node, parent, state, info) {
|
||||
const listItemIndent = checkListItemIndent(state)
|
||||
let bullet = state.bulletCurrent || checkBullet(state)
|
||||
|
||||
// Add the marker value for ordered lists.
|
||||
if (parent && parent.type === 'list' && parent.ordered) {
|
||||
bullet =
|
||||
(typeof parent.start === 'number' && parent.start > -1
|
||||
? parent.start
|
||||
: 1) +
|
||||
(state.options.incrementListMarker === false
|
||||
? 0
|
||||
: parent.children.indexOf(node)) +
|
||||
bullet
|
||||
}
|
||||
|
||||
let size = bullet.length + 1
|
||||
|
||||
if (
|
||||
listItemIndent === 'tab' ||
|
||||
(listItemIndent === 'mixed' &&
|
||||
((parent && parent.type === 'list' && parent.spread) || node.spread))
|
||||
) {
|
||||
size = Math.ceil(size / 4) * 4
|
||||
}
|
||||
|
||||
const tracker = state.createTracker(info)
|
||||
tracker.move(bullet + ' '.repeat(size - bullet.length))
|
||||
tracker.shift(size)
|
||||
const exit = state.enter('listItem')
|
||||
const value = state.indentLines(
|
||||
state.containerFlow(node, tracker.current()),
|
||||
map
|
||||
)
|
||||
exit()
|
||||
|
||||
return value
|
||||
|
||||
/** @type {Map} */
|
||||
function map(line, index, blank) {
|
||||
if (index) {
|
||||
return (blank ? '' : ' '.repeat(size)) + line
|
||||
}
|
||||
|
||||
return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line
|
||||
}
|
||||
}
|
||||
17
node_modules/mdast-util-to-markdown/lib/handle/list.d.ts
generated
vendored
Normal file
17
node_modules/mdast-util-to-markdown/lib/handle/list.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @param {List} node
|
||||
* @param {Parent | undefined} parent
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function list(
|
||||
node: List,
|
||||
parent: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type List = import('mdast').List
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
113
node_modules/mdast-util-to-markdown/lib/handle/list.js
generated
vendored
Normal file
113
node_modules/mdast-util-to-markdown/lib/handle/list.js
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
* @typedef {import('mdast').List} List
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {checkBullet} from '../util/check-bullet.js'
|
||||
import {checkBulletOther} from '../util/check-bullet-other.js'
|
||||
import {checkBulletOrdered} from '../util/check-bullet-ordered.js'
|
||||
import {checkBulletOrderedOther} from '../util/check-bullet-ordered-other.js'
|
||||
import {checkRule} from '../util/check-rule.js'
|
||||
|
||||
/**
|
||||
* @param {List} node
|
||||
* @param {Parent | 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
|
||||
? checkBulletOrderedOther(state)
|
||||
: checkBulletOther(state)
|
||||
const bulletLastUsed = state.bulletLastUsed
|
||||
let useDifferentMarker = false
|
||||
|
||||
if (
|
||||
parent &&
|
||||
// Explicit `other` set.
|
||||
(node.ordered
|
||||
? state.options.bulletOrderedOther
|
||||
: state.options.bulletOther) &&
|
||||
bulletLastUsed &&
|
||||
bullet === bulletLastUsed
|
||||
) {
|
||||
useDifferentMarker = true
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
23
node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts
generated
vendored
Normal file
23
node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Paragraph} Paragraph
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
/**
|
||||
* @param {Paragraph} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function paragraph(
|
||||
node: Paragraph,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Paragraph = import('mdast').Paragraph
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
22
node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
generated
vendored
Normal file
22
node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Paragraph} Paragraph
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Paragraph} node
|
||||
* @param {Parent | 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
|
||||
}
|
||||
17
node_modules/mdast-util-to-markdown/lib/handle/root.d.ts
generated
vendored
Normal file
17
node_modules/mdast-util-to-markdown/lib/handle/root.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @param {Root} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function root(
|
||||
node: Root,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Root = import('mdast').Root
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
23
node_modules/mdast-util-to-markdown/lib/handle/root.js
generated
vendored
Normal file
23
node_modules/mdast-util-to-markdown/lib/handle/root.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Root} Root
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {phrasing} from 'mdast-util-phrasing'
|
||||
|
||||
/**
|
||||
* @param {Root} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function root(node, _, state, info) {
|
||||
// Note: `html` nodes are ambiguous.
|
||||
const hasPhrasing = node.children.some((d) => phrasing(d))
|
||||
const fn = hasPhrasing ? state.containerPhrasing : state.containerFlow
|
||||
// @ts-expect-error: `root`s are supposed to have one type of content
|
||||
return fn.call(state, node, info)
|
||||
}
|
||||
32
node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts
generated
vendored
Normal file
32
node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* @param {Strong} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function strong(
|
||||
node: Strong,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export namespace strong {
|
||||
export {strongPeek as peek}
|
||||
}
|
||||
export type Strong = import('mdast').Strong
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
/**
|
||||
* @param {Strong} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function strongPeek(
|
||||
_: Strong,
|
||||
_1: Parent | undefined,
|
||||
state: State
|
||||
): string
|
||||
export {}
|
||||
48
node_modules/mdast-util-to-markdown/lib/handle/strong.js
generated
vendored
Normal file
48
node_modules/mdast-util-to-markdown/lib/handle/strong.js
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Strong} Strong
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
import {checkStrong} from '../util/check-strong.js'
|
||||
|
||||
strong.peek = strongPeek
|
||||
|
||||
// To do: there are cases where emphasis cannot “form” depending on the
|
||||
// previous or next character of sequences.
|
||||
// There’s no way around that though, except for injecting zero-width stuff.
|
||||
// Do we need to safeguard against that?
|
||||
/**
|
||||
* @param {Strong} node
|
||||
* @param {Parent | 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)
|
||||
let value = tracker.move(marker + marker)
|
||||
value += tracker.move(
|
||||
state.containerPhrasing(node, {
|
||||
before: value,
|
||||
after: marker,
|
||||
...tracker.current()
|
||||
})
|
||||
)
|
||||
value += tracker.move(marker + marker)
|
||||
exit()
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Strong} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
function strongPeek(_, _1, state) {
|
||||
return state.options.strong || '*'
|
||||
}
|
||||
23
node_modules/mdast-util-to-markdown/lib/handle/text.d.ts
generated
vendored
Normal file
23
node_modules/mdast-util-to-markdown/lib/handle/text.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Text} Text
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
/**
|
||||
* @param {Text} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function text(
|
||||
node: Text,
|
||||
_: Parent | undefined,
|
||||
state: State,
|
||||
info: Info
|
||||
): string
|
||||
export type Text = import('mdast').Text
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
export type Info = import('../types.js').Info
|
||||
17
node_modules/mdast-util-to-markdown/lib/handle/text.js
generated
vendored
Normal file
17
node_modules/mdast-util-to-markdown/lib/handle/text.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Text} Text
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
* @typedef {import('../types.js').Info} Info
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Text} node
|
||||
* @param {Parent | undefined} _
|
||||
* @param {State} state
|
||||
* @param {Info} info
|
||||
* @returns {string}
|
||||
*/
|
||||
export function text(node, _, state, info) {
|
||||
return state.safe(node.value, info)
|
||||
}
|
||||
14
node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts
generated
vendored
Normal file
14
node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* @param {ThematicBreak} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
export function thematicBreak(
|
||||
_: ThematicBreak,
|
||||
_1: Parent | undefined,
|
||||
state: State
|
||||
): string
|
||||
export type ThematicBreak = import('mdast').ThematicBreak
|
||||
export type Parent = import('../types.js').Parent
|
||||
export type State = import('../types.js').State
|
||||
22
node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
generated
vendored
Normal file
22
node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* @typedef {import('mdast').ThematicBreak} ThematicBreak
|
||||
* @typedef {import('../types.js').Parent} Parent
|
||||
* @typedef {import('../types.js').State} State
|
||||
*/
|
||||
|
||||
import {checkRuleRepetition} from '../util/check-rule-repetition.js'
|
||||
import {checkRule} from '../util/check-rule.js'
|
||||
|
||||
/**
|
||||
* @param {ThematicBreak} _
|
||||
* @param {Parent | undefined} _1
|
||||
* @param {State} state
|
||||
* @returns {string}
|
||||
*/
|
||||
export function thematicBreak(_, _1, state) {
|
||||
const value = (
|
||||
checkRule(state) + (state.options.ruleSpaces ? ' ' : '')
|
||||
).repeat(checkRuleRepetition(state))
|
||||
|
||||
return state.options.ruleSpaces ? value.slice(0, -1) : value
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue