Urara-Blog/node_modules/.pnpm-store/v3/files/5c/30d84298d8bc6dd7d174e7c179732712c1cb84e7dbbb0a17c9e804eaad1e2db976170da693080d5f621fd18186662b5df16e2965ff2ddce5340807b4df8650
2022-08-14 01:14:53 +08:00

28 lines
948 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @typedef {import('mdast').Association} Association
*/
import {decodeString} from 'micromark-util-decode-string'
/**
* 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 dont 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 were going to serialize:
* it has whitespace, casing, and we can ignore most useless character escapes
* and all character references.
*
* @param {Association} node
* @returns {string}
*/
export function association(node) {
if (node.label || !node.identifier) {
return node.label || ''
}
return decodeString(node.identifier)
}