Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
61
node_modules/mdast-util-to-hast/lib/handlers/table.js
generated
vendored
Normal file
61
node_modules/mdast-util-to-hast/lib/handlers/table.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @typedef {import('hast').Element} Element
|
||||
* @typedef {import('mdast').Table} Table
|
||||
* @typedef {import('../state.js').State} State
|
||||
*/
|
||||
|
||||
import {pointEnd, pointStart} from 'unist-util-position'
|
||||
|
||||
/**
|
||||
* Turn an mdast `table` node into hast.
|
||||
*
|
||||
* @param {State} state
|
||||
* Info passed around.
|
||||
* @param {Table} node
|
||||
* mdast node.
|
||||
* @returns {Element}
|
||||
* hast node.
|
||||
*/
|
||||
export function table(state, node) {
|
||||
const rows = state.all(node)
|
||||
const firstRow = rows.shift()
|
||||
/** @type {Array<Element>} */
|
||||
const tableContent = []
|
||||
|
||||
if (firstRow) {
|
||||
/** @type {Element} */
|
||||
const head = {
|
||||
type: 'element',
|
||||
tagName: 'thead',
|
||||
properties: {},
|
||||
children: state.wrap([firstRow], true)
|
||||
}
|
||||
state.patch(node.children[0], head)
|
||||
tableContent.push(head)
|
||||
}
|
||||
|
||||
if (rows.length > 0) {
|
||||
/** @type {Element} */
|
||||
const body = {
|
||||
type: 'element',
|
||||
tagName: 'tbody',
|
||||
properties: {},
|
||||
children: state.wrap(rows, true)
|
||||
}
|
||||
|
||||
const start = pointStart(node.children[1])
|
||||
const end = pointEnd(node.children[node.children.length - 1])
|
||||
if (start && end) body.position = {start, end}
|
||||
tableContent.push(body)
|
||||
}
|
||||
|
||||
/** @type {Element} */
|
||||
const result = {
|
||||
type: 'element',
|
||||
tagName: 'table',
|
||||
properties: {},
|
||||
children: state.wrap(tableContent, true)
|
||||
}
|
||||
state.patch(node, result)
|
||||
return state.applyData(node, result)
|
||||
}
|
Reference in New Issue
Block a user