Spaces:
Paused
Paused
Include updated package-lock.json (part 3)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/mdast-util-to-markdown/lib/handle/image-reference.js +63 -0
- node_modules/mdast-util-to-markdown/lib/handle/image.d.ts +21 -0
- node_modules/mdast-util-to-markdown/lib/handle/image.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/image.js +82 -0
- node_modules/mdast-util-to-markdown/lib/handle/index.d.ts +42 -0
- node_modules/mdast-util-to-markdown/lib/handle/index.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/index.js +45 -0
- node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts +19 -0
- node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/inline-code.js +76 -0
- node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts +21 -0
- node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/link-reference.js +63 -0
- node_modules/mdast-util-to-markdown/lib/handle/link.d.ts +24 -0
- node_modules/mdast-util-to-markdown/lib/handle/link.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/link.js +114 -0
- node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts +13 -0
- node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/list-item.js +62 -0
- node_modules/mdast-util-to-markdown/lib/handle/list.d.ts +13 -0
- node_modules/mdast-util-to-markdown/lib/handle/list.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/list.js +100 -0
- node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts +17 -0
- node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/paragraph.js +20 -0
- node_modules/mdast-util-to-markdown/lib/handle/root.d.ts +13 -0
- node_modules/mdast-util-to-markdown/lib/handle/root.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/root.js +23 -0
- node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts +24 -0
- node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/strong.js +69 -0
- node_modules/mdast-util-to-markdown/lib/handle/text.d.ts +17 -0
- node_modules/mdast-util-to-markdown/lib/handle/text.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/text.js +15 -0
- node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts +11 -0
- node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js +21 -0
- node_modules/mdast-util-to-markdown/lib/index.d.ts +14 -0
- node_modules/mdast-util-to-markdown/lib/index.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/index.js +187 -0
- node_modules/mdast-util-to-markdown/lib/join.d.ts +4 -0
- node_modules/mdast-util-to-markdown/lib/join.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/join.js +39 -0
- node_modules/mdast-util-to-markdown/lib/types.d.ts +965 -0
- node_modules/mdast-util-to-markdown/lib/types.js +2 -0
- node_modules/mdast-util-to-markdown/lib/unsafe.d.ts +4 -0
- node_modules/mdast-util-to-markdown/lib/unsafe.d.ts.map +1 -0
- node_modules/mdast-util-to-markdown/lib/unsafe.js +146 -0
- node_modules/mdast-util-to-markdown/lib/util/association.d.ts +2 -0
- node_modules/mdast-util-to-markdown/lib/util/association.d.ts.map +1 -0
node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {ImageReference, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
imageReference.peek = imageReferencePeek
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @param {ImageReference} node
|
| 10 |
+
* @param {Parents | undefined} _
|
| 11 |
+
* @param {State} state
|
| 12 |
+
* @param {Info} info
|
| 13 |
+
* @returns {string}
|
| 14 |
+
*/
|
| 15 |
+
export function imageReference(node, _, state, info) {
|
| 16 |
+
const type = node.referenceType
|
| 17 |
+
const exit = state.enter('imageReference')
|
| 18 |
+
let subexit = state.enter('label')
|
| 19 |
+
const tracker = state.createTracker(info)
|
| 20 |
+
let value = tracker.move('![')
|
| 21 |
+
const alt = state.safe(node.alt, {
|
| 22 |
+
before: value,
|
| 23 |
+
after: ']',
|
| 24 |
+
...tracker.current()
|
| 25 |
+
})
|
| 26 |
+
value += tracker.move(alt + '][')
|
| 27 |
+
|
| 28 |
+
subexit()
|
| 29 |
+
// Hide the fact that we’re in phrasing, because escapes don’t work.
|
| 30 |
+
const stack = state.stack
|
| 31 |
+
state.stack = []
|
| 32 |
+
subexit = state.enter('reference')
|
| 33 |
+
// Note: for proper tracking, we should reset the output positions when we end
|
| 34 |
+
// up making a `shortcut` reference, because then there is no brace output.
|
| 35 |
+
// Practically, in that case, there is no content, so it doesn’t matter that
|
| 36 |
+
// we’ve tracked one too many characters.
|
| 37 |
+
const reference = state.safe(state.associationId(node), {
|
| 38 |
+
before: value,
|
| 39 |
+
after: ']',
|
| 40 |
+
...tracker.current()
|
| 41 |
+
})
|
| 42 |
+
subexit()
|
| 43 |
+
state.stack = stack
|
| 44 |
+
exit()
|
| 45 |
+
|
| 46 |
+
if (type === 'full' || !alt || alt !== reference) {
|
| 47 |
+
value += tracker.move(reference + ']')
|
| 48 |
+
} else if (type === 'shortcut') {
|
| 49 |
+
// Remove the unwanted `[`.
|
| 50 |
+
value = value.slice(0, -1)
|
| 51 |
+
} else {
|
| 52 |
+
value += tracker.move(']')
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
return value
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* @returns {string}
|
| 60 |
+
*/
|
| 61 |
+
function imageReferencePeek() {
|
| 62 |
+
return '!'
|
| 63 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/image.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {Image} node
|
| 3 |
+
* @param {Parents | undefined} _
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @param {Info} info
|
| 6 |
+
* @returns {string}
|
| 7 |
+
*/
|
| 8 |
+
export function image(node: Image, _: Parents | undefined, state: State, info: Info): string;
|
| 9 |
+
export namespace image {
|
| 10 |
+
export { imagePeek as peek };
|
| 11 |
+
}
|
| 12 |
+
import type { Image } from 'mdast';
|
| 13 |
+
import type { Parents } from 'mdast';
|
| 14 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 15 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 16 |
+
/**
|
| 17 |
+
* @returns {string}
|
| 18 |
+
*/
|
| 19 |
+
declare function imagePeek(): string;
|
| 20 |
+
export {};
|
| 21 |
+
//# sourceMappingURL=image.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/image.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["image.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,4BANW,KAAK,KACL,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CA4DlB;;;;2BAxEgC,OAAO;6BAAP,OAAO;2BADV,wBAAwB;0BAAxB,wBAAwB;AA2EtD;;GAEG;AACH,8BAFa,MAAM,CAIlB"}
|
node_modules/mdast-util-to-markdown/lib/handle/image.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Image, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
import {checkQuote} from '../util/check-quote.js'
|
| 7 |
+
|
| 8 |
+
image.peek = imagePeek
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* @param {Image} node
|
| 12 |
+
* @param {Parents | undefined} _
|
| 13 |
+
* @param {State} state
|
| 14 |
+
* @param {Info} info
|
| 15 |
+
* @returns {string}
|
| 16 |
+
*/
|
| 17 |
+
export function image(node, _, state, info) {
|
| 18 |
+
const quote = checkQuote(state)
|
| 19 |
+
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
| 20 |
+
const exit = state.enter('image')
|
| 21 |
+
let subexit = state.enter('label')
|
| 22 |
+
const tracker = state.createTracker(info)
|
| 23 |
+
let value = tracker.move('![')
|
| 24 |
+
value += tracker.move(
|
| 25 |
+
state.safe(node.alt, {before: value, after: ']', ...tracker.current()})
|
| 26 |
+
)
|
| 27 |
+
value += tracker.move('](')
|
| 28 |
+
|
| 29 |
+
subexit()
|
| 30 |
+
|
| 31 |
+
if (
|
| 32 |
+
// If there’s no url but there is a title…
|
| 33 |
+
(!node.url && node.title) ||
|
| 34 |
+
// If there are control characters or whitespace.
|
| 35 |
+
/[\0- \u007F]/.test(node.url)
|
| 36 |
+
) {
|
| 37 |
+
subexit = state.enter('destinationLiteral')
|
| 38 |
+
value += tracker.move('<')
|
| 39 |
+
value += tracker.move(
|
| 40 |
+
state.safe(node.url, {before: value, after: '>', ...tracker.current()})
|
| 41 |
+
)
|
| 42 |
+
value += tracker.move('>')
|
| 43 |
+
} else {
|
| 44 |
+
// No whitespace, raw is prettier.
|
| 45 |
+
subexit = state.enter('destinationRaw')
|
| 46 |
+
value += tracker.move(
|
| 47 |
+
state.safe(node.url, {
|
| 48 |
+
before: value,
|
| 49 |
+
after: node.title ? ' ' : ')',
|
| 50 |
+
...tracker.current()
|
| 51 |
+
})
|
| 52 |
+
)
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
subexit()
|
| 56 |
+
|
| 57 |
+
if (node.title) {
|
| 58 |
+
subexit = state.enter(`title${suffix}`)
|
| 59 |
+
value += tracker.move(' ' + quote)
|
| 60 |
+
value += tracker.move(
|
| 61 |
+
state.safe(node.title, {
|
| 62 |
+
before: value,
|
| 63 |
+
after: quote,
|
| 64 |
+
...tracker.current()
|
| 65 |
+
})
|
| 66 |
+
)
|
| 67 |
+
value += tracker.move(quote)
|
| 68 |
+
subexit()
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
value += tracker.move(')')
|
| 72 |
+
exit()
|
| 73 |
+
|
| 74 |
+
return value
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* @returns {string}
|
| 79 |
+
*/
|
| 80 |
+
function imagePeek() {
|
| 81 |
+
return '!'
|
| 82 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export namespace handle {
|
| 2 |
+
export { blockquote };
|
| 3 |
+
export { hardBreak as break };
|
| 4 |
+
export { code };
|
| 5 |
+
export { definition };
|
| 6 |
+
export { emphasis };
|
| 7 |
+
export { hardBreak };
|
| 8 |
+
export { heading };
|
| 9 |
+
export { html };
|
| 10 |
+
export { image };
|
| 11 |
+
export { imageReference };
|
| 12 |
+
export { inlineCode };
|
| 13 |
+
export { link };
|
| 14 |
+
export { linkReference };
|
| 15 |
+
export { list };
|
| 16 |
+
export { listItem };
|
| 17 |
+
export { paragraph };
|
| 18 |
+
export { root };
|
| 19 |
+
export { strong };
|
| 20 |
+
export { text };
|
| 21 |
+
export { thematicBreak };
|
| 22 |
+
}
|
| 23 |
+
import { blockquote } from './blockquote.js';
|
| 24 |
+
import { hardBreak } from './break.js';
|
| 25 |
+
import { code } from './code.js';
|
| 26 |
+
import { definition } from './definition.js';
|
| 27 |
+
import { emphasis } from './emphasis.js';
|
| 28 |
+
import { heading } from './heading.js';
|
| 29 |
+
import { html } from './html.js';
|
| 30 |
+
import { image } from './image.js';
|
| 31 |
+
import { imageReference } from './image-reference.js';
|
| 32 |
+
import { inlineCode } from './inline-code.js';
|
| 33 |
+
import { link } from './link.js';
|
| 34 |
+
import { linkReference } from './link-reference.js';
|
| 35 |
+
import { list } from './list.js';
|
| 36 |
+
import { listItem } from './list-item.js';
|
| 37 |
+
import { paragraph } from './paragraph.js';
|
| 38 |
+
import { root } from './root.js';
|
| 39 |
+
import { strong } from './strong.js';
|
| 40 |
+
import { text } from './text.js';
|
| 41 |
+
import { thematicBreak } from './thematic-break.js';
|
| 42 |
+
//# sourceMappingURL=index.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"}
|
node_modules/mdast-util-to-markdown/lib/handle/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {blockquote} from './blockquote.js'
|
| 2 |
+
import {hardBreak} from './break.js'
|
| 3 |
+
import {code} from './code.js'
|
| 4 |
+
import {definition} from './definition.js'
|
| 5 |
+
import {emphasis} from './emphasis.js'
|
| 6 |
+
import {heading} from './heading.js'
|
| 7 |
+
import {html} from './html.js'
|
| 8 |
+
import {image} from './image.js'
|
| 9 |
+
import {imageReference} from './image-reference.js'
|
| 10 |
+
import {inlineCode} from './inline-code.js'
|
| 11 |
+
import {link} from './link.js'
|
| 12 |
+
import {linkReference} from './link-reference.js'
|
| 13 |
+
import {list} from './list.js'
|
| 14 |
+
import {listItem} from './list-item.js'
|
| 15 |
+
import {paragraph} from './paragraph.js'
|
| 16 |
+
import {root} from './root.js'
|
| 17 |
+
import {strong} from './strong.js'
|
| 18 |
+
import {text} from './text.js'
|
| 19 |
+
import {thematicBreak} from './thematic-break.js'
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Default (CommonMark) handlers.
|
| 23 |
+
*/
|
| 24 |
+
export const handle = {
|
| 25 |
+
blockquote,
|
| 26 |
+
break: hardBreak,
|
| 27 |
+
code,
|
| 28 |
+
definition,
|
| 29 |
+
emphasis,
|
| 30 |
+
hardBreak,
|
| 31 |
+
heading,
|
| 32 |
+
html,
|
| 33 |
+
image,
|
| 34 |
+
imageReference,
|
| 35 |
+
inlineCode,
|
| 36 |
+
link,
|
| 37 |
+
linkReference,
|
| 38 |
+
list,
|
| 39 |
+
listItem,
|
| 40 |
+
paragraph,
|
| 41 |
+
root,
|
| 42 |
+
strong,
|
| 43 |
+
text,
|
| 44 |
+
thematicBreak
|
| 45 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {InlineCode} node
|
| 3 |
+
* @param {Parents | undefined} _
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @returns {string}
|
| 6 |
+
*/
|
| 7 |
+
export function inlineCode(node: InlineCode, _: Parents | undefined, state: State): string;
|
| 8 |
+
export namespace inlineCode {
|
| 9 |
+
export { inlineCodePeek as peek };
|
| 10 |
+
}
|
| 11 |
+
import type { InlineCode } from 'mdast';
|
| 12 |
+
import type { Parents } from 'mdast';
|
| 13 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 14 |
+
/**
|
| 15 |
+
* @returns {string}
|
| 16 |
+
*/
|
| 17 |
+
declare function inlineCodePeek(): string;
|
| 18 |
+
export {};
|
| 19 |
+
//# sourceMappingURL=inline-code.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"inline-code.d.ts","sourceRoot":"","sources":["inline-code.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,iCALW,UAAU,KACV,OAAO,GAAG,SAAS,SACnB,KAAK,GACH,MAAM,CAyDlB;;;;gCAlEqC,OAAO;6BAAP,OAAO;2BADrB,wBAAwB;AAqEhD;;GAEG;AACH,mCAFa,MAAM,CAIlB"}
|
node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {InlineCode, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
inlineCode.peek = inlineCodePeek
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @param {InlineCode} node
|
| 10 |
+
* @param {Parents | undefined} _
|
| 11 |
+
* @param {State} state
|
| 12 |
+
* @returns {string}
|
| 13 |
+
*/
|
| 14 |
+
export function inlineCode(node, _, state) {
|
| 15 |
+
let value = node.value || ''
|
| 16 |
+
let sequence = '`'
|
| 17 |
+
let index = -1
|
| 18 |
+
|
| 19 |
+
// If there is a single grave accent on its own in the code, use a fence of
|
| 20 |
+
// two.
|
| 21 |
+
// If there are two in a row, use one.
|
| 22 |
+
while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) {
|
| 23 |
+
sequence += '`'
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
// If this is not just spaces or eols (tabs don’t count), and either the
|
| 27 |
+
// first or last character are a space, eol, or tick, then pad with spaces.
|
| 28 |
+
if (
|
| 29 |
+
/[^ \r\n]/.test(value) &&
|
| 30 |
+
((/^[ \r\n]/.test(value) && /[ \r\n]$/.test(value)) || /^`|`$/.test(value))
|
| 31 |
+
) {
|
| 32 |
+
value = ' ' + value + ' '
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// We have a potential problem: certain characters after eols could result in
|
| 36 |
+
// blocks being seen.
|
| 37 |
+
// For example, if someone injected the string `'\n# b'`, then that would
|
| 38 |
+
// result in an ATX heading.
|
| 39 |
+
// We can’t escape characters in `inlineCode`, but because eols are
|
| 40 |
+
// transformed to spaces when going from markdown to HTML anyway, we can swap
|
| 41 |
+
// them out.
|
| 42 |
+
while (++index < state.unsafe.length) {
|
| 43 |
+
const pattern = state.unsafe[index]
|
| 44 |
+
const expression = state.compilePattern(pattern)
|
| 45 |
+
/** @type {RegExpExecArray | null} */
|
| 46 |
+
let match
|
| 47 |
+
|
| 48 |
+
// Only look for `atBreak`s.
|
| 49 |
+
// Btw: note that `atBreak` patterns will always start the regex at LF or
|
| 50 |
+
// CR.
|
| 51 |
+
if (!pattern.atBreak) continue
|
| 52 |
+
|
| 53 |
+
while ((match = expression.exec(value))) {
|
| 54 |
+
let position = match.index
|
| 55 |
+
|
| 56 |
+
// Support CRLF (patterns only look for one of the characters).
|
| 57 |
+
if (
|
| 58 |
+
value.charCodeAt(position) === 10 /* `\n` */ &&
|
| 59 |
+
value.charCodeAt(position - 1) === 13 /* `\r` */
|
| 60 |
+
) {
|
| 61 |
+
position--
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
value = value.slice(0, position) + ' ' + value.slice(match.index + 1)
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
return sequence + value + sequence
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* @returns {string}
|
| 73 |
+
*/
|
| 74 |
+
function inlineCodePeek() {
|
| 75 |
+
return '`'
|
| 76 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {LinkReference} node
|
| 3 |
+
* @param {Parents | undefined} _
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @param {Info} info
|
| 6 |
+
* @returns {string}
|
| 7 |
+
*/
|
| 8 |
+
export function linkReference(node: LinkReference, _: Parents | undefined, state: State, info: Info): string;
|
| 9 |
+
export namespace linkReference {
|
| 10 |
+
export { linkReferencePeek as peek };
|
| 11 |
+
}
|
| 12 |
+
import type { LinkReference } from 'mdast';
|
| 13 |
+
import type { Parents } from 'mdast';
|
| 14 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 15 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 16 |
+
/**
|
| 17 |
+
* @returns {string}
|
| 18 |
+
*/
|
| 19 |
+
declare function linkReferencePeek(): string;
|
| 20 |
+
export {};
|
| 21 |
+
//# sourceMappingURL=link-reference.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"link-reference.d.ts","sourceRoot":"","sources":["link-reference.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,oCANW,aAAa,KACb,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CA2ClB;;;;mCArDwC,OAAO;6BAAP,OAAO;2BADlB,wBAAwB;0BAAxB,wBAAwB;AAwDtD;;GAEG;AACH,sCAFa,MAAM,CAIlB"}
|
node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {LinkReference, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
linkReference.peek = linkReferencePeek
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @param {LinkReference} node
|
| 10 |
+
* @param {Parents | undefined} _
|
| 11 |
+
* @param {State} state
|
| 12 |
+
* @param {Info} info
|
| 13 |
+
* @returns {string}
|
| 14 |
+
*/
|
| 15 |
+
export function linkReference(node, _, state, info) {
|
| 16 |
+
const type = node.referenceType
|
| 17 |
+
const exit = state.enter('linkReference')
|
| 18 |
+
let subexit = state.enter('label')
|
| 19 |
+
const tracker = state.createTracker(info)
|
| 20 |
+
let value = tracker.move('[')
|
| 21 |
+
const text = state.containerPhrasing(node, {
|
| 22 |
+
before: value,
|
| 23 |
+
after: ']',
|
| 24 |
+
...tracker.current()
|
| 25 |
+
})
|
| 26 |
+
value += tracker.move(text + '][')
|
| 27 |
+
|
| 28 |
+
subexit()
|
| 29 |
+
// Hide the fact that we’re in phrasing, because escapes don’t work.
|
| 30 |
+
const stack = state.stack
|
| 31 |
+
state.stack = []
|
| 32 |
+
subexit = state.enter('reference')
|
| 33 |
+
// Note: for proper tracking, we should reset the output positions when we end
|
| 34 |
+
// up making a `shortcut` reference, because then there is no brace output.
|
| 35 |
+
// Practically, in that case, there is no content, so it doesn’t matter that
|
| 36 |
+
// we’ve tracked one too many characters.
|
| 37 |
+
const reference = state.safe(state.associationId(node), {
|
| 38 |
+
before: value,
|
| 39 |
+
after: ']',
|
| 40 |
+
...tracker.current()
|
| 41 |
+
})
|
| 42 |
+
subexit()
|
| 43 |
+
state.stack = stack
|
| 44 |
+
exit()
|
| 45 |
+
|
| 46 |
+
if (type === 'full' || !text || text !== reference) {
|
| 47 |
+
value += tracker.move(reference + ']')
|
| 48 |
+
} else if (type === 'shortcut') {
|
| 49 |
+
// Remove the unwanted `[`.
|
| 50 |
+
value = value.slice(0, -1)
|
| 51 |
+
} else {
|
| 52 |
+
value += tracker.move(']')
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
return value
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* @returns {string}
|
| 60 |
+
*/
|
| 61 |
+
function linkReferencePeek() {
|
| 62 |
+
return '['
|
| 63 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/link.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {Link} node
|
| 3 |
+
* @param {Parents | undefined} _
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @param {Info} info
|
| 6 |
+
* @returns {string}
|
| 7 |
+
*/
|
| 8 |
+
export function link(node: Link, _: Parents | undefined, state: State, info: Info): string;
|
| 9 |
+
export namespace link {
|
| 10 |
+
export { linkPeek as peek };
|
| 11 |
+
}
|
| 12 |
+
import type { Link } from 'mdast';
|
| 13 |
+
import type { Parents } from 'mdast';
|
| 14 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 15 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 16 |
+
/**
|
| 17 |
+
* @param {Link} node
|
| 18 |
+
* @param {Parents | undefined} _
|
| 19 |
+
* @param {State} state
|
| 20 |
+
* @returns {string}
|
| 21 |
+
*/
|
| 22 |
+
declare function linkPeek(node: Link, _: Parents | undefined, state: State): string;
|
| 23 |
+
export {};
|
| 24 |
+
//# sourceMappingURL=link.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/link.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,2BANW,IAAI,KACJ,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CAuFlB;;;;0BArG+B,OAAO;6BAAP,OAAO;2BADT,wBAAwB;0BAAxB,wBAAwB;AAwGtD;;;;;GAKG;AACH,gCALW,IAAI,KACJ,OAAO,GAAG,SAAS,SACnB,KAAK,GACH,MAAM,CAIlB"}
|
node_modules/mdast-util-to-markdown/lib/handle/link.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Link, Parents} from 'mdast'
|
| 4 |
+
* @import {Exit} from '../types.js'
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
import {checkQuote} from '../util/check-quote.js'
|
| 8 |
+
import {formatLinkAsAutolink} from '../util/format-link-as-autolink.js'
|
| 9 |
+
|
| 10 |
+
link.peek = linkPeek
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* @param {Link} node
|
| 14 |
+
* @param {Parents | undefined} _
|
| 15 |
+
* @param {State} state
|
| 16 |
+
* @param {Info} info
|
| 17 |
+
* @returns {string}
|
| 18 |
+
*/
|
| 19 |
+
export function link(node, _, state, info) {
|
| 20 |
+
const quote = checkQuote(state)
|
| 21 |
+
const suffix = quote === '"' ? 'Quote' : 'Apostrophe'
|
| 22 |
+
const tracker = state.createTracker(info)
|
| 23 |
+
/** @type {Exit} */
|
| 24 |
+
let exit
|
| 25 |
+
/** @type {Exit} */
|
| 26 |
+
let subexit
|
| 27 |
+
|
| 28 |
+
if (formatLinkAsAutolink(node, state)) {
|
| 29 |
+
// Hide the fact that we’re in phrasing, because escapes don’t work.
|
| 30 |
+
const stack = state.stack
|
| 31 |
+
state.stack = []
|
| 32 |
+
exit = state.enter('autolink')
|
| 33 |
+
let value = tracker.move('<')
|
| 34 |
+
value += tracker.move(
|
| 35 |
+
state.containerPhrasing(node, {
|
| 36 |
+
before: value,
|
| 37 |
+
after: '>',
|
| 38 |
+
...tracker.current()
|
| 39 |
+
})
|
| 40 |
+
)
|
| 41 |
+
value += tracker.move('>')
|
| 42 |
+
exit()
|
| 43 |
+
state.stack = stack
|
| 44 |
+
return value
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
exit = state.enter('link')
|
| 48 |
+
subexit = state.enter('label')
|
| 49 |
+
let value = tracker.move('[')
|
| 50 |
+
value += tracker.move(
|
| 51 |
+
state.containerPhrasing(node, {
|
| 52 |
+
before: value,
|
| 53 |
+
after: '](',
|
| 54 |
+
...tracker.current()
|
| 55 |
+
})
|
| 56 |
+
)
|
| 57 |
+
value += tracker.move('](')
|
| 58 |
+
subexit()
|
| 59 |
+
|
| 60 |
+
if (
|
| 61 |
+
// If there’s no url but there is a title…
|
| 62 |
+
(!node.url && node.title) ||
|
| 63 |
+
// If there are control characters or whitespace.
|
| 64 |
+
/[\0- \u007F]/.test(node.url)
|
| 65 |
+
) {
|
| 66 |
+
subexit = state.enter('destinationLiteral')
|
| 67 |
+
value += tracker.move('<')
|
| 68 |
+
value += tracker.move(
|
| 69 |
+
state.safe(node.url, {before: value, after: '>', ...tracker.current()})
|
| 70 |
+
)
|
| 71 |
+
value += tracker.move('>')
|
| 72 |
+
} else {
|
| 73 |
+
// No whitespace, raw is prettier.
|
| 74 |
+
subexit = state.enter('destinationRaw')
|
| 75 |
+
value += tracker.move(
|
| 76 |
+
state.safe(node.url, {
|
| 77 |
+
before: value,
|
| 78 |
+
after: node.title ? ' ' : ')',
|
| 79 |
+
...tracker.current()
|
| 80 |
+
})
|
| 81 |
+
)
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
subexit()
|
| 85 |
+
|
| 86 |
+
if (node.title) {
|
| 87 |
+
subexit = state.enter(`title${suffix}`)
|
| 88 |
+
value += tracker.move(' ' + quote)
|
| 89 |
+
value += tracker.move(
|
| 90 |
+
state.safe(node.title, {
|
| 91 |
+
before: value,
|
| 92 |
+
after: quote,
|
| 93 |
+
...tracker.current()
|
| 94 |
+
})
|
| 95 |
+
)
|
| 96 |
+
value += tracker.move(quote)
|
| 97 |
+
subexit()
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
value += tracker.move(')')
|
| 101 |
+
|
| 102 |
+
exit()
|
| 103 |
+
return value
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* @param {Link} node
|
| 108 |
+
* @param {Parents | undefined} _
|
| 109 |
+
* @param {State} state
|
| 110 |
+
* @returns {string}
|
| 111 |
+
*/
|
| 112 |
+
function linkPeek(node, _, state) {
|
| 113 |
+
return formatLinkAsAutolink(node, state) ? '<' : '['
|
| 114 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {ListItem} node
|
| 3 |
+
* @param {Parents | undefined} parent
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @param {Info} info
|
| 6 |
+
* @returns {string}
|
| 7 |
+
*/
|
| 8 |
+
export function listItem(node: ListItem, parent: Parents | undefined, state: State, info: Info): string;
|
| 9 |
+
import type { ListItem } from 'mdast';
|
| 10 |
+
import type { Parents } from 'mdast';
|
| 11 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 12 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 13 |
+
//# sourceMappingURL=list-item.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"}
|
node_modules/mdast-util-to-markdown/lib/handle/list-item.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, Map, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {ListItem, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
import {checkBullet} from '../util/check-bullet.js'
|
| 7 |
+
import {checkListItemIndent} from '../util/check-list-item-indent.js'
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* @param {ListItem} node
|
| 11 |
+
* @param {Parents | undefined} parent
|
| 12 |
+
* @param {State} state
|
| 13 |
+
* @param {Info} info
|
| 14 |
+
* @returns {string}
|
| 15 |
+
*/
|
| 16 |
+
export function listItem(node, parent, state, info) {
|
| 17 |
+
const listItemIndent = checkListItemIndent(state)
|
| 18 |
+
let bullet = state.bulletCurrent || checkBullet(state)
|
| 19 |
+
|
| 20 |
+
// Add the marker value for ordered lists.
|
| 21 |
+
if (parent && parent.type === 'list' && parent.ordered) {
|
| 22 |
+
bullet =
|
| 23 |
+
(typeof parent.start === 'number' && parent.start > -1
|
| 24 |
+
? parent.start
|
| 25 |
+
: 1) +
|
| 26 |
+
(state.options.incrementListMarker === false
|
| 27 |
+
? 0
|
| 28 |
+
: parent.children.indexOf(node)) +
|
| 29 |
+
bullet
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
let size = bullet.length + 1
|
| 33 |
+
|
| 34 |
+
if (
|
| 35 |
+
listItemIndent === 'tab' ||
|
| 36 |
+
(listItemIndent === 'mixed' &&
|
| 37 |
+
((parent && parent.type === 'list' && parent.spread) || node.spread))
|
| 38 |
+
) {
|
| 39 |
+
size = Math.ceil(size / 4) * 4
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
const tracker = state.createTracker(info)
|
| 43 |
+
tracker.move(bullet + ' '.repeat(size - bullet.length))
|
| 44 |
+
tracker.shift(size)
|
| 45 |
+
const exit = state.enter('listItem')
|
| 46 |
+
const value = state.indentLines(
|
| 47 |
+
state.containerFlow(node, tracker.current()),
|
| 48 |
+
map
|
| 49 |
+
)
|
| 50 |
+
exit()
|
| 51 |
+
|
| 52 |
+
return value
|
| 53 |
+
|
| 54 |
+
/** @type {Map} */
|
| 55 |
+
function map(line, index, blank) {
|
| 56 |
+
if (index) {
|
| 57 |
+
return (blank ? '' : ' '.repeat(size)) + line
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line
|
| 61 |
+
}
|
| 62 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/list.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {List} node
|
| 3 |
+
* @param {Parents | undefined} parent
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @param {Info} info
|
| 6 |
+
* @returns {string}
|
| 7 |
+
*/
|
| 8 |
+
export function list(node: List, parent: Parents | undefined, state: State, info: Info): string;
|
| 9 |
+
import type { List } from 'mdast';
|
| 10 |
+
import type { Parents } from 'mdast';
|
| 11 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 12 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 13 |
+
//# sourceMappingURL=list.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/list.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["list.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,2BANW,IAAI,UACJ,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CAoFlB;0BAjG+B,OAAO;6BAAP,OAAO;2BADT,wBAAwB;0BAAxB,wBAAwB"}
|
node_modules/mdast-util-to-markdown/lib/handle/list.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {List, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
import {checkBullet} from '../util/check-bullet.js'
|
| 7 |
+
import {checkBulletOther} from '../util/check-bullet-other.js'
|
| 8 |
+
import {checkBulletOrdered} from '../util/check-bullet-ordered.js'
|
| 9 |
+
import {checkRule} from '../util/check-rule.js'
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* @param {List} node
|
| 13 |
+
* @param {Parents | undefined} parent
|
| 14 |
+
* @param {State} state
|
| 15 |
+
* @param {Info} info
|
| 16 |
+
* @returns {string}
|
| 17 |
+
*/
|
| 18 |
+
export function list(node, parent, state, info) {
|
| 19 |
+
const exit = state.enter('list')
|
| 20 |
+
const bulletCurrent = state.bulletCurrent
|
| 21 |
+
/** @type {string} */
|
| 22 |
+
let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state)
|
| 23 |
+
/** @type {string} */
|
| 24 |
+
const bulletOther = node.ordered
|
| 25 |
+
? bullet === '.'
|
| 26 |
+
? ')'
|
| 27 |
+
: '.'
|
| 28 |
+
: checkBulletOther(state)
|
| 29 |
+
let useDifferentMarker =
|
| 30 |
+
parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false
|
| 31 |
+
|
| 32 |
+
if (!node.ordered) {
|
| 33 |
+
const firstListItem = node.children ? node.children[0] : undefined
|
| 34 |
+
|
| 35 |
+
// If there’s an empty first list item directly in two list items,
|
| 36 |
+
// we have to use a different bullet:
|
| 37 |
+
//
|
| 38 |
+
// ```markdown
|
| 39 |
+
// * - *
|
| 40 |
+
// ```
|
| 41 |
+
//
|
| 42 |
+
// …because otherwise it would become one big thematic break.
|
| 43 |
+
if (
|
| 44 |
+
// Bullet could be used as a thematic break marker:
|
| 45 |
+
(bullet === '*' || bullet === '-') &&
|
| 46 |
+
// Empty first list item:
|
| 47 |
+
firstListItem &&
|
| 48 |
+
(!firstListItem.children || !firstListItem.children[0]) &&
|
| 49 |
+
// Directly in two other list items:
|
| 50 |
+
state.stack[state.stack.length - 1] === 'list' &&
|
| 51 |
+
state.stack[state.stack.length - 2] === 'listItem' &&
|
| 52 |
+
state.stack[state.stack.length - 3] === 'list' &&
|
| 53 |
+
state.stack[state.stack.length - 4] === 'listItem' &&
|
| 54 |
+
// That are each the first child.
|
| 55 |
+
state.indexStack[state.indexStack.length - 1] === 0 &&
|
| 56 |
+
state.indexStack[state.indexStack.length - 2] === 0 &&
|
| 57 |
+
state.indexStack[state.indexStack.length - 3] === 0
|
| 58 |
+
) {
|
| 59 |
+
useDifferentMarker = true
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// If there’s a thematic break at the start of the first list item,
|
| 63 |
+
// we have to use a different bullet:
|
| 64 |
+
//
|
| 65 |
+
// ```markdown
|
| 66 |
+
// * ---
|
| 67 |
+
// ```
|
| 68 |
+
//
|
| 69 |
+
// …because otherwise it would become one big thematic break.
|
| 70 |
+
if (checkRule(state) === bullet && firstListItem) {
|
| 71 |
+
let index = -1
|
| 72 |
+
|
| 73 |
+
while (++index < node.children.length) {
|
| 74 |
+
const item = node.children[index]
|
| 75 |
+
|
| 76 |
+
if (
|
| 77 |
+
item &&
|
| 78 |
+
item.type === 'listItem' &&
|
| 79 |
+
item.children &&
|
| 80 |
+
item.children[0] &&
|
| 81 |
+
item.children[0].type === 'thematicBreak'
|
| 82 |
+
) {
|
| 83 |
+
useDifferentMarker = true
|
| 84 |
+
break
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
if (useDifferentMarker) {
|
| 91 |
+
bullet = bulletOther
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
state.bulletCurrent = bullet
|
| 95 |
+
const value = state.containerFlow(node, info)
|
| 96 |
+
state.bulletLastUsed = bullet
|
| 97 |
+
state.bulletCurrent = bulletCurrent
|
| 98 |
+
exit()
|
| 99 |
+
return value
|
| 100 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Paragraph, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
/**
|
| 6 |
+
* @param {Paragraph} node
|
| 7 |
+
* @param {Parents | undefined} _
|
| 8 |
+
* @param {State} state
|
| 9 |
+
* @param {Info} info
|
| 10 |
+
* @returns {string}
|
| 11 |
+
*/
|
| 12 |
+
export function paragraph(node: Paragraph, _: Parents | undefined, state: State, info: Info): string;
|
| 13 |
+
import type { Paragraph } from 'mdast';
|
| 14 |
+
import type { Parents } from 'mdast';
|
| 15 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 16 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 17 |
+
//# sourceMappingURL=paragraph.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["paragraph.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,gCANW,SAAS,KACT,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CASlB;+BAjBoC,OAAO;6BAAP,OAAO;2BADd,wBAAwB;0BAAxB,wBAAwB"}
|
node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Paragraph, Parents} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* @param {Paragraph} node
|
| 8 |
+
* @param {Parents | undefined} _
|
| 9 |
+
* @param {State} state
|
| 10 |
+
* @param {Info} info
|
| 11 |
+
* @returns {string}
|
| 12 |
+
*/
|
| 13 |
+
export function paragraph(node, _, state, info) {
|
| 14 |
+
const exit = state.enter('paragraph')
|
| 15 |
+
const subexit = state.enter('phrasing')
|
| 16 |
+
const value = state.containerPhrasing(node, info)
|
| 17 |
+
subexit()
|
| 18 |
+
exit()
|
| 19 |
+
return value
|
| 20 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/root.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {Root} node
|
| 3 |
+
* @param {Parents | undefined} _
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @param {Info} info
|
| 6 |
+
* @returns {string}
|
| 7 |
+
*/
|
| 8 |
+
export function root(node: Root, _: Parents | undefined, state: State, info: Info): string;
|
| 9 |
+
import type { Root } from 'mdast';
|
| 10 |
+
import type { Parents } from 'mdast';
|
| 11 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 12 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 13 |
+
//# sourceMappingURL=root.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/root.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["root.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,2BANW,IAAI,KACJ,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CAUlB;0BApB+B,OAAO;6BAAP,OAAO;2BADT,wBAAwB;0BAAxB,wBAAwB"}
|
node_modules/mdast-util-to-markdown/lib/handle/root.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Parents, Root} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
import {phrasing} from 'mdast-util-phrasing'
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* @param {Root} node
|
| 10 |
+
* @param {Parents | undefined} _
|
| 11 |
+
* @param {State} state
|
| 12 |
+
* @param {Info} info
|
| 13 |
+
* @returns {string}
|
| 14 |
+
*/
|
| 15 |
+
export function root(node, _, state, info) {
|
| 16 |
+
// Note: `html` nodes are ambiguous.
|
| 17 |
+
const hasPhrasing = node.children.some(function (d) {
|
| 18 |
+
return phrasing(d)
|
| 19 |
+
})
|
| 20 |
+
|
| 21 |
+
const container = hasPhrasing ? state.containerPhrasing : state.containerFlow
|
| 22 |
+
return container.call(state, node, info)
|
| 23 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {Strong} node
|
| 3 |
+
* @param {Parents | undefined} _
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @param {Info} info
|
| 6 |
+
* @returns {string}
|
| 7 |
+
*/
|
| 8 |
+
export function strong(node: Strong, _: Parents | undefined, state: State, info: Info): string;
|
| 9 |
+
export namespace strong {
|
| 10 |
+
export { strongPeek as peek };
|
| 11 |
+
}
|
| 12 |
+
import type { Strong } from 'mdast';
|
| 13 |
+
import type { Parents } from 'mdast';
|
| 14 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 15 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 16 |
+
/**
|
| 17 |
+
* @param {Strong} _
|
| 18 |
+
* @param {Parents | undefined} _1
|
| 19 |
+
* @param {State} state
|
| 20 |
+
* @returns {string}
|
| 21 |
+
*/
|
| 22 |
+
declare function strongPeek(_: Strong, _1: Parents | undefined, state: State): string;
|
| 23 |
+
export {};
|
| 24 |
+
//# sourceMappingURL=strong.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"strong.d.ts","sourceRoot":"","sources":["strong.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,6BANW,MAAM,KACN,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CA0ClB;;;;4BAxDiC,OAAO;6BAAP,OAAO;2BADX,wBAAwB;0BAAxB,wBAAwB;AA2DtD;;;;;GAKG;AACH,+BALW,MAAM,MACN,OAAO,GAAG,SAAS,SACnB,KAAK,GACH,MAAM,CAIlB"}
|
node_modules/mdast-util-to-markdown/lib/handle/strong.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Parents, Strong} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
import {checkStrong} from '../util/check-strong.js'
|
| 7 |
+
import {encodeCharacterReference} from '../util/encode-character-reference.js'
|
| 8 |
+
import {encodeInfo} from '../util/encode-info.js'
|
| 9 |
+
|
| 10 |
+
strong.peek = strongPeek
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* @param {Strong} node
|
| 14 |
+
* @param {Parents | undefined} _
|
| 15 |
+
* @param {State} state
|
| 16 |
+
* @param {Info} info
|
| 17 |
+
* @returns {string}
|
| 18 |
+
*/
|
| 19 |
+
export function strong(node, _, state, info) {
|
| 20 |
+
const marker = checkStrong(state)
|
| 21 |
+
const exit = state.enter('strong')
|
| 22 |
+
const tracker = state.createTracker(info)
|
| 23 |
+
const before = tracker.move(marker + marker)
|
| 24 |
+
|
| 25 |
+
let between = tracker.move(
|
| 26 |
+
state.containerPhrasing(node, {
|
| 27 |
+
after: marker,
|
| 28 |
+
before,
|
| 29 |
+
...tracker.current()
|
| 30 |
+
})
|
| 31 |
+
)
|
| 32 |
+
const betweenHead = between.charCodeAt(0)
|
| 33 |
+
const open = encodeInfo(
|
| 34 |
+
info.before.charCodeAt(info.before.length - 1),
|
| 35 |
+
betweenHead,
|
| 36 |
+
marker
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
if (open.inside) {
|
| 40 |
+
between = encodeCharacterReference(betweenHead) + between.slice(1)
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
const betweenTail = between.charCodeAt(between.length - 1)
|
| 44 |
+
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker)
|
| 45 |
+
|
| 46 |
+
if (close.inside) {
|
| 47 |
+
between = between.slice(0, -1) + encodeCharacterReference(betweenTail)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
const after = tracker.move(marker + marker)
|
| 51 |
+
|
| 52 |
+
exit()
|
| 53 |
+
|
| 54 |
+
state.attentionEncodeSurroundingInfo = {
|
| 55 |
+
after: close.outside,
|
| 56 |
+
before: open.outside
|
| 57 |
+
}
|
| 58 |
+
return before + between + after
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @param {Strong} _
|
| 63 |
+
* @param {Parents | undefined} _1
|
| 64 |
+
* @param {State} state
|
| 65 |
+
* @returns {string}
|
| 66 |
+
*/
|
| 67 |
+
function strongPeek(_, _1, state) {
|
| 68 |
+
return state.options.strong || '*'
|
| 69 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/text.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Parents, Text} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
/**
|
| 6 |
+
* @param {Text} node
|
| 7 |
+
* @param {Parents | undefined} _
|
| 8 |
+
* @param {State} state
|
| 9 |
+
* @param {Info} info
|
| 10 |
+
* @returns {string}
|
| 11 |
+
*/
|
| 12 |
+
export function text(node: Text, _: Parents | undefined, state: State, info: Info): string;
|
| 13 |
+
import type { Text } from 'mdast';
|
| 14 |
+
import type { Parents } from 'mdast';
|
| 15 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 16 |
+
import type { Info } from 'mdast-util-to-markdown';
|
| 17 |
+
//# sourceMappingURL=text.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/text.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["text.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,2BANW,IAAI,KACJ,OAAO,GAAG,SAAS,SACnB,KAAK,QACL,IAAI,GACF,MAAM,CAIlB;0BAZ+B,OAAO;6BAAP,OAAO;2BADT,wBAAwB;0BAAxB,wBAAwB"}
|
node_modules/mdast-util-to-markdown/lib/handle/text.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Parents, Text} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* @param {Text} node
|
| 8 |
+
* @param {Parents | undefined} _
|
| 9 |
+
* @param {State} state
|
| 10 |
+
* @param {Info} info
|
| 11 |
+
* @returns {string}
|
| 12 |
+
*/
|
| 13 |
+
export function text(node, _, state, info) {
|
| 14 |
+
return state.safe(node.value, info)
|
| 15 |
+
}
|
node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {ThematicBreak} _
|
| 3 |
+
* @param {Parents | undefined} _1
|
| 4 |
+
* @param {State} state
|
| 5 |
+
* @returns {string}
|
| 6 |
+
*/
|
| 7 |
+
export function thematicBreak(_: ThematicBreak, _1: Parents | undefined, state: State): string;
|
| 8 |
+
import type { ThematicBreak } from 'mdast';
|
| 9 |
+
import type { Parents } from 'mdast';
|
| 10 |
+
import type { State } from 'mdast-util-to-markdown';
|
| 11 |
+
//# sourceMappingURL=thematic-break.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"thematic-break.d.ts","sourceRoot":"","sources":["thematic-break.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,iCALW,aAAa,MACb,OAAO,GAAG,SAAS,SACnB,KAAK,GACH,MAAM,CAQlB;mCAlBwC,OAAO;6BAAP,OAAO;2BADxB,wBAAwB"}
|
node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Parents, ThematicBreak} from 'mdast'
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
import {checkRuleRepetition} from '../util/check-rule-repetition.js'
|
| 7 |
+
import {checkRule} from '../util/check-rule.js'
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* @param {ThematicBreak} _
|
| 11 |
+
* @param {Parents | undefined} _1
|
| 12 |
+
* @param {State} state
|
| 13 |
+
* @returns {string}
|
| 14 |
+
*/
|
| 15 |
+
export function thematicBreak(_, _1, state) {
|
| 16 |
+
const value = (
|
| 17 |
+
checkRule(state) + (state.options.ruleSpaces ? ' ' : '')
|
| 18 |
+
).repeat(checkRuleRepetition(state))
|
| 19 |
+
|
| 20 |
+
return state.options.ruleSpaces ? value.slice(0, -1) : value
|
| 21 |
+
}
|
node_modules/mdast-util-to-markdown/lib/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Turn an mdast syntax tree into markdown.
|
| 3 |
+
*
|
| 4 |
+
* @param {Nodes} tree
|
| 5 |
+
* Tree to serialize.
|
| 6 |
+
* @param {Options | null | undefined} [options]
|
| 7 |
+
* Configuration (optional).
|
| 8 |
+
* @returns {string}
|
| 9 |
+
* Serialized markdown representing `tree`.
|
| 10 |
+
*/
|
| 11 |
+
export function toMarkdown(tree: Nodes, options?: Options | null | undefined): string;
|
| 12 |
+
import type { Nodes } from 'mdast';
|
| 13 |
+
import type { Options } from 'mdast-util-to-markdown';
|
| 14 |
+
//# sourceMappingURL=index.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"}
|
node_modules/mdast-util-to-markdown/lib/index.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Info, Join, Options, SafeConfig, State} from 'mdast-util-to-markdown'
|
| 3 |
+
* @import {Nodes} from 'mdast'
|
| 4 |
+
* @import {Enter, FlowParents, PhrasingParents, TrackFields} from './types.js'
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
import {zwitch} from 'zwitch'
|
| 8 |
+
import {configure} from './configure.js'
|
| 9 |
+
import {handle as handlers} from './handle/index.js'
|
| 10 |
+
import {join} from './join.js'
|
| 11 |
+
import {unsafe} from './unsafe.js'
|
| 12 |
+
import {association} from './util/association.js'
|
| 13 |
+
import {compilePattern} from './util/compile-pattern.js'
|
| 14 |
+
import {containerPhrasing} from './util/container-phrasing.js'
|
| 15 |
+
import {containerFlow} from './util/container-flow.js'
|
| 16 |
+
import {indentLines} from './util/indent-lines.js'
|
| 17 |
+
import {safe} from './util/safe.js'
|
| 18 |
+
import {track} from './util/track.js'
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Turn an mdast syntax tree into markdown.
|
| 22 |
+
*
|
| 23 |
+
* @param {Nodes} tree
|
| 24 |
+
* Tree to serialize.
|
| 25 |
+
* @param {Options | null | undefined} [options]
|
| 26 |
+
* Configuration (optional).
|
| 27 |
+
* @returns {string}
|
| 28 |
+
* Serialized markdown representing `tree`.
|
| 29 |
+
*/
|
| 30 |
+
export function toMarkdown(tree, options) {
|
| 31 |
+
const settings = options || {}
|
| 32 |
+
/** @type {State} */
|
| 33 |
+
const state = {
|
| 34 |
+
associationId: association,
|
| 35 |
+
containerPhrasing: containerPhrasingBound,
|
| 36 |
+
containerFlow: containerFlowBound,
|
| 37 |
+
createTracker: track,
|
| 38 |
+
compilePattern,
|
| 39 |
+
enter,
|
| 40 |
+
// @ts-expect-error: GFM / frontmatter are typed in `mdast` but not defined
|
| 41 |
+
// here.
|
| 42 |
+
handlers: {...handlers},
|
| 43 |
+
// @ts-expect-error: add `handle` in a second.
|
| 44 |
+
handle: undefined,
|
| 45 |
+
indentLines,
|
| 46 |
+
indexStack: [],
|
| 47 |
+
join: [...join],
|
| 48 |
+
options: {},
|
| 49 |
+
safe: safeBound,
|
| 50 |
+
stack: [],
|
| 51 |
+
unsafe: [...unsafe]
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
configure(state, settings)
|
| 55 |
+
|
| 56 |
+
if (state.options.tightDefinitions) {
|
| 57 |
+
state.join.push(joinDefinition)
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
state.handle = zwitch('type', {
|
| 61 |
+
invalid,
|
| 62 |
+
unknown,
|
| 63 |
+
handlers: state.handlers
|
| 64 |
+
})
|
| 65 |
+
|
| 66 |
+
let result = state.handle(tree, undefined, state, {
|
| 67 |
+
before: '\n',
|
| 68 |
+
after: '\n',
|
| 69 |
+
now: {line: 1, column: 1},
|
| 70 |
+
lineShift: 0
|
| 71 |
+
})
|
| 72 |
+
|
| 73 |
+
if (
|
| 74 |
+
result &&
|
| 75 |
+
result.charCodeAt(result.length - 1) !== 10 &&
|
| 76 |
+
result.charCodeAt(result.length - 1) !== 13
|
| 77 |
+
) {
|
| 78 |
+
result += '\n'
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
return result
|
| 82 |
+
|
| 83 |
+
/** @type {Enter} */
|
| 84 |
+
function enter(name) {
|
| 85 |
+
state.stack.push(name)
|
| 86 |
+
return exit
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* @returns {undefined}
|
| 90 |
+
*/
|
| 91 |
+
function exit() {
|
| 92 |
+
state.stack.pop()
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* @param {unknown} value
|
| 99 |
+
* @returns {never}
|
| 100 |
+
*/
|
| 101 |
+
function invalid(value) {
|
| 102 |
+
throw new Error('Cannot handle value `' + value + '`, expected node')
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* @param {unknown} value
|
| 107 |
+
* @returns {never}
|
| 108 |
+
*/
|
| 109 |
+
function unknown(value) {
|
| 110 |
+
// Always a node.
|
| 111 |
+
const node = /** @type {Nodes} */ (value)
|
| 112 |
+
throw new Error('Cannot handle unknown node `' + node.type + '`')
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/** @type {Join} */
|
| 116 |
+
function joinDefinition(left, right) {
|
| 117 |
+
// No blank line between adjacent definitions.
|
| 118 |
+
if (left.type === 'definition' && left.type === right.type) {
|
| 119 |
+
return 0
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Serialize the children of a parent that contains phrasing children.
|
| 125 |
+
*
|
| 126 |
+
* These children will be joined flush together.
|
| 127 |
+
*
|
| 128 |
+
* @this {State}
|
| 129 |
+
* Info passed around about the current state.
|
| 130 |
+
* @param {PhrasingParents} parent
|
| 131 |
+
* Parent of flow nodes.
|
| 132 |
+
* @param {Info} info
|
| 133 |
+
* Info on where we are in the document we are generating.
|
| 134 |
+
* @returns {string}
|
| 135 |
+
* Serialized children, joined together.
|
| 136 |
+
*/
|
| 137 |
+
function containerPhrasingBound(parent, info) {
|
| 138 |
+
return containerPhrasing(parent, this, info)
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Serialize the children of a parent that contains flow children.
|
| 143 |
+
*
|
| 144 |
+
* These children will typically be joined by blank lines.
|
| 145 |
+
* What they are joined by exactly is defined by `Join` functions.
|
| 146 |
+
*
|
| 147 |
+
* @this {State}
|
| 148 |
+
* Info passed around about the current state.
|
| 149 |
+
* @param {FlowParents} parent
|
| 150 |
+
* Parent of flow nodes.
|
| 151 |
+
* @param {TrackFields} info
|
| 152 |
+
* Info on where we are in the document we are generating.
|
| 153 |
+
* @returns {string}
|
| 154 |
+
* Serialized children, joined by (blank) lines.
|
| 155 |
+
*/
|
| 156 |
+
function containerFlowBound(parent, info) {
|
| 157 |
+
return containerFlow(parent, this, info)
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* Make a string safe for embedding in markdown constructs.
|
| 162 |
+
*
|
| 163 |
+
* In markdown, almost all punctuation characters can, in certain cases,
|
| 164 |
+
* result in something.
|
| 165 |
+
* Whether they do is highly subjective to where they happen and in what
|
| 166 |
+
* they happen.
|
| 167 |
+
*
|
| 168 |
+
* To solve this, `mdast-util-to-markdown` tracks:
|
| 169 |
+
*
|
| 170 |
+
* * Characters before and after something;
|
| 171 |
+
* * What “constructs” we are in.
|
| 172 |
+
*
|
| 173 |
+
* This information is then used by this function to escape or encode
|
| 174 |
+
* special characters.
|
| 175 |
+
*
|
| 176 |
+
* @this {State}
|
| 177 |
+
* Info passed around about the current state.
|
| 178 |
+
* @param {string | null | undefined} value
|
| 179 |
+
* Raw value to make safe.
|
| 180 |
+
* @param {SafeConfig} config
|
| 181 |
+
* Configuration.
|
| 182 |
+
* @returns {string}
|
| 183 |
+
* Serialized markdown safe for embedding.
|
| 184 |
+
*/
|
| 185 |
+
function safeBound(value, config) {
|
| 186 |
+
return safe(this, value, config)
|
| 187 |
+
}
|
node_modules/mdast-util-to-markdown/lib/join.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Array<Join>} */
|
| 2 |
+
export const join: Array<Join>;
|
| 3 |
+
import type { Join } from 'mdast-util-to-markdown';
|
| 4 |
+
//# sourceMappingURL=join.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/join.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["join.js"],"names":[],"mappings":"AAOA,0BAA0B;AAC1B,mBADW,KAAK,CAAC,IAAI,CAAC,CACY;0BAPX,wBAAwB"}
|
node_modules/mdast-util-to-markdown/lib/join.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {Join} from 'mdast-util-to-markdown'
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
import {formatCodeAsIndented} from './util/format-code-as-indented.js'
|
| 6 |
+
import {formatHeadingAsSetext} from './util/format-heading-as-setext.js'
|
| 7 |
+
|
| 8 |
+
/** @type {Array<Join>} */
|
| 9 |
+
export const join = [joinDefaults]
|
| 10 |
+
|
| 11 |
+
/** @type {Join} */
|
| 12 |
+
function joinDefaults(left, right, parent, state) {
|
| 13 |
+
// Indented code after list or another indented code.
|
| 14 |
+
if (
|
| 15 |
+
right.type === 'code' &&
|
| 16 |
+
formatCodeAsIndented(right, state) &&
|
| 17 |
+
(left.type === 'list' ||
|
| 18 |
+
(left.type === right.type && formatCodeAsIndented(left, state)))
|
| 19 |
+
) {
|
| 20 |
+
return false
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
// Join children of a list or an item.
|
| 24 |
+
// In which case, `parent` has a `spread` field.
|
| 25 |
+
if ('spread' in parent && typeof parent.spread === 'boolean') {
|
| 26 |
+
if (
|
| 27 |
+
left.type === 'paragraph' &&
|
| 28 |
+
// Two paragraphs.
|
| 29 |
+
(left.type === right.type ||
|
| 30 |
+
right.type === 'definition' ||
|
| 31 |
+
// Paragraph followed by a setext heading.
|
| 32 |
+
(right.type === 'heading' && formatHeadingAsSetext(right, state)))
|
| 33 |
+
) {
|
| 34 |
+
return
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
return parent.spread ? 1 : 0
|
| 38 |
+
}
|
| 39 |
+
}
|
node_modules/mdast-util-to-markdown/lib/types.d.ts
ADDED
|
@@ -0,0 +1,965 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type {
|
| 2 |
+
Parents,
|
| 3 |
+
PhrasingContent,
|
| 4 |
+
TableCell,
|
| 5 |
+
TableRow,
|
| 6 |
+
Association,
|
| 7 |
+
Nodes
|
| 8 |
+
} from 'mdast'
|
| 9 |
+
import type {Point} from 'unist'
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Get an identifier from an association to match it to others.
|
| 13 |
+
*
|
| 14 |
+
* Associations are nodes that match to something else through an ID:
|
| 15 |
+
* <https://github.com/syntax-tree/mdast#association>.
|
| 16 |
+
*
|
| 17 |
+
* The `label` of an association is the string value: character escapes and
|
| 18 |
+
* references work, and casing is intact.
|
| 19 |
+
* The `identifier` is used to match one association to another:
|
| 20 |
+
* controversially, character escapes and references don’t work in this
|
| 21 |
+
* matching: `©` does not match `©`, and `\+` does not match `+`.
|
| 22 |
+
*
|
| 23 |
+
* But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb`
|
| 24 |
+
* matches `a b`.
|
| 25 |
+
* So, we do prefer the label when figuring out how we’re going to serialize:
|
| 26 |
+
* it has whitespace, casing, and we can ignore most useless character
|
| 27 |
+
* escapes and all character references.
|
| 28 |
+
*
|
| 29 |
+
* @param node
|
| 30 |
+
* Node that includes an association.
|
| 31 |
+
* @returns
|
| 32 |
+
* ID.
|
| 33 |
+
*/
|
| 34 |
+
export type AssociationId = (node: Association) => string
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Compile an unsafe pattern to a regex.
|
| 38 |
+
*
|
| 39 |
+
* @param info
|
| 40 |
+
* Pattern.
|
| 41 |
+
* @returns
|
| 42 |
+
* Regex.
|
| 43 |
+
*/
|
| 44 |
+
export type CompilePattern = (info: Unsafe) => RegExp
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Interface of registered constructs.
|
| 48 |
+
*
|
| 49 |
+
* When working on extensions that use new constructs, extend the corresponding
|
| 50 |
+
* interface to register its name:
|
| 51 |
+
*
|
| 52 |
+
* ```ts
|
| 53 |
+
* declare module 'mdast-util-to-markdown' {
|
| 54 |
+
* interface ConstructNameMap {
|
| 55 |
+
* // Register a new construct name (value is used, key should match it).
|
| 56 |
+
* gfmStrikethrough: 'gfmStrikethrough'
|
| 57 |
+
* }
|
| 58 |
+
* }
|
| 59 |
+
* ```
|
| 60 |
+
*/
|
| 61 |
+
export interface ConstructNameMap {
|
| 62 |
+
/**
|
| 63 |
+
* Whole autolink.
|
| 64 |
+
*
|
| 65 |
+
* ```markdown
|
| 66 |
+
* > | <https://example.com> and <admin@example.com>
|
| 67 |
+
* ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
|
| 68 |
+
* ```
|
| 69 |
+
*/
|
| 70 |
+
autolink: 'autolink'
|
| 71 |
+
/**
|
| 72 |
+
* Whole block quote.
|
| 73 |
+
*
|
| 74 |
+
* ```markdown
|
| 75 |
+
* > | > a
|
| 76 |
+
* ^^^
|
| 77 |
+
* > | b
|
| 78 |
+
* ^
|
| 79 |
+
* ```
|
| 80 |
+
*/
|
| 81 |
+
blockquote: 'blockquote'
|
| 82 |
+
/**
|
| 83 |
+
* Whole code (indented).
|
| 84 |
+
*
|
| 85 |
+
* ```markdown
|
| 86 |
+
* ␠␠␠␠console.log(1)
|
| 87 |
+
* ^^^^^^^^^^^^^^^^^^
|
| 88 |
+
* ```
|
| 89 |
+
*/
|
| 90 |
+
codeIndented: 'codeIndented'
|
| 91 |
+
/**
|
| 92 |
+
* Whole code (fenced).
|
| 93 |
+
*
|
| 94 |
+
* ````markdown
|
| 95 |
+
* > | ```js
|
| 96 |
+
* ^^^^^
|
| 97 |
+
* > | console.log(1)
|
| 98 |
+
* ^^^^^^^^^^^^^^
|
| 99 |
+
* > | ```
|
| 100 |
+
* ^^^
|
| 101 |
+
* ````
|
| 102 |
+
*/
|
| 103 |
+
codeFenced: 'codeFenced'
|
| 104 |
+
/**
|
| 105 |
+
* Code (fenced) language, when fenced with grave accents.
|
| 106 |
+
*
|
| 107 |
+
* ````markdown
|
| 108 |
+
* > | ```js
|
| 109 |
+
* ^^
|
| 110 |
+
* | console.log(1)
|
| 111 |
+
* | ```
|
| 112 |
+
* ````
|
| 113 |
+
*/
|
| 114 |
+
codeFencedLangGraveAccent: 'codeFencedLangGraveAccent'
|
| 115 |
+
/**
|
| 116 |
+
* Code (fenced) language, when fenced with tildes.
|
| 117 |
+
*
|
| 118 |
+
* ````markdown
|
| 119 |
+
* > | ~~~js
|
| 120 |
+
* ^^
|
| 121 |
+
* | console.log(1)
|
| 122 |
+
* | ~~~
|
| 123 |
+
* ````
|
| 124 |
+
*/
|
| 125 |
+
codeFencedLangTilde: 'codeFencedLangTilde'
|
| 126 |
+
/**
|
| 127 |
+
* Code (fenced) meta string, when fenced with grave accents.
|
| 128 |
+
*
|
| 129 |
+
* ````markdown
|
| 130 |
+
* > | ```js eval
|
| 131 |
+
* ^^^^
|
| 132 |
+
* | console.log(1)
|
| 133 |
+
* | ```
|
| 134 |
+
* ````
|
| 135 |
+
*/
|
| 136 |
+
codeFencedMetaGraveAccent: 'codeFencedMetaGraveAccent'
|
| 137 |
+
/**
|
| 138 |
+
* Code (fenced) meta string, when fenced with tildes.
|
| 139 |
+
*
|
| 140 |
+
* ````markdown
|
| 141 |
+
* > | ~~~js eval
|
| 142 |
+
* ^^^^
|
| 143 |
+
* | console.log(1)
|
| 144 |
+
* | ~~~
|
| 145 |
+
* ````
|
| 146 |
+
*/
|
| 147 |
+
codeFencedMetaTilde: 'codeFencedMetaTilde'
|
| 148 |
+
/**
|
| 149 |
+
* Whole definition.
|
| 150 |
+
*
|
| 151 |
+
* ```markdown
|
| 152 |
+
* > | [a]: b "c"
|
| 153 |
+
* ^^^^^^^^^^
|
| 154 |
+
* ```
|
| 155 |
+
*/
|
| 156 |
+
definition: 'definition'
|
| 157 |
+
/**
|
| 158 |
+
* Destination (literal) (occurs in definition, image, link).
|
| 159 |
+
*
|
| 160 |
+
* ```markdown
|
| 161 |
+
* > | [a]: <b> "c"
|
| 162 |
+
* ^^^
|
| 163 |
+
* > | a  e
|
| 164 |
+
* ^^^
|
| 165 |
+
* ```
|
| 166 |
+
*/
|
| 167 |
+
destinationLiteral: 'destinationLiteral'
|
| 168 |
+
/**
|
| 169 |
+
* Destination (raw) (occurs in definition, image, link).
|
| 170 |
+
*
|
| 171 |
+
* ```markdown
|
| 172 |
+
* > | [a]: b "c"
|
| 173 |
+
* ^
|
| 174 |
+
* > | a  e
|
| 175 |
+
* ^
|
| 176 |
+
* ```
|
| 177 |
+
*/
|
| 178 |
+
destinationRaw: 'destinationRaw'
|
| 179 |
+
/**
|
| 180 |
+
* Emphasis.
|
| 181 |
+
*
|
| 182 |
+
* ```markdown
|
| 183 |
+
* > | *a*
|
| 184 |
+
* ^^^
|
| 185 |
+
* ```
|
| 186 |
+
*/
|
| 187 |
+
emphasis: 'emphasis'
|
| 188 |
+
/**
|
| 189 |
+
* Whole heading (atx).
|
| 190 |
+
*
|
| 191 |
+
* ```markdown
|
| 192 |
+
* > | # alpha
|
| 193 |
+
* ^^^^^^^
|
| 194 |
+
* ```
|
| 195 |
+
*/
|
| 196 |
+
headingAtx: 'headingAtx'
|
| 197 |
+
/**
|
| 198 |
+
* Whole heading (setext).
|
| 199 |
+
*
|
| 200 |
+
* ```markdown
|
| 201 |
+
* > | alpha
|
| 202 |
+
* ^^^^^
|
| 203 |
+
* > | =====
|
| 204 |
+
* ^^^^^
|
| 205 |
+
* ```
|
| 206 |
+
*/
|
| 207 |
+
headingSetext: 'headingSetext'
|
| 208 |
+
/**
|
| 209 |
+
* Whole image.
|
| 210 |
+
*
|
| 211 |
+
* ```markdown
|
| 212 |
+
* > | 
|
| 213 |
+
* ^^^^^^^
|
| 214 |
+
* > | ![c]
|
| 215 |
+
* ^^^^
|
| 216 |
+
* ```
|
| 217 |
+
*/
|
| 218 |
+
image: 'image'
|
| 219 |
+
/**
|
| 220 |
+
* Whole image reference.
|
| 221 |
+
*
|
| 222 |
+
* ```markdown
|
| 223 |
+
* > | ![a]
|
| 224 |
+
* ^^^^
|
| 225 |
+
* ```
|
| 226 |
+
*/
|
| 227 |
+
imageReference: 'imageReference'
|
| 228 |
+
/**
|
| 229 |
+
* Label (occurs in definitions, image reference, image, link reference,
|
| 230 |
+
* link).
|
| 231 |
+
*
|
| 232 |
+
* ```markdown
|
| 233 |
+
* > | [a]: b "c"
|
| 234 |
+
* ^^^
|
| 235 |
+
* > | a [b] c
|
| 236 |
+
* ^^^
|
| 237 |
+
* > | a ![b][c] d
|
| 238 |
+
* ^^^^
|
| 239 |
+
* > | a [b](c) d
|
| 240 |
+
* ^^^
|
| 241 |
+
* ```
|
| 242 |
+
*/
|
| 243 |
+
label: 'label'
|
| 244 |
+
/**
|
| 245 |
+
* Whole link.
|
| 246 |
+
*
|
| 247 |
+
* ```markdown
|
| 248 |
+
* > | [a](b)
|
| 249 |
+
* ^^^^^^
|
| 250 |
+
* > | [c]
|
| 251 |
+
* ^^^
|
| 252 |
+
* ```
|
| 253 |
+
*/
|
| 254 |
+
link: 'link'
|
| 255 |
+
/**
|
| 256 |
+
* Whole link reference.
|
| 257 |
+
*
|
| 258 |
+
* ```markdown
|
| 259 |
+
* > | [a]
|
| 260 |
+
* ^^^
|
| 261 |
+
* ```
|
| 262 |
+
*/
|
| 263 |
+
linkReference: 'linkReference'
|
| 264 |
+
/**
|
| 265 |
+
* List.
|
| 266 |
+
*
|
| 267 |
+
* ```markdown
|
| 268 |
+
* > | * a
|
| 269 |
+
* ^^^
|
| 270 |
+
* > | 1. b
|
| 271 |
+
* ^^^^
|
| 272 |
+
* ```
|
| 273 |
+
*/
|
| 274 |
+
list: 'list'
|
| 275 |
+
/**
|
| 276 |
+
* List item.
|
| 277 |
+
*
|
| 278 |
+
* ```markdown
|
| 279 |
+
* > | * a
|
| 280 |
+
* ^^^
|
| 281 |
+
* > | 1. b
|
| 282 |
+
* ^^^^
|
| 283 |
+
* ```
|
| 284 |
+
*/
|
| 285 |
+
listItem: 'listItem'
|
| 286 |
+
/**
|
| 287 |
+
* Paragraph.
|
| 288 |
+
*
|
| 289 |
+
* ```markdown
|
| 290 |
+
* > | a b
|
| 291 |
+
* ^^^
|
| 292 |
+
* > | c.
|
| 293 |
+
* ^^
|
| 294 |
+
* ```
|
| 295 |
+
*/
|
| 296 |
+
paragraph: 'paragraph'
|
| 297 |
+
/**
|
| 298 |
+
* Phrasing (occurs in headings, paragraphs, etc).
|
| 299 |
+
*
|
| 300 |
+
* ```markdown
|
| 301 |
+
* > | a
|
| 302 |
+
* ^
|
| 303 |
+
* ```
|
| 304 |
+
*/
|
| 305 |
+
phrasing: 'phrasing'
|
| 306 |
+
/**
|
| 307 |
+
* Reference (occurs in image, link).
|
| 308 |
+
*
|
| 309 |
+
* ```markdown
|
| 310 |
+
* > | [a][]
|
| 311 |
+
* ^^
|
| 312 |
+
* ```
|
| 313 |
+
*/
|
| 314 |
+
reference: 'reference'
|
| 315 |
+
/**
|
| 316 |
+
* Strong.
|
| 317 |
+
*
|
| 318 |
+
* ```markdown
|
| 319 |
+
* > | **a**
|
| 320 |
+
* ^^^^^
|
| 321 |
+
* ```
|
| 322 |
+
*/
|
| 323 |
+
strong: 'strong'
|
| 324 |
+
/**
|
| 325 |
+
* Title using single quotes (occurs in definition, image, link).
|
| 326 |
+
*
|
| 327 |
+
* ```markdown
|
| 328 |
+
* > | [a](b 'c')
|
| 329 |
+
* ^^^
|
| 330 |
+
* ```
|
| 331 |
+
*/
|
| 332 |
+
titleApostrophe: 'titleApostrophe'
|
| 333 |
+
/**
|
| 334 |
+
* Title using double quotes (occurs in definition, image, link).
|
| 335 |
+
*
|
| 336 |
+
* ```markdown
|
| 337 |
+
* > | [a](b "c")
|
| 338 |
+
* ^^^
|
| 339 |
+
* ```
|
| 340 |
+
*/
|
| 341 |
+
titleQuote: 'titleQuote'
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
/**
|
| 345 |
+
* Construct names for things generated by `mdast-util-to-markdown`.
|
| 346 |
+
*
|
| 347 |
+
* This is an enum of strings, each being a semantic label, useful to know when
|
| 348 |
+
* serializing whether we’re for example in a double (`"`) or single (`'`)
|
| 349 |
+
* quoted title.
|
| 350 |
+
*/
|
| 351 |
+
export type ConstructName = ConstructNameMap[keyof ConstructNameMap]
|
| 352 |
+
|
| 353 |
+
/**
|
| 354 |
+
* Serialize the children of a parent that contains flow children.
|
| 355 |
+
*
|
| 356 |
+
* These children will typically be joined by blank lines.
|
| 357 |
+
* What they are joined by exactly is defined by `Join` functions.
|
| 358 |
+
*
|
| 359 |
+
* @param parent
|
| 360 |
+
* Parent of flow nodes.
|
| 361 |
+
* @param info
|
| 362 |
+
* Info on where we are in the document we are generating.
|
| 363 |
+
* @returns
|
| 364 |
+
* Serialized children, joined by (blank) lines.
|
| 365 |
+
*/
|
| 366 |
+
export type ContainerFlow = (parent: FlowParents, info: TrackFields) => string
|
| 367 |
+
|
| 368 |
+
/**
|
| 369 |
+
* Serialize the children of a parent that contains phrasing children.
|
| 370 |
+
*
|
| 371 |
+
* These children will be joined flush together.
|
| 372 |
+
*
|
| 373 |
+
* @param parent
|
| 374 |
+
* Parent of phrasing nodes.
|
| 375 |
+
* @param info
|
| 376 |
+
* Info on where we are in the document we are generating.
|
| 377 |
+
* @returns
|
| 378 |
+
* Serialized children, joined together.
|
| 379 |
+
*/
|
| 380 |
+
export type ContainerPhrasing = (parent: PhrasingParents, info: Info) => string
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* Track positional info in the output.
|
| 384 |
+
*
|
| 385 |
+
* This info isn’t used yet but such functionality will allow line wrapping,
|
| 386 |
+
* source maps, etc.
|
| 387 |
+
*
|
| 388 |
+
* @param info
|
| 389 |
+
* Info on where we are in the document we are generating.
|
| 390 |
+
* @returns
|
| 391 |
+
* Tracker.
|
| 392 |
+
*/
|
| 393 |
+
export type CreateTracker = (info: TrackFields) => Tracker
|
| 394 |
+
|
| 395 |
+
/**
|
| 396 |
+
* Whether to encode things — with fields representing the surrounding of a
|
| 397 |
+
* whole.
|
| 398 |
+
*/
|
| 399 |
+
export interface EncodeSurrounding {
|
| 400 |
+
/**
|
| 401 |
+
* Whether to encode after.
|
| 402 |
+
*/
|
| 403 |
+
after: boolean
|
| 404 |
+
|
| 405 |
+
/**
|
| 406 |
+
* Whether to encode before.
|
| 407 |
+
*/
|
| 408 |
+
before: boolean
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
/**
|
| 412 |
+
* Whether to encode things — with fields representing the relationship to a
|
| 413 |
+
* whole.
|
| 414 |
+
*/
|
| 415 |
+
export interface EncodeSides {
|
| 416 |
+
/**
|
| 417 |
+
* Whether to encode inside.
|
| 418 |
+
*/
|
| 419 |
+
inside: boolean
|
| 420 |
+
|
| 421 |
+
/**
|
| 422 |
+
* Whether to encode before.
|
| 423 |
+
*/
|
| 424 |
+
outside: boolean
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
/**
|
| 428 |
+
* Enter something.
|
| 429 |
+
*
|
| 430 |
+
* @param name
|
| 431 |
+
* Label, more similar to a micromark event than an mdast node type.
|
| 432 |
+
* @returns
|
| 433 |
+
* Revert.
|
| 434 |
+
*/
|
| 435 |
+
export type Enter = (name: ConstructName) => Exit
|
| 436 |
+
|
| 437 |
+
/**
|
| 438 |
+
* Exit something.
|
| 439 |
+
*
|
| 440 |
+
* @returns
|
| 441 |
+
* Nothing.
|
| 442 |
+
*/
|
| 443 |
+
export type Exit = () => undefined
|
| 444 |
+
|
| 445 |
+
/**
|
| 446 |
+
* Children of flow nodes.
|
| 447 |
+
*/
|
| 448 |
+
export type FlowChildren = FlowParents extends {
|
| 449 |
+
children: Array<infer T>
|
| 450 |
+
}
|
| 451 |
+
? T
|
| 452 |
+
: never
|
| 453 |
+
|
| 454 |
+
/**
|
| 455 |
+
* Parents that are not phrasing,
|
| 456 |
+
* or similar.
|
| 457 |
+
*/
|
| 458 |
+
export type FlowParents = Exclude<
|
| 459 |
+
Parents,
|
| 460 |
+
PhrasingContent | TableCell | TableRow
|
| 461 |
+
>
|
| 462 |
+
|
| 463 |
+
/**
|
| 464 |
+
* Handle particular nodes.
|
| 465 |
+
*
|
| 466 |
+
* Each key is a node type, each value its corresponding handler.
|
| 467 |
+
*/
|
| 468 |
+
export type Handlers = Record<Nodes['type'], Handle>
|
| 469 |
+
|
| 470 |
+
/**
|
| 471 |
+
* Handle a particular node.
|
| 472 |
+
*
|
| 473 |
+
* @param node
|
| 474 |
+
* Expected mdast node.
|
| 475 |
+
* @param parent
|
| 476 |
+
* Parent of `node`.
|
| 477 |
+
* @param state
|
| 478 |
+
* Info passed around about the current state.
|
| 479 |
+
* @param Info
|
| 480 |
+
* Info on the surrounding of the node that is serialized.
|
| 481 |
+
* @returns
|
| 482 |
+
* Serialized markdown representing `node`.
|
| 483 |
+
*/
|
| 484 |
+
export type Handle = (
|
| 485 |
+
node: any,
|
| 486 |
+
parent: Parents | undefined,
|
| 487 |
+
state: State,
|
| 488 |
+
Info: Info
|
| 489 |
+
) => string
|
| 490 |
+
|
| 491 |
+
/**
|
| 492 |
+
* Pad serialized markdown.
|
| 493 |
+
*
|
| 494 |
+
* @param value
|
| 495 |
+
* Whole fragment of serialized markdown.
|
| 496 |
+
* @param map
|
| 497 |
+
* Map function.
|
| 498 |
+
* @returns
|
| 499 |
+
* Padded value.
|
| 500 |
+
*/
|
| 501 |
+
export type IndentLines = (value: string, map: Map) => string
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
* Info on the surrounding of the node that is serialized.
|
| 505 |
+
*/
|
| 506 |
+
export interface Info extends SafeFields, TrackFields {}
|
| 507 |
+
|
| 508 |
+
/**
|
| 509 |
+
* How to join two blocks.
|
| 510 |
+
*
|
| 511 |
+
* “Blocks” are typically joined by one blank line.
|
| 512 |
+
* Sometimes it’s nicer to have them flush next to each other, yet other
|
| 513 |
+
* times they cannot occur together at all.
|
| 514 |
+
*
|
| 515 |
+
* Join functions receive two adjacent siblings and their parent and what
|
| 516 |
+
* they return defines how many blank lines to use between them.
|
| 517 |
+
*
|
| 518 |
+
* @param left
|
| 519 |
+
* First of two adjacent siblings.
|
| 520 |
+
* @param right
|
| 521 |
+
* Second of two adjacent siblings.
|
| 522 |
+
* @param parent
|
| 523 |
+
* Parent of the two siblings.
|
| 524 |
+
* @param state
|
| 525 |
+
* Info passed around about the current state.
|
| 526 |
+
* @returns
|
| 527 |
+
* How many blank lines to use between the siblings.
|
| 528 |
+
*
|
| 529 |
+
* Where `true` is as passing `1` and `false` means the nodes cannot be
|
| 530 |
+
* joined by a blank line, such as two adjacent block quotes or indented code
|
| 531 |
+
* after a list, in which case a comment will be injected to break them up:
|
| 532 |
+
*
|
| 533 |
+
* ```markdown
|
| 534 |
+
* > Quote 1
|
| 535 |
+
*
|
| 536 |
+
* <!---->
|
| 537 |
+
*
|
| 538 |
+
* > Quote 2
|
| 539 |
+
* ```
|
| 540 |
+
*
|
| 541 |
+
* > 👉 **Note**: abusing this feature will break markdown.
|
| 542 |
+
* > One such example is when returning `0` for two paragraphs, which will
|
| 543 |
+
* > result in the text running together, and in the future to be seen as
|
| 544 |
+
* > one paragraph.
|
| 545 |
+
*/
|
| 546 |
+
export type Join = (
|
| 547 |
+
left: FlowChildren,
|
| 548 |
+
right: FlowChildren,
|
| 549 |
+
parent: FlowParents,
|
| 550 |
+
state: State
|
| 551 |
+
) => boolean | number | null | undefined | void
|
| 552 |
+
|
| 553 |
+
/**
|
| 554 |
+
* Map function to pad a single line.
|
| 555 |
+
*
|
| 556 |
+
* @param value
|
| 557 |
+
* A single line of serialized markdown.
|
| 558 |
+
* @param line
|
| 559 |
+
* Line number relative to the fragment.
|
| 560 |
+
* @param blank
|
| 561 |
+
* Whether the line is considered blank in markdown.
|
| 562 |
+
* @returns
|
| 563 |
+
* Padded line.
|
| 564 |
+
*/
|
| 565 |
+
export type Map = (value: string, line: number, blank: boolean) => string
|
| 566 |
+
|
| 567 |
+
/**
|
| 568 |
+
* Configuration (optional).
|
| 569 |
+
*/
|
| 570 |
+
export interface Options {
|
| 571 |
+
/**
|
| 572 |
+
* Marker to use in certain cases where the primary bullet doesn’t work
|
| 573 |
+
* (default: `'-'` when `bullet` is `'*'`, `'*'` otherwise).
|
| 574 |
+
*
|
| 575 |
+
* Cannot be equal to `bullet`.
|
| 576 |
+
*/
|
| 577 |
+
bulletOther?: '*' | '+' | '-' | null | undefined
|
| 578 |
+
/**
|
| 579 |
+
* Marker to use for bullets of items in ordered lists (default: `'.'`).
|
| 580 |
+
*
|
| 581 |
+
* There is one case where the primary bullet for ordered items cannot be
|
| 582 |
+
* used:
|
| 583 |
+
*
|
| 584 |
+
* * when two ordered lists appear next to each other: `1. a\n2) b`; to
|
| 585 |
+
* solve
|
| 586 |
+
* that, `'.'` will be used when `bulletOrdered` is `')'`, and `'.'`
|
| 587 |
+
* otherwise
|
| 588 |
+
*/
|
| 589 |
+
bulletOrdered?: '.' | ')' | null | undefined
|
| 590 |
+
/**
|
| 591 |
+
* Marker to use for bullets of items in unordered lists (default: `'*'`).
|
| 592 |
+
*
|
| 593 |
+
* There are three cases where the primary bullet cannot be used:
|
| 594 |
+
*
|
| 595 |
+
* * when three or more list items are on their own, the last one is empty,
|
| 596 |
+
* and `bullet` is also a valid `rule`: `* - +`; this would turn into a
|
| 597 |
+
* thematic break if serialized with three primary bullets; `bulletOther`
|
| 598 |
+
* is used for the last item
|
| 599 |
+
* * when a thematic break is the first child of a list item and `bullet` is
|
| 600 |
+
* the same character as `rule`: `- ***`; this would turn into a single
|
| 601 |
+
* thematic break if serialized with primary bullets; `bulletOther` is used
|
| 602 |
+
* for the item
|
| 603 |
+
* * when two unordered lists appear next to each other: `* a\n- b`;
|
| 604 |
+
* `bulletOther` is used for such lists
|
| 605 |
+
*/
|
| 606 |
+
bullet?: '*' | '+' | '-' | null | undefined
|
| 607 |
+
/**
|
| 608 |
+
* Whether to add the same number of number signs (`#`) at the end of an ATX
|
| 609 |
+
* heading as the opening sequence (default: `false`).
|
| 610 |
+
*/
|
| 611 |
+
closeAtx?: boolean | null | undefined
|
| 612 |
+
/**
|
| 613 |
+
* Marker to use for emphasis (default: `'*'`).
|
| 614 |
+
*/
|
| 615 |
+
emphasis?: '*' | '_' | null | undefined
|
| 616 |
+
/**
|
| 617 |
+
* List of extensions to include (optional).
|
| 618 |
+
*
|
| 619 |
+
* Each `ToMarkdownExtension` is an object with the same interface as
|
| 620 |
+
* `Options` here.
|
| 621 |
+
*/
|
| 622 |
+
extensions?: Array<Options> | null | undefined
|
| 623 |
+
/**
|
| 624 |
+
* Whether to use fenced code always (default: `true`).
|
| 625 |
+
*
|
| 626 |
+
* The default is to use fenced code if there is a language defined, if the
|
| 627 |
+
* code is empty, or if it starts or ends in blank lines.
|
| 628 |
+
*/
|
| 629 |
+
fences?: boolean | null | undefined
|
| 630 |
+
/**
|
| 631 |
+
* Marker to use for fenced code (default: ``'`'``).
|
| 632 |
+
*/
|
| 633 |
+
fence?: '`' | '~' | null | undefined
|
| 634 |
+
/**
|
| 635 |
+
* Handle particular nodes (optional).
|
| 636 |
+
*
|
| 637 |
+
* Each key is a node type, each value its corresponding handler.
|
| 638 |
+
*/
|
| 639 |
+
handlers?: Partial<Handlers> | null | undefined
|
| 640 |
+
/**
|
| 641 |
+
* Whether to increment the counter of ordered lists items (default: `true`).
|
| 642 |
+
*/
|
| 643 |
+
incrementListMarker?: boolean | null | undefined
|
| 644 |
+
/**
|
| 645 |
+
* How to join blocks (optional).
|
| 646 |
+
*/
|
| 647 |
+
join?: Array<Join> | null | undefined
|
| 648 |
+
/**
|
| 649 |
+
* How to indent the content of list items (default: `'one'`).
|
| 650 |
+
*
|
| 651 |
+
* Either with the size of the bullet plus one space (when `'one'`), a tab
|
| 652 |
+
* stop (`'tab'`), or depending on the item and its parent list (`'mixed'`,
|
| 653 |
+
* uses `'one'` if the item and list are tight and `'tab'` otherwise).
|
| 654 |
+
*/
|
| 655 |
+
listItemIndent?: 'mixed' | 'one' | 'tab' | null | undefined
|
| 656 |
+
/**
|
| 657 |
+
* Marker to use for titles (default: `'"'`).
|
| 658 |
+
*/
|
| 659 |
+
quote?: '"' | "'" | null | undefined
|
| 660 |
+
/**
|
| 661 |
+
* Whether to always use resource links (default: `false`).
|
| 662 |
+
*
|
| 663 |
+
* The default is to use autolinks (`<https://example.com>`) when possible
|
| 664 |
+
* and resource links (`[text](url)`) otherwise.
|
| 665 |
+
*/
|
| 666 |
+
resourceLink?: boolean | null | undefined
|
| 667 |
+
/**
|
| 668 |
+
* Number of markers to use for thematic breaks (default: `3`).
|
| 669 |
+
*/
|
| 670 |
+
ruleRepetition?: number | null | undefined
|
| 671 |
+
/**
|
| 672 |
+
* Whether to add spaces between markers in thematic breaks (default:
|
| 673 |
+
* `false`).
|
| 674 |
+
*/
|
| 675 |
+
ruleSpaces?: boolean | null | undefined
|
| 676 |
+
/**
|
| 677 |
+
* Marker to use for thematic breaks (default: `'*'`).
|
| 678 |
+
*/
|
| 679 |
+
rule?: '*' | '-' | '_' | null | undefined
|
| 680 |
+
/**
|
| 681 |
+
* Whether to use setext headings when possible (default: `false`).
|
| 682 |
+
*
|
| 683 |
+
* The default is to always use ATX headings (`# heading`) instead of setext
|
| 684 |
+
* headings (`heading\n=======`).
|
| 685 |
+
* Setext headings cannot be used for empty headings or headings with a rank
|
| 686 |
+
* of three or more.
|
| 687 |
+
*/
|
| 688 |
+
setext?: boolean | null | undefined
|
| 689 |
+
/**
|
| 690 |
+
* Marker to use for strong (default: `'*'`).
|
| 691 |
+
*/
|
| 692 |
+
strong?: '*' | '_' | null | undefined
|
| 693 |
+
/**
|
| 694 |
+
* Whether to join definitions without a blank line (default: `false`).
|
| 695 |
+
*
|
| 696 |
+
* The default is to add blank lines between any flow (“block”) construct.
|
| 697 |
+
* Turning this option on is a shortcut for a join function like so:
|
| 698 |
+
*
|
| 699 |
+
* ```js
|
| 700 |
+
* function joinTightDefinitions(left, right) {
|
| 701 |
+
* if (left.type === 'definition' && right.type === 'definition') {
|
| 702 |
+
* return 0
|
| 703 |
+
* }
|
| 704 |
+
* }
|
| 705 |
+
* ```
|
| 706 |
+
*/
|
| 707 |
+
tightDefinitions?: boolean | null | undefined
|
| 708 |
+
/**
|
| 709 |
+
* Schemas that define when characters cannot occur (optional).
|
| 710 |
+
*/
|
| 711 |
+
unsafe?: Array<Unsafe> | null | undefined
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
/**
|
| 715 |
+
* Parent of phrasing nodes.
|
| 716 |
+
*/
|
| 717 |
+
export type PhrasingParents = Parents extends {
|
| 718 |
+
children: Array<infer T>
|
| 719 |
+
}
|
| 720 |
+
? PhrasingContent extends T
|
| 721 |
+
? Parents
|
| 722 |
+
: never
|
| 723 |
+
: never
|
| 724 |
+
|
| 725 |
+
/**
|
| 726 |
+
* Configuration for `safe`
|
| 727 |
+
*/
|
| 728 |
+
export interface SafeConfig extends SafeFields {
|
| 729 |
+
/**
|
| 730 |
+
* Extra characters that *must* be encoded (as character references) instead
|
| 731 |
+
* of escaped (character escapes) (optional).
|
| 732 |
+
*
|
| 733 |
+
* Only ASCII punctuation will use character escapes, so you never need to
|
| 734 |
+
* pass non-ASCII-punctuation here.
|
| 735 |
+
*/
|
| 736 |
+
encode?: Array<string> | null | undefined
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
/**
|
| 740 |
+
* Info on the characters that are around the current thing we are generating.
|
| 741 |
+
*/
|
| 742 |
+
export interface SafeFields {
|
| 743 |
+
/**
|
| 744 |
+
* Characters after this (guaranteed to be one, can be more).
|
| 745 |
+
*/
|
| 746 |
+
after: string
|
| 747 |
+
/**
|
| 748 |
+
* Characters before this (guaranteed to be one, can be more).
|
| 749 |
+
*/
|
| 750 |
+
before: string
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
/**
|
| 754 |
+
* Make a string safe for embedding in markdown constructs.
|
| 755 |
+
*
|
| 756 |
+
* In markdown, almost all punctuation characters can, in certain cases,
|
| 757 |
+
* result in something.
|
| 758 |
+
* Whether they do is highly subjective to where they happen and in what
|
| 759 |
+
* they happen.
|
| 760 |
+
*
|
| 761 |
+
* To solve this, `mdast-util-to-markdown` tracks:
|
| 762 |
+
*
|
| 763 |
+
* * Characters before and after something;
|
| 764 |
+
* * What “constructs” we are in.
|
| 765 |
+
*
|
| 766 |
+
* This information is then used by this function to escape or encode
|
| 767 |
+
* special characters.
|
| 768 |
+
*
|
| 769 |
+
* @param input
|
| 770 |
+
* Raw value to make safe.
|
| 771 |
+
* @param config
|
| 772 |
+
* Configuration.
|
| 773 |
+
* @returns
|
| 774 |
+
* Serialized markdown safe for embedding.
|
| 775 |
+
*/
|
| 776 |
+
export type Safe = (
|
| 777 |
+
input: string | null | undefined,
|
| 778 |
+
config: SafeConfig
|
| 779 |
+
) => string
|
| 780 |
+
|
| 781 |
+
/**
|
| 782 |
+
* Info passed around about the current state.
|
| 783 |
+
*/
|
| 784 |
+
export interface State {
|
| 785 |
+
/**
|
| 786 |
+
* Get an identifier from an association to match it to others.
|
| 787 |
+
*/
|
| 788 |
+
associationId: AssociationId
|
| 789 |
+
/**
|
| 790 |
+
* Info on whether to encode the surrounding of *attention*.
|
| 791 |
+
*
|
| 792 |
+
* Whether attention (emphasis, strong, strikethrough) forms
|
| 793 |
+
* depends on the characters inside and outside them.
|
| 794 |
+
* The characters inside can be handled by *attention* itself.
|
| 795 |
+
* However the outside characters are already handled.
|
| 796 |
+
* Or handled afterwards.
|
| 797 |
+
* This field can be used to signal from *attention* that some parent
|
| 798 |
+
* function (practically `containerPhrasing`) has to handle the surrounding.
|
| 799 |
+
*/
|
| 800 |
+
attentionEncodeSurroundingInfo: EncodeSurrounding | undefined
|
| 801 |
+
/**
|
| 802 |
+
* List marker currently in use.
|
| 803 |
+
*/
|
| 804 |
+
bulletCurrent: string | undefined
|
| 805 |
+
/**
|
| 806 |
+
* List marker previously in use.
|
| 807 |
+
*/
|
| 808 |
+
bulletLastUsed: string | undefined
|
| 809 |
+
/**
|
| 810 |
+
* Compile an unsafe pattern to a regex.
|
| 811 |
+
*/
|
| 812 |
+
compilePattern: CompilePattern
|
| 813 |
+
/**
|
| 814 |
+
* Serialize the children of a parent that contains phrasing children.
|
| 815 |
+
*/
|
| 816 |
+
containerPhrasing: ContainerPhrasing
|
| 817 |
+
/**
|
| 818 |
+
* Serialize the children of a parent that contains flow children.
|
| 819 |
+
*/
|
| 820 |
+
containerFlow: ContainerFlow
|
| 821 |
+
/**
|
| 822 |
+
* Track positional info in the output.
|
| 823 |
+
*/
|
| 824 |
+
createTracker: CreateTracker
|
| 825 |
+
/**
|
| 826 |
+
* Enter a construct (returns a corresponding exit function).
|
| 827 |
+
*/
|
| 828 |
+
enter: Enter
|
| 829 |
+
/**
|
| 830 |
+
* Applied handlers.
|
| 831 |
+
*/
|
| 832 |
+
handlers: Handlers
|
| 833 |
+
/**
|
| 834 |
+
* Call the configured handler for the given node.
|
| 835 |
+
*/
|
| 836 |
+
handle: Handle
|
| 837 |
+
/**
|
| 838 |
+
* Pad serialized markdown.
|
| 839 |
+
*/
|
| 840 |
+
indentLines: IndentLines
|
| 841 |
+
/**
|
| 842 |
+
* Positions of child nodes in their parents.
|
| 843 |
+
*/
|
| 844 |
+
indexStack: Array<number>
|
| 845 |
+
/**
|
| 846 |
+
* Applied join handlers.
|
| 847 |
+
*/
|
| 848 |
+
join: Array<Join>
|
| 849 |
+
/**
|
| 850 |
+
* Applied user configuration.
|
| 851 |
+
*/
|
| 852 |
+
options: Options
|
| 853 |
+
/**
|
| 854 |
+
* Serialize the children of a parent that contains flow children.
|
| 855 |
+
*/
|
| 856 |
+
safe: Safe
|
| 857 |
+
/**
|
| 858 |
+
* Stack of constructs we’re in.
|
| 859 |
+
*/
|
| 860 |
+
stack: Array<ConstructName>
|
| 861 |
+
/**
|
| 862 |
+
* Applied unsafe patterns.
|
| 863 |
+
*/
|
| 864 |
+
unsafe: Array<Unsafe>
|
| 865 |
+
}
|
| 866 |
+
|
| 867 |
+
/**
|
| 868 |
+
* Get current tracked info.
|
| 869 |
+
*
|
| 870 |
+
* @returns
|
| 871 |
+
* Current tracked info.
|
| 872 |
+
*/
|
| 873 |
+
export type TrackCurrent = () => TrackFields
|
| 874 |
+
|
| 875 |
+
/**
|
| 876 |
+
* Info on where we are in the document we are generating.
|
| 877 |
+
*/
|
| 878 |
+
export interface TrackFields {
|
| 879 |
+
/**
|
| 880 |
+
* Number of columns each line will be shifted by wrapping nodes.
|
| 881 |
+
*/
|
| 882 |
+
lineShift: number
|
| 883 |
+
/**
|
| 884 |
+
* Current point.
|
| 885 |
+
*/
|
| 886 |
+
now: Point
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
/**
|
| 890 |
+
* Move past some generated markdown.
|
| 891 |
+
*
|
| 892 |
+
* @param value
|
| 893 |
+
* Generated markdown.
|
| 894 |
+
* @returns
|
| 895 |
+
* Given markdown.
|
| 896 |
+
*/
|
| 897 |
+
export type TrackMove = (value: string | null | undefined) => string
|
| 898 |
+
|
| 899 |
+
/**
|
| 900 |
+
* Define a relative increased line shift (the typical indent for lines).
|
| 901 |
+
*
|
| 902 |
+
* @param value
|
| 903 |
+
* Relative increment in how much each line will be padded.
|
| 904 |
+
* @returns
|
| 905 |
+
* Nothing.
|
| 906 |
+
*/
|
| 907 |
+
export type TrackShift = (value: number) => undefined
|
| 908 |
+
|
| 909 |
+
/**
|
| 910 |
+
* Track positional info in the output.
|
| 911 |
+
*
|
| 912 |
+
* This info isn’t used yet but such functionality will allow line wrapping,
|
| 913 |
+
* source maps, etc.
|
| 914 |
+
*/
|
| 915 |
+
export interface Tracker {
|
| 916 |
+
/**
|
| 917 |
+
* Get the current tracked info.
|
| 918 |
+
*/
|
| 919 |
+
current: TrackCurrent
|
| 920 |
+
/**
|
| 921 |
+
* Move past some generated markdown.
|
| 922 |
+
*/
|
| 923 |
+
move: TrackMove
|
| 924 |
+
/**
|
| 925 |
+
* Define an increased line shift (the typical indent for lines).
|
| 926 |
+
*/
|
| 927 |
+
shift: TrackShift
|
| 928 |
+
}
|
| 929 |
+
|
| 930 |
+
/**
|
| 931 |
+
* Schema that defines when a character cannot occur.
|
| 932 |
+
*/
|
| 933 |
+
export interface Unsafe {
|
| 934 |
+
/**
|
| 935 |
+
* The unsafe pattern (this whole object) compiled as a regex (do not use).
|
| 936 |
+
*
|
| 937 |
+
* This is internal and must not be defined.
|
| 938 |
+
*/
|
| 939 |
+
_compiled?: RegExp | null | undefined
|
| 940 |
+
/**
|
| 941 |
+
* `character` is bad when this is after it (optional).
|
| 942 |
+
*/
|
| 943 |
+
after?: string | null | undefined
|
| 944 |
+
/**
|
| 945 |
+
* `character` is bad at a break (cannot be used together with `before`) (optional).
|
| 946 |
+
*/
|
| 947 |
+
atBreak?: boolean | null | undefined
|
| 948 |
+
/**
|
| 949 |
+
* `character` is bad when this is before it (cannot be used together with
|
| 950 |
+
* `atBreak`) (optional).
|
| 951 |
+
*/
|
| 952 |
+
before?: string | null | undefined
|
| 953 |
+
/**
|
| 954 |
+
* Single unsafe character.
|
| 955 |
+
*/
|
| 956 |
+
character: string
|
| 957 |
+
/**
|
| 958 |
+
* Constructs where this is bad (optional).
|
| 959 |
+
*/
|
| 960 |
+
inConstruct?: Array<ConstructName> | ConstructName | null | undefined
|
| 961 |
+
/**
|
| 962 |
+
* Constructs where this is fine again (optional).
|
| 963 |
+
*/
|
| 964 |
+
notInConstruct?: Array<ConstructName> | ConstructName | null | undefined
|
| 965 |
+
}
|
node_modules/mdast-util-to-markdown/lib/types.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Note: types exposed from `types.d.ts`.
|
| 2 |
+
export {}
|
node_modules/mdast-util-to-markdown/lib/unsafe.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {Array<Unsafe>} */
|
| 2 |
+
export const unsafe: Array<Unsafe>;
|
| 3 |
+
import type { Unsafe } from 'mdast-util-to-markdown';
|
| 4 |
+
//# sourceMappingURL=unsafe.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/unsafe.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"unsafe.d.ts","sourceRoot":"","sources":["unsafe.js"],"names":[],"mappings":"AAqBA,4BAA4B;AAC5B,qBADW,KAAK,CAAC,MAAM,CAAC,CA4HvB;4BAhJuC,wBAAwB"}
|
node_modules/mdast-util-to-markdown/lib/unsafe.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @import {ConstructName, Unsafe} from 'mdast-util-to-markdown'
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* List of constructs that occur in phrasing (paragraphs, headings), but cannot
|
| 7 |
+
* contain things like attention (emphasis, strong), images, or links.
|
| 8 |
+
* So they sort of cancel each other out.
|
| 9 |
+
* Note: could use a better name.
|
| 10 |
+
*
|
| 11 |
+
* @type {Array<ConstructName>}
|
| 12 |
+
*/
|
| 13 |
+
const fullPhrasingSpans = [
|
| 14 |
+
'autolink',
|
| 15 |
+
'destinationLiteral',
|
| 16 |
+
'destinationRaw',
|
| 17 |
+
'reference',
|
| 18 |
+
'titleQuote',
|
| 19 |
+
'titleApostrophe'
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
/** @type {Array<Unsafe>} */
|
| 23 |
+
export const unsafe = [
|
| 24 |
+
{character: '\t', after: '[\\r\\n]', inConstruct: 'phrasing'},
|
| 25 |
+
{character: '\t', before: '[\\r\\n]', inConstruct: 'phrasing'},
|
| 26 |
+
{
|
| 27 |
+
character: '\t',
|
| 28 |
+
inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde']
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
character: '\r',
|
| 32 |
+
inConstruct: [
|
| 33 |
+
'codeFencedLangGraveAccent',
|
| 34 |
+
'codeFencedLangTilde',
|
| 35 |
+
'codeFencedMetaGraveAccent',
|
| 36 |
+
'codeFencedMetaTilde',
|
| 37 |
+
'destinationLiteral',
|
| 38 |
+
'headingAtx'
|
| 39 |
+
]
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
character: '\n',
|
| 43 |
+
inConstruct: [
|
| 44 |
+
'codeFencedLangGraveAccent',
|
| 45 |
+
'codeFencedLangTilde',
|
| 46 |
+
'codeFencedMetaGraveAccent',
|
| 47 |
+
'codeFencedMetaTilde',
|
| 48 |
+
'destinationLiteral',
|
| 49 |
+
'headingAtx'
|
| 50 |
+
]
|
| 51 |
+
},
|
| 52 |
+
{character: ' ', after: '[\\r\\n]', inConstruct: 'phrasing'},
|
| 53 |
+
{character: ' ', before: '[\\r\\n]', inConstruct: 'phrasing'},
|
| 54 |
+
{
|
| 55 |
+
character: ' ',
|
| 56 |
+
inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde']
|
| 57 |
+
},
|
| 58 |
+
// An exclamation mark can start an image, if it is followed by a link or
|
| 59 |
+
// a link reference.
|
| 60 |
+
{
|
| 61 |
+
character: '!',
|
| 62 |
+
after: '\\[',
|
| 63 |
+
inConstruct: 'phrasing',
|
| 64 |
+
notInConstruct: fullPhrasingSpans
|
| 65 |
+
},
|
| 66 |
+
// A quote can break out of a title.
|
| 67 |
+
{character: '"', inConstruct: 'titleQuote'},
|
| 68 |
+
// A number sign could start an ATX heading if it starts a line.
|
| 69 |
+
{atBreak: true, character: '#'},
|
| 70 |
+
{character: '#', inConstruct: 'headingAtx', after: '(?:[\r\n]|$)'},
|
| 71 |
+
// Dollar sign and percentage are not used in markdown.
|
| 72 |
+
// An ampersand could start a character reference.
|
| 73 |
+
{character: '&', after: '[#A-Za-z]', inConstruct: 'phrasing'},
|
| 74 |
+
// An apostrophe can break out of a title.
|
| 75 |
+
{character: "'", inConstruct: 'titleApostrophe'},
|
| 76 |
+
// A left paren could break out of a destination raw.
|
| 77 |
+
{character: '(', inConstruct: 'destinationRaw'},
|
| 78 |
+
// A left paren followed by `]` could make something into a link or image.
|
| 79 |
+
{
|
| 80 |
+
before: '\\]',
|
| 81 |
+
character: '(',
|
| 82 |
+
inConstruct: 'phrasing',
|
| 83 |
+
notInConstruct: fullPhrasingSpans
|
| 84 |
+
},
|
| 85 |
+
// A right paren could start a list item or break out of a destination
|
| 86 |
+
// raw.
|
| 87 |
+
{atBreak: true, before: '\\d+', character: ')'},
|
| 88 |
+
{character: ')', inConstruct: 'destinationRaw'},
|
| 89 |
+
// An asterisk can start thematic breaks, list items, emphasis, strong.
|
| 90 |
+
{atBreak: true, character: '*', after: '(?:[ \t\r\n*])'},
|
| 91 |
+
{character: '*', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans},
|
| 92 |
+
// A plus sign could start a list item.
|
| 93 |
+
{atBreak: true, character: '+', after: '(?:[ \t\r\n])'},
|
| 94 |
+
// A dash can start thematic breaks, list items, and setext heading
|
| 95 |
+
// underlines.
|
| 96 |
+
{atBreak: true, character: '-', after: '(?:[ \t\r\n-])'},
|
| 97 |
+
// A dot could start a list item.
|
| 98 |
+
{atBreak: true, before: '\\d+', character: '.', after: '(?:[ \t\r\n]|$)'},
|
| 99 |
+
// Slash, colon, and semicolon are not used in markdown for constructs.
|
| 100 |
+
// A less than can start html (flow or text) or an autolink.
|
| 101 |
+
// HTML could start with an exclamation mark (declaration, cdata, comment),
|
| 102 |
+
// slash (closing tag), question mark (instruction), or a letter (tag).
|
| 103 |
+
// An autolink also starts with a letter.
|
| 104 |
+
// Finally, it could break out of a destination literal.
|
| 105 |
+
{atBreak: true, character: '<', after: '[!/?A-Za-z]'},
|
| 106 |
+
{
|
| 107 |
+
character: '<',
|
| 108 |
+
after: '[!/?A-Za-z]',
|
| 109 |
+
inConstruct: 'phrasing',
|
| 110 |
+
notInConstruct: fullPhrasingSpans
|
| 111 |
+
},
|
| 112 |
+
{character: '<', inConstruct: 'destinationLiteral'},
|
| 113 |
+
// An equals to can start setext heading underlines.
|
| 114 |
+
{atBreak: true, character: '='},
|
| 115 |
+
// A greater than can start block quotes and it can break out of a
|
| 116 |
+
// destination literal.
|
| 117 |
+
{atBreak: true, character: '>'},
|
| 118 |
+
{character: '>', inConstruct: 'destinationLiteral'},
|
| 119 |
+
// Question mark and at sign are not used in markdown for constructs.
|
| 120 |
+
// A left bracket can start definitions, references, labels,
|
| 121 |
+
{atBreak: true, character: '['},
|
| 122 |
+
{character: '[', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans},
|
| 123 |
+
{character: '[', inConstruct: ['label', 'reference']},
|
| 124 |
+
// A backslash can start an escape (when followed by punctuation) or a
|
| 125 |
+
// hard break (when followed by an eol).
|
| 126 |
+
// Note: typical escapes are handled in `safe`!
|
| 127 |
+
{character: '\\', after: '[\\r\\n]', inConstruct: 'phrasing'},
|
| 128 |
+
// A right bracket can exit labels.
|
| 129 |
+
{character: ']', inConstruct: ['label', 'reference']},
|
| 130 |
+
// Caret is not used in markdown for constructs.
|
| 131 |
+
// An underscore can start emphasis, strong, or a thematic break.
|
| 132 |
+
{atBreak: true, character: '_'},
|
| 133 |
+
{character: '_', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans},
|
| 134 |
+
// A grave accent can start code (fenced or text), or it can break out of
|
| 135 |
+
// a grave accent code fence.
|
| 136 |
+
{atBreak: true, character: '`'},
|
| 137 |
+
{
|
| 138 |
+
character: '`',
|
| 139 |
+
inConstruct: ['codeFencedLangGraveAccent', 'codeFencedMetaGraveAccent']
|
| 140 |
+
},
|
| 141 |
+
{character: '`', inConstruct: 'phrasing', notInConstruct: fullPhrasingSpans},
|
| 142 |
+
// Left brace, vertical bar, right brace are not used in markdown for
|
| 143 |
+
// constructs.
|
| 144 |
+
// A tilde can start code (fenced).
|
| 145 |
+
{atBreak: true, character: '~'}
|
| 146 |
+
]
|
node_modules/mdast-util-to-markdown/lib/util/association.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export function association(node: import("mdast").Association): string;
|
| 2 |
+
//# sourceMappingURL=association.d.ts.map
|
node_modules/mdast-util-to-markdown/lib/util/association.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"association.d.ts","sourceRoot":"","sources":["association.js"],"names":[],"mappings":""}
|