Files
wehub-resource-sync f877c37fc6
tests / Test (windows-latest, 3.13) (push) Blocked by required conditions
tests / Test (windows-latest, 3.14) (push) Blocked by required conditions
tests / Validate (push) Waiting to run
tests / Test (macos-latest, 3.10) (push) Blocked by required conditions
tests / Test (macos-latest, 3.11) (push) Blocked by required conditions
tests / Test (macos-latest, 3.12) (push) Blocked by required conditions
tests / Test (macos-latest, 3.13) (push) Blocked by required conditions
tests / Test (macos-latest, 3.14) (push) Blocked by required conditions
tests / Test (ubuntu-latest, 3.10) (push) Blocked by required conditions
tests / Test (ubuntu-latest, 3.11) (push) Blocked by required conditions
tests / Test (ubuntu-latest, 3.12) (push) Blocked by required conditions
tests / Test (ubuntu-latest, 3.13) (push) Blocked by required conditions
tests / Test (ubuntu-latest, 3.14) (push) Blocked by required conditions
tests / Test (windows-latest, 3.10) (push) Blocked by required conditions
tests / Test (windows-latest, 3.11) (push) Blocked by required conditions
tests / Test (windows-latest, 3.12) (push) Blocked by required conditions
universe validation / Validate (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:37:51 +08:00

39 lines
942 B
JavaScript

import getProps from './getProps.mjs'
const handleNode = (node) => {
if (node.type === 'section' && node.children) {
return {
...node,
children: node.children.map(handleNode),
}
}
if (node.type !== 'heading' || !node.children || node.children < 2) {
return node
}
const indexLast = node.children.length - 1
const lastNode = node.children[indexLast]
if (lastNode.type !== 'mdxTextExpression' || !lastNode.data || !lastNode.data.estree) {
return node
}
const data = node.data || (node.data = {})
data.hProperties = getProps(lastNode.data.estree)
// Only keep the text, drop the rest
node.children = [node.children[0]]
return node
}
const parseAstTree = (markdownAST) => ({
...markdownAST,
children: markdownAST.children.map(handleNode),
})
const remarkCustomAttrs = () => parseAstTree
export default remarkCustomAttrs