Skip to content

Commit 36b930b

Browse files
committed
Fix decoding identifier of association if w/o label
1 parent bed41e2 commit 36b930b

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

lib/util/association.js

+2-16
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
* @typedef {import('mdast').Association} Association
33
*/
44

5-
import {decodeEntity} from 'parse-entities/decode-entity.js'
6-
7-
const characterEscape = /\\([!-/:-@[-`{-~])/g
8-
const characterReference = /&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi
5+
import {decodeString} from 'micromark-util-decode-string'
96

107
/**
118
* The `label` of an association is the string value: character escapes and
@@ -27,16 +24,5 @@ export function association(node) {
2724
return node.label || ''
2825
}
2926

30-
return node.identifier
31-
.replace(characterEscape, '$1')
32-
.replace(characterReference, decodeIfPossible)
33-
}
34-
35-
/**
36-
* @param {string} $0
37-
* @param {string} $1
38-
* @returns {string}
39-
*/
40-
function decodeIfPossible($0, $1) {
41-
return decodeEntity($1) || $0
27+
return decodeString(node.identifier)
4228
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@types/unist": "^2.0.0",
4343
"longest-streak": "^3.0.0",
4444
"mdast-util-to-string": "^3.0.0",
45-
"parse-entities": "^3.0.0",
45+
"micromark-util-decode-string": "^1.0.0",
4646
"unist-util-visit": "^4.0.0",
4747
"zwitch": "^2.0.0"
4848
},

0 commit comments

Comments
 (0)