🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
31
node_modules/parse-latin/lib/plugin/patch-position.js
generated
vendored
Normal file
31
node_modules/parse-latin/lib/plugin/patch-position.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import {visitChildren} from 'unist-util-visit-children'
|
||||
|
||||
// Patch the position on a parent node based on its first and last child.
|
||||
export const patchPosition = visitChildren(function (child, index, node) {
|
||||
const siblings = node.children
|
||||
|
||||
if (!child.position) {
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
index < 1 &&
|
||||
/* c8 ignore next */
|
||||
(!node.position || !node.position.start)
|
||||
) {
|
||||
patch(node)
|
||||
node.position.start = child.position.start
|
||||
}
|
||||
|
||||
if (index === siblings.length - 1 && (!node.position || !node.position.end)) {
|
||||
patch(node)
|
||||
node.position.end = child.position.end
|
||||
}
|
||||
})
|
||||
|
||||
// Add a `position` object when it does not yet exist on `node`.
|
||||
function patch(node) {
|
||||
if (!node.position) {
|
||||
node.position = {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue