@@ -77,9 +77,9 @@ import {toString} from 'mdast-util-to-string'
7777import { parse } from 'micromark/lib/parse.js'
7878import { preprocess } from 'micromark/lib/preprocess.js'
7979import { postprocess } from 'micromark/lib/postprocess.js'
80+ import { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference'
8081import { normalizeIdentifier } from 'micromark-util-normalize-identifier'
8182import { codes } from 'micromark-util-symbol/codes.js'
82- import { values } from 'micromark-util-symbol/values.js'
8383import { constants } from 'micromark-util-symbol/constants.js'
8484import { types } from 'micromark-util-symbol/types.js'
8585import { decodeEntity } from 'parse-entities/decode-entity.js'
@@ -895,7 +895,7 @@ function compiler(options = {}) {
895895 let value
896896
897897 if ( type ) {
898- value = parseNumericCharacterReference (
898+ value = decodeNumericCharacterReference (
899899 data ,
900900 type === types . characterReferenceMarkerNumeric
901901 ? constants . numericBaseDecimal
@@ -1095,39 +1095,3 @@ function extension(combined, extension) {
10951095 }
10961096 }
10971097}
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