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

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

22
node_modules/hast-util-to-mdast/lib/all.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict'
module.exports = all
var one = require('./one')
function all(h, parent) {
var nodes = parent.children || []
var values = []
var index = -1
var result
while (++index < nodes.length) {
result = one(h, nodes[index], parent)
if (result) {
values = values.concat(result)
}
}
return values
}

10
node_modules/hast-util-to-mdast/lib/handlers/base.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
'use strict'
module.exports = base
function base(h, node) {
if (!h.baseFound) {
h.frozenBaseUrl = node.properties.href
h.baseFound = true
}
}

View File

@@ -0,0 +1,9 @@
'use strict'
module.exports = blockquote
var wrapChildren = require('../util/wrap-children')
function blockquote(h, node) {
return h(node, 'blockquote', wrapChildren(h, node))
}

View File

@@ -0,0 +1,7 @@
'use strict'
module.exports = br
function br(h, node) {
return h.wrapText ? h(node, 'break') : h(node, 'text', ' ')
}

48
node_modules/hast-util-to-mdast/lib/handlers/code.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
'use strict'
module.exports = code
var has = require('hast-util-has-property')
var convert = require('hast-util-is-element/convert')
var toText = require('hast-util-to-text')
var trim = require('trim-trailing-lines')
var wrapText = require('../util/wrap-text')
var prefix = 'language-'
var pre = convert('pre')
var isCode = convert('code')
function code(h, node) {
var children = node.children
var index = -1
var classList
var lang
if (pre(node)) {
while (++index < children.length) {
if (isCode(children[index]) && has(children[index], 'className')) {
classList = children[index].properties.className
break
}
}
}
if (classList) {
index = -1
while (++index < classList.length) {
if (classList[index].slice(0, prefix.length) === prefix) {
lang = classList[index].slice(prefix.length)
break
}
}
}
return h(
node,
'code',
{lang: lang || null, meta: null},
trim(wrapText(h, toText(node)))
)
}

View File

@@ -0,0 +1,9 @@
'use strict'
module.exports = comment
var wrapText = require('../util/wrap-text')
function comment(h, node) {
return h(node, 'html', '<!--' + wrapText(h, node.value) + '-->')
}

View File

@@ -0,0 +1,9 @@
'use strict'
module.exports = del
var all = require('../all')
function del(h, node) {
return h(node, 'delete', all(h, node))
}

98
node_modules/hast-util-to-mdast/lib/handlers/dl.js generated vendored Normal file
View File

@@ -0,0 +1,98 @@
'use strict'
module.exports = dl
var convert = require('hast-util-is-element/convert')
var spread = require('../util/list-items-spread')
var wrapListItems = require('../util/wrap-list-items')
var div = convert('div')
var dt = convert('dt')
var dd = convert('dd')
function dl(h, node) {
var children = node.children
var index = -1
var clean = []
var groups = []
var group = {titles: [], definitions: []}
var content
var child
// Unwrap `<div>`s
while (++index < children.length) {
child = children[index]
clean = clean.concat(div(child) ? child.children : child)
}
index = -1
// Group titles and definitions.
while (++index < clean.length) {
child = clean[index]
if (dt(child)) {
if (dd(clean[index - 1])) {
groups.push(group)
group = {titles: [], definitions: []}
}
group.titles.push(child)
} else {
group.definitions.push(child)
}
}
groups.push(group)
// Create items.
index = -1
content = []
while (++index < groups.length) {
group = handle(h, groups[index].titles).concat(
handle(h, groups[index].definitions)
)
if (group.length) {
content.push({
type: 'listItem',
spread: group.length > 1,
checked: null,
children: group
})
}
}
// Create a list if there are items.
if (content.length) {
return h(
node,
'list',
{ordered: false, start: null, spread: spread(content)},
content
)
}
}
function handle(h, children) {
var nodes = wrapListItems(h, {children: children})
if (!nodes.length) {
return nodes
}
if (nodes.length === 1) {
return nodes[0].children
}
return [
{
type: 'list',
ordered: false,
start: null,
spread: spread(nodes),
children: nodes
}
]
}

View File

@@ -0,0 +1,9 @@
'use strict'
module.exports = emphasis
var all = require('../all')
function emphasis(h, node) {
return h(node, 'emphasis', all(h, node))
}

View File

@@ -0,0 +1,18 @@
'use strict'
module.exports = heading
var all = require('../all')
function heading(h, node) {
/* istanbul ignore next - `else` shouldnt happen, of course… */
var depth = Number(node.tagName.charAt(1)) || 1
var wrap = h.wrapText
var result
h.wrapText = false
result = h(node, 'heading', {depth: depth}, all(h, node))
h.wrapText = wrap
return result
}

24
node_modules/hast-util-to-mdast/lib/handlers/iframe.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'use strict'
module.exports = iframe
var resolve = require('../util/resolve')
var wrapText = require('../util/wrap-text')
function iframe(h, node) {
var src = node.properties.src
var title = node.properties.title
// Only create a link if there is a title.
// We cant use the content of the frame because conforming HTML parsers treat
// it as text, whereas legacy parsers treat it as HTML, so it will likely
// contain tags that will show up in text.
if (src && title) {
return {
type: 'link',
title: null,
url: resolve(h, src),
children: [{type: 'text', value: wrapText(h, title)}]
}
}
}

13
node_modules/hast-util-to-mdast/lib/handlers/image.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict'
module.exports = image
var resolve = require('../util/resolve')
function image(h, node) {
return h(node, 'image', {
url: resolve(h, node.properties.src),
title: node.properties.title || null,
alt: node.properties.alt || ''
})
}

191
node_modules/hast-util-to-mdast/lib/handlers/index.js generated vendored Normal file
View File

@@ -0,0 +1,191 @@
'use strict'
var all = require('../all')
var wrapped = require('../util/wrap-children')
var base = require('./base')
var blockquote = require('./blockquote')
var br = require('./break')
var code = require('./code')
var comment = require('./comment')
var del = require('./delete')
var dl = require('./dl')
var emphasis = require('./emphasis')
var heading = require('./heading')
var iframe = require('./iframe')
var image = require('./image')
var inlineCode = require('./inline-code')
var input = require('./input')
var link = require('./link')
var listItem = require('./list-item')
var list = require('./list')
var media = require('./media')
var paragraph = require('./paragraph')
var quote = require('./q')
var root = require('./root')
var select = require('./select')
var strong = require('./strong')
var cell = require('./table-cell')
var row = require('./table-row')
var table = require('./table')
var text = require('./text')
var textarea = require('./textarea')
var thematicBreak = require('./thematic-break')
var wbr = require('./wbr')
exports.root = root
exports.text = text
exports.comment = comment
exports.doctype = ignore
exports.applet = ignore
exports.area = ignore
exports.basefont = ignore
exports.bgsound = ignore
exports.caption = ignore
exports.col = ignore
exports.colgroup = ignore
exports.command = ignore
exports.content = ignore
exports.datalist = ignore
exports.dialog = ignore
exports.element = ignore
exports.embed = ignore
exports.frame = ignore
exports.frameset = ignore
exports.isindex = ignore
exports.keygen = ignore
exports.link = ignore
exports.math = ignore
exports.menu = ignore
exports.menuitem = ignore
exports.meta = ignore
exports.nextid = ignore
exports.noembed = ignore
exports.noframes = ignore
exports.optgroup = ignore
exports.option = ignore
exports.param = ignore
exports.script = ignore
exports.shadow = ignore
exports.source = ignore
exports.spacer = ignore
exports.style = ignore
exports.svg = ignore
exports.template = ignore
exports.title = ignore
exports.track = ignore
exports.abbr = all
exports.acronym = all
exports.bdi = all
exports.bdo = all
exports.big = all
exports.blink = all
exports.button = all
exports.canvas = all
exports.cite = all
exports.data = all
exports.details = all
exports.dfn = all
exports.font = all
exports.ins = all
exports.label = all
exports.map = all
exports.marquee = all
exports.meter = all
exports.nobr = all
exports.noscript = all
exports.object = all
exports.output = all
exports.progress = all
exports.rb = all
exports.rbc = all
exports.rp = all
exports.rt = all
exports.rtc = all
exports.ruby = all
exports.slot = all
exports.small = all
exports.span = all
exports.sup = all
exports.sub = all
exports.tbody = all
exports.tfoot = all
exports.thead = all
exports.time = all
exports.address = wrapped
exports.article = wrapped
exports.aside = wrapped
exports.body = wrapped
exports.center = wrapped
exports.div = wrapped
exports.fieldset = wrapped
exports.figcaption = wrapped
exports.figure = wrapped
exports.form = wrapped
exports.footer = wrapped
exports.header = wrapped
exports.hgroup = wrapped
exports.html = wrapped
exports.legend = wrapped
exports.main = wrapped
exports.multicol = wrapped
exports.nav = wrapped
exports.picture = wrapped
exports.section = wrapped
exports.a = link
exports.audio = media
exports.b = strong
exports.base = base
exports.blockquote = blockquote
exports.br = br
exports.code = inlineCode
exports.dir = list
exports.dl = dl
exports.dt = listItem
exports.dd = listItem
exports.del = del
exports.em = emphasis
exports.h1 = heading
exports.h2 = heading
exports.h3 = heading
exports.h4 = heading
exports.h5 = heading
exports.h6 = heading
exports.hr = thematicBreak
exports.i = emphasis
exports.iframe = iframe
exports.img = image
exports.image = image
exports.input = input
exports.kbd = inlineCode
exports.li = listItem
exports.listing = code
exports.mark = emphasis
exports.ol = list
exports.p = paragraph
exports.plaintext = code
exports.pre = code
exports.q = quote
exports.s = del
exports.samp = inlineCode
exports.select = select
exports.strike = del
exports.strong = strong
exports.summary = paragraph
exports.table = table
exports.td = cell
exports.textarea = textarea
exports.th = cell
exports.tr = row
exports.tt = inlineCode
exports.u = emphasis
exports.ul = list
exports.var = inlineCode
exports.video = media
exports.wbr = wbr
exports.xmp = code
function ignore() {}

View File

@@ -0,0 +1,10 @@
'use strict'
module.exports = inlineCode
var toText = require('hast-util-to-text')
var wrapText = require('../util/wrap-text')
function inlineCode(h, node) {
return h(node, 'inlineCode', wrapText(h, toText(node)))
}

105
node_modules/hast-util-to-mdast/lib/handlers/input.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
'use strict'
module.exports = input
var convert = require('hast-util-is-element/convert')
var repeat = require('repeat-string')
var findSelectedOptions = require('../util/find-selected-options')
var own = require('../util/own')
var resolve = require('../util/resolve')
var wrapText = require('../util/wrap-text')
var datalist = convert('datalist')
function input(h, node) {
var props = node.properties
var value = props.value || props.placeholder
var results = []
var values = []
var index = -1
var list
if (props.disabled || props.type === 'hidden' || props.type === 'file') {
return
}
if (props.type === 'checkbox' || props.type === 'radio') {
return h(
node,
'text',
wrapText(h, h[props.checked ? 'checked' : 'unchecked'])
)
}
if (props.type === 'image') {
return props.alt || value
? h(node, 'image', {
url: resolve(h, props.src),
title: (props.title && wrapText(h, props.title)) || null,
alt: wrapText(h, props.alt || value)
})
: []
}
if (value) {
values = [[value]]
} else if (
// `list` is not supported on these types:
props.type !== 'password' &&
props.type !== 'file' &&
props.type !== 'submit' &&
props.type !== 'reset' &&
props.type !== 'button' &&
props.list
) {
list = String(props.list).toUpperCase()
if (own.call(h.nodeById, list) && datalist(h.nodeById[list])) {
values = findSelectedOptions(h, h.nodeById[list], props)
}
}
if (!values.length) {
return
}
// Hide password value.
if (props.type === 'password') {
// Passwords dont support `list`.
values[0] = [repeat('•', values[0][0].length)]
}
if (props.type === 'url' || props.type === 'email') {
while (++index < values.length) {
value = resolve(h, values[index][0])
results.push(
h(
node,
'link',
{
title: null,
url: wrapText(h, props.type === 'email' ? 'mailto:' + value : value)
},
[{type: 'text', value: wrapText(h, values[index][1] || value)}]
)
)
if (index !== values.length - 1) {
results.push({type: 'text', value: ', '})
}
}
return results
}
while (++index < values.length) {
results.push(
values[index][1]
? values[index][1] + ' (' + values[index][0] + ')'
: values[index][0]
)
}
return h(node, 'text', wrapText(h, results.join(', ')))
}

18
node_modules/hast-util-to-mdast/lib/handlers/link.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict'
module.exports = link
var all = require('../all')
var resolve = require('../util/resolve')
function link(h, node) {
return h(
node,
'link',
{
title: node.properties.title || null,
url: resolve(h, node.properties.href)
},
all(h, node)
)
}

View File

@@ -0,0 +1,45 @@
'use strict'
module.exports = listItem
var convert = require('hast-util-is-element/convert')
var shallow = require('../util/shallow')
var wrapChildren = require('../util/wrap-children')
var p = convert('p')
var input = convert('input')
function listItem(h, node) {
var head = node.children[0]
var checked = null
var content
var checkbox
var clone
var headClone
// Check if this node starts with a checkbox.
if (p(head)) {
checkbox = head.children[0]
if (
input(checkbox) &&
(checkbox.properties.type === 'checkbox' ||
checkbox.properties.type === 'radio')
) {
checked = Boolean(checkbox.properties.checked)
headClone = shallow(head)
headClone.children = head.children.slice(1)
clone = shallow(node)
clone.children = [headClone].concat(node.children.slice(1))
}
}
content = wrapChildren(h, clone || node)
return h(
node,
'listItem',
{spread: content.length > 1, checked: checked},
content
)
}

27
node_modules/hast-util-to-mdast/lib/handlers/list.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
'use strict'
module.exports = list
var convert = require('hast-util-is-element/convert')
var has = require('hast-util-has-property')
var spread = require('../util/list-items-spread')
var wrapListItems = require('../util/wrap-list-items')
var ol = convert('ol')
function list(h, node) {
var ordered = ol(node)
var children = wrapListItems(h, node)
var start = null
if (ordered) {
start = has(node, 'start') ? node.properties.start : 1
}
return h(
node,
'list',
{ordered: ordered, start: start, spread: spread(children)},
children
)
}

60
node_modules/hast-util-to-mdast/lib/handlers/media.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
'use strict'
module.exports = media
var convert = require('hast-util-is-element/convert')
var toString = require('mdast-util-to-string')
var visit = require('unist-util-visit')
var all = require('../all')
var resolve = require('../util/resolve')
var wrap = require('../util/wrap')
var source = convert('source')
var video = convert('video')
function media(h, node) {
var nodes = all(h, node)
var poster = video(node) && node.properties.poster
var src = node.properties.src
var index = -1
var linkInFallbackContent
visit({type: 'root', children: nodes}, 'link', findLink)
// If the content links to something, or if its not phrasing…
if (linkInFallbackContent || wrap.needed(nodes)) {
return nodes
}
// Find the source.
while (!src && ++index < node.children.length) {
if (source(node.children[index])) {
src = node.children[index].properties.src
}
}
// If theres a poster defined on the video, create an image.
if (poster) {
nodes = [
{
type: 'image',
title: null,
url: resolve(h, poster),
alt: toString({children: nodes})
}
]
}
// Link to the media resource.
return {
type: 'link',
title: node.properties.title || null,
url: resolve(h, src),
children: nodes
}
function findLink() {
linkInFallbackContent = true
return visit.EXIT
}
}

View File

@@ -0,0 +1,13 @@
'use strict'
module.exports = paragraph
var all = require('../all')
function paragraph(h, node) {
var nodes = all(h, node)
if (nodes.length) {
return h(node, 'paragraph', nodes)
}
}

23
node_modules/hast-util-to-mdast/lib/handlers/q.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
'use strict'
module.exports = q
var all = require('../all')
function q(h, node) {
var expected = h.quotes[h.qNesting % h.quotes.length]
var contents
h.qNesting++
contents = all(h, node)
h.qNesting--
contents.unshift({type: 'text', value: expected.charAt(0)})
contents.push({
type: 'text',
value: expected.length > 1 ? expected.charAt(1) : expected
})
return contents
}

16
node_modules/hast-util-to-mdast/lib/handlers/root.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict'
module.exports = root
var all = require('../all')
var wrap = require('../util/wrap')
function root(h, node) {
var children = all(h, node)
if (h.document || wrap.needed(children)) {
children = wrap(children)
}
return h(node, 'root', children)
}

22
node_modules/hast-util-to-mdast/lib/handlers/select.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict'
module.exports = select
var findSelectedOptions = require('../util/find-selected-options')
var wrapText = require('../util/wrap-text')
function select(h, node) {
var values = findSelectedOptions(h, node)
var index = -1
var results = []
var value
while (++index < values.length) {
value = values[index]
results.push(value[1] ? value[1] + ' (' + value[0] + ')' : value[0])
}
if (results.length) {
return h(node, 'text', wrapText(h, results.join(', ')))
}
}

View File

@@ -0,0 +1,9 @@
'use strict'
module.exports = strong
var all = require('../all')
function strong(h, node) {
return h(node, 'strong', all(h, node))
}

View File

@@ -0,0 +1,16 @@
'use strict'
module.exports = cell
var all = require('../all')
function cell(h, node) {
var wrap = h.wrapText
var result
h.wrapText = false
result = h(node, 'tableCell', all(h, node))
h.wrapText = wrap
return result
}

View File

@@ -0,0 +1,9 @@
'use strict'
module.exports = row
var all = require('../all')
function row(h, node) {
return h(node, 'tableRow', all(h, node))
}

135
node_modules/hast-util-to-mdast/lib/handlers/table.js generated vendored Normal file
View File

@@ -0,0 +1,135 @@
'use strict'
module.exports = table
var convert = require('hast-util-is-element/convert')
var visit = require('unist-util-visit')
var all = require('../all')
var thead = convert('thead')
var tr = convert('tr')
var cell = convert(['th', 'td'])
function table(h, node) {
var info = inspect(node)
return h(node, 'table', {align: info.align}, toRows(all(h, node), info))
}
// Infer whether the HTML table has a head and how it aligns.
function inspect(node) {
var headless = true
var align = [null]
var rowIndex = 0
var cellIndex = 0
visit(node, 'element', visitor)
return {align: align, headless: headless}
function visitor(child) {
// If there is a `thead`, assume there is a header row.
if (thead(child)) {
headless = false
} else if (tr(child)) {
rowIndex++
cellIndex = 0
} else if (cell(child)) {
if (!align[cellIndex]) {
align[cellIndex] = child.properties.align || null
}
// If there is a th in the first row, assume there is a header row.
if (headless && rowIndex < 2 && child.tagName === 'th') {
headless = false
}
cellIndex++
}
}
}
// Ensure the rows are properly structured.
function toRows(children, info) {
var nodes = []
var index = -1
var node
var queue
// Add an empty header row.
if (info.headless) {
nodes.push({type: 'tableRow', children: []})
}
while (++index < children.length) {
node = children[index]
if (node.type === 'tableRow') {
if (queue) {
node.children = queue.concat(node.children)
queue = undefined
}
nodes.push(node)
} else {
if (!queue) queue = []
queue.push(node)
}
}
if (queue) {
node = nodes[nodes.length - 1]
node.children = node.children.concat(queue)
}
index = -1
while (++index < nodes.length) {
node = nodes[index]
node.children = toCells(node.children, info)
}
return nodes
}
// Ensure the cells in a row are properly structured.
function toCells(children, info) {
var nodes = []
var index = -1
var node
var queue
while (++index < children.length) {
node = children[index]
if (node.type === 'tableCell') {
if (queue) {
node.children = queue.concat(node.children)
queue = undefined
}
nodes.push(node)
} else {
if (!queue) queue = []
queue.push(node)
}
}
if (queue) {
node = nodes[nodes.length - 1]
if (!node) {
node = {type: 'tableCell', children: []}
nodes.push(node)
}
node.children = node.children.concat(queue)
}
index = nodes.length - 1
while (++index < info.align.length) {
nodes.push({type: 'tableCell', children: []})
}
return nodes
}

9
node_modules/hast-util-to-mdast/lib/handlers/text.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
'use strict'
module.exports = text
var wrapText = require('../util/wrap-text')
function text(h, node) {
return h(node, 'text', wrapText(h, node.value))
}

View File

@@ -0,0 +1,10 @@
'use strict'
module.exports = textarea
var toText = require('hast-util-to-text')
var wrapText = require('../util/wrap-text')
function textarea(h, node) {
return h(node, 'text', wrapText(h, toText(node)))
}

View File

@@ -0,0 +1,7 @@
'use strict'
module.exports = thematicBreak
function thematicBreak(h, node) {
return h(node, 'thematicBreak')
}

7
node_modules/hast-util-to-mdast/lib/handlers/wbr.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
'use strict'
module.exports = wbr
function wbr(h, node) {
return h(node, 'text', '\u200b')
}

33
node_modules/hast-util-to-mdast/lib/one.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict'
module.exports = one
var all = require('./all')
var own = require('./util/own')
var wrapText = require('./util/wrap-text')
function one(h, node, parent) {
var fn
if (node.type === 'element') {
if (node.properties && node.properties.dataMdast === 'ignore') {
return
}
if (own.call(h.handlers, node.tagName)) {
fn = h.handlers[node.tagName]
}
} else if (own.call(h.handlers, node.type)) {
fn = h.handlers[node.type]
}
return (typeof fn === 'function' ? fn : unknown)(h, node, parent)
}
function unknown(h, node) {
if (node.value) {
return h(node, 'text', wrapText(h, node.value))
}
return all(h, node)
}

View File

@@ -0,0 +1,66 @@
'use strict'
var has = require('hast-util-has-property')
var convert = require('hast-util-is-element/convert')
var toText = require('hast-util-to-text')
var wrapText = require('./wrap-text')
module.exports = findSelectedOptions
var option = convert('option')
function findSelectedOptions(h, node, properties) {
var props = properties || node.properties
var options = findOptions(node)
var size = Math.min(parseInt(props.size, 10), 0) || (props.multiple ? 4 : 1)
var index = -1
var selectedOptions = []
var values = []
var option
var list
var content
var label
var value
while (++index < options.length) {
if (has(options[index], 'selected')) {
selectedOptions.push(options[index])
}
}
list = selectedOptions.length ? selectedOptions : options
options = list.slice(0, size)
index = -1
while (++index < options.length) {
option = options[index]
content = wrapText(h, toText(option))
label = content || option.properties.label
value = option.properties.value || content
values.push([value, label === value ? null : label])
}
return values
}
function findOptions(node) {
var children = node.children
var index = -1
var results = []
var child
while (++index < children.length) {
child = children[index]
if (option(child)) {
if (!has(child, 'disabled')) {
results.push(child)
}
} else if (child.children) {
results = results.concat(findOptions(child))
}
}
return results
}

View File

@@ -0,0 +1,17 @@
'use strict'
module.exports = spread
function spread(children) {
var index = -1
if (children.length > 1) {
while (++index < children.length) {
if (children[index].spread) {
return true
}
}
}
return false
}

3
node_modules/hast-util-to-mdast/lib/util/own.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict'
module.exports = {}.hasOwnProperty

16
node_modules/hast-util-to-mdast/lib/util/resolve.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict'
module.exports = resolve
function resolve(h, url) {
if (url === null || url === undefined) {
return ''
}
/* istanbul ignore next - ignored for older Node */
if (h.frozenBaseUrl && typeof URL !== 'undefined') {
return String(new URL(url, h.frozenBaseUrl))
}
return url
}

19
node_modules/hast-util-to-mdast/lib/util/shallow.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
'use strict'
module.exports = shallow
var own = require('./own')
// Shallow copy of a node, excluding its children.
function shallow(node) {
var copy = {}
var key
for (key in node) {
if (own.call(node, key) && key !== 'children') {
copy[key] = node[key]
}
}
return copy
}

View File

@@ -0,0 +1,10 @@
'use strict'
module.exports = wrapped
var all = require('../all')
var wrap = require('./wrap')
function wrapped(h, node) {
return wrap(all(h, node))
}

View File

@@ -0,0 +1,23 @@
'use strict'
module.exports = wrapListItems
var all = require('../all')
function wrapListItems(h, node) {
var children = all(h, node)
var index = -1
while (++index < children.length) {
if (children[index].type !== 'listItem') {
children[index] = {
type: 'listItem',
spread: false,
checked: null,
children: [children[index]]
}
}
}
return children
}

View File

@@ -0,0 +1,7 @@
'use strict'
module.exports = wrapText
function wrapText(h, value) {
return h.wrapText ? value : value.replace(/\r?\n|\r/g, ' ')
}

133
node_modules/hast-util-to-mdast/lib/util/wrap.js generated vendored Normal file
View File

@@ -0,0 +1,133 @@
'use strict'
module.exports = wrap
wrap.needed = needed
var extend = require('extend')
var phrasing = require('mdast-util-phrasing')
var shallow = require('./shallow')
function wrap(nodes) {
return runs(nodes, onphrasing)
function onphrasing(nodes) {
var head = nodes[0]
if (
nodes.length === 1 &&
head.type === 'text' &&
(head.value === ' ' || head.value === '\n')
) {
return []
}
return {type: 'paragraph', children: nodes}
}
}
// Wrap all runs of mdast phrasing content in `paragraph` nodes.
function runs(nodes, onphrasing, onnonphrasing) {
var nonphrasing = onnonphrasing || identity
var flattened = flatten(nodes)
var result = []
var index = -1
var node
var queue
while (++index < flattened.length) {
node = flattened[index]
if (phrasing(node)) {
if (!queue) queue = []
queue.push(node)
} else {
if (queue) {
result = result.concat(onphrasing(queue))
queue = undefined
}
result = result.concat(nonphrasing(node))
}
}
if (queue) {
result = result.concat(onphrasing(queue))
}
return result
}
// Flatten a list of nodes.
function flatten(nodes) {
var flattened = []
var index = -1
var node
while (++index < nodes.length) {
node = nodes[index]
// Straddling: some elements are *weird*.
// Namely: `map`, `ins`, `del`, and `a`, as they are hybrid elements.
// See: <https://html.spec.whatwg.org/#paragraphs>.
// Paragraphs are the weirdest of them all.
// See the straddling fixture for more info!
// `ins` is ignored in mdast, so we dont need to worry about that.
// `map` maps to its content, so we dont need to worry about that either.
// `del` maps to `delete` and `a` to `link`, so we do handle those.
// What well do is split `node` over each of its children.
if (
(node.type === 'delete' || node.type === 'link') &&
needed(node.children)
) {
flattened = flattened.concat(split(node))
} else {
flattened.push(node)
}
}
return flattened
}
// Check if there are non-phrasing mdast nodes returned.
// This is needed if a fragment is given, which could just be a sentence, and
// doesnt need a wrapper paragraph.
function needed(nodes) {
var index = -1
var node
while (++index < nodes.length) {
node = nodes[index]
if (!phrasing(node) || (node.children && needed(node.children))) {
return true
}
}
}
function split(node) {
return runs(node.children, onphrasing, onnonphrasing)
// Use `child`, add `parent` as its first child, put the original children
// into `parent`.
function onnonphrasing(child) {
var parent = extend(true, {}, shallow(node))
var copy = shallow(child)
copy.children = [parent]
parent.children = child.children
return copy
}
// Use `parent`, put the phrasing run inside it.
function onphrasing(nodes) {
var parent = extend(true, {}, shallow(node))
parent.children = nodes
return parent
}
}
function identity(n) {
return n
}