🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
33
node_modules/mdast-util-to-markdown/lib/util/association.js
generated
vendored
Normal file
33
node_modules/mdast-util-to-markdown/lib/util/association.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* @typedef {import('../types.js').AssociationId} AssociationId
|
||||
*/
|
||||
|
||||
import {decodeString} from 'micromark-util-decode-string'
|
||||
|
||||
/**
|
||||
* Get an identifier from an association to match it to others.
|
||||
*
|
||||
* Associations are nodes that match to something else through an ID:
|
||||
* <https://github.com/syntax-tree/mdast#association>.
|
||||
*
|
||||
* The `label` of an association is the string value: character escapes and
|
||||
* references work, and casing is intact.
|
||||
* The `identifier` is used to match one association to another:
|
||||
* controversially, character escapes and references don’t work in this
|
||||
* matching: `©` does not match `©`, and `\+` does not match `+`.
|
||||
*
|
||||
* But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb`
|
||||
* matches `a b`.
|
||||
* So, we do prefer the label when figuring out how we’re going to serialize:
|
||||
* it has whitespace, casing, and we can ignore most useless character
|
||||
* escapes and all character references.
|
||||
*
|
||||
* @type {AssociationId}
|
||||
*/
|
||||
export function association(node) {
|
||||
if (node.label || !node.identifier) {
|
||||
return node.label || ''
|
||||
}
|
||||
|
||||
return decodeString(node.identifier)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue