@@ -77,9 +77,9 @@ import {toString} from 'mdast-util-to-string'
77
77
import { parse } from 'micromark/lib/parse.js'
78
78
import { preprocess } from 'micromark/lib/preprocess.js'
79
79
import { postprocess } from 'micromark/lib/postprocess.js'
80
+ import { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference'
80
81
import { normalizeIdentifier } from 'micromark-util-normalize-identifier'
81
82
import { codes } from 'micromark-util-symbol/codes.js'
82
- import { values } from 'micromark-util-symbol/values.js'
83
83
import { constants } from 'micromark-util-symbol/constants.js'
84
84
import { types } from 'micromark-util-symbol/types.js'
85
85
import { decodeEntity } from 'parse-entities/decode-entity.js'
@@ -895,7 +895,7 @@ function compiler(options = {}) {
895
895
let value
896
896
897
897
if ( type ) {
898
- value = parseNumericCharacterReference (
898
+ value = decodeNumericCharacterReference (
899
899
data ,
900
900
type === types . characterReferenceMarkerNumeric
901
901
? constants . numericBaseDecimal
@@ -1095,39 +1095,3 @@ function extension(combined, extension) {
1095
1095
}
1096
1096
}
1097
1097
}
1098
-
1099
- // To do: externalize this from `micromark/lib/compile`
1100
- /**
1101
- * Turn the number (in string form as either hexa- or plain decimal) coming from
1102
- * a numeric character reference into a character.
1103
- *
1104
- * @param {string } value
1105
- * @param {number } base
1106
- * @returns {string }
1107
- */
1108
- function parseNumericCharacterReference ( value , base ) {
1109
- const code = Number . parseInt ( value , base )
1110
-
1111
- if (
1112
- // C0 except for HT, LF, FF, CR, space
1113
- code < codes . ht ||
1114
- code === codes . vt ||
1115
- ( code > codes . cr && code < codes . space ) ||
1116
- // Control character (DEL) of the basic block and C1 controls.
1117
- ( code > codes . tilde && code < 160 ) ||
1118
- // Lone high surrogates and low surrogates.
1119
- /* c8 ignore next */
1120
- ( code > 55295 && code < 57344 ) ||
1121
- // Noncharacters.
1122
- /* c8 ignore next */
1123
- ( code > 64975 && code < 65008 ) ||
1124
- ( code & 65535 ) === 65535 ||
1125
- ( code & 65535 ) === 65534 ||
1126
- // Out of range
1127
- code > 1114111
1128
- ) {
1129
- return values . replacementCharacter
1130
- }
1131
-
1132
- return String . fromCharCode ( code )
1133
- }
0 commit comments