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:
45
node_modules/parse-latin/lib/plugin/merge-final-word-symbol.js
generated
vendored
Normal file
45
node_modules/parse-latin/lib/plugin/merge-final-word-symbol.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @typedef {import('nlcst').Sentence} Sentence
|
||||
*/
|
||||
|
||||
import {toString} from 'nlcst-to-string'
|
||||
import {modifyChildren} from 'unist-util-modify-children'
|
||||
|
||||
// Merge certain punctuation marks into their preceding words.
|
||||
export const mergeFinalWordSymbol = modifyChildren(
|
||||
/**
|
||||
* @type {import('unist-util-modify-children').Modifier<Sentence>}
|
||||
*/
|
||||
function (child, index, parent) {
|
||||
if (
|
||||
index > 0 &&
|
||||
(child.type === 'SymbolNode' || child.type === 'PunctuationNode') &&
|
||||
toString(child) === '-'
|
||||
) {
|
||||
const children = parent.children
|
||||
const previous = children[index - 1]
|
||||
const next = children[index + 1]
|
||||
|
||||
if (
|
||||
(!next || next.type !== 'WordNode') &&
|
||||
previous &&
|
||||
previous.type === 'WordNode'
|
||||
) {
|
||||
// Remove `child` from parent.
|
||||
children.splice(index, 1)
|
||||
|
||||
// Add the punctuation mark at the end of the previous node.
|
||||
previous.children.push(child)
|
||||
|
||||
// Update position.
|
||||
if (previous.position && child.position) {
|
||||
previous.position.end = child.position.end
|
||||
}
|
||||
|
||||
// Next, iterate over the node *now* at the current position (which was
|
||||
// the next node).
|
||||
return index
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user