Skip to content

perf: match Unicode punctuation with property escapes and leave uc.micro out of markdown-exit/core - #47

Open
onmax wants to merge 1 commit into
serkodev:mainfrom
onmax:perf/punct-regex
Open

onmax wants to merge 1 commit into
serkodev:mainfrom
onmax:perf/punct-regex

Conversation

@onmax

@onmax onmax commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

follow-up to #41. related: #45

markdown-exit imports uc.micro for one check: isPunctChar, which asks whether a character is CommonMark's "Unicode punctuation", the P and S categories. uc.micro's regexes list every such character, so they're large and compress badly. /[\p{P}\p{S}]/u matches the same set, and on Node 24 (Unicode 17) it gives the same answer as uc.micro for every code point.

this switches isPunctChar to that regex. uc.micro is still re-exported as md.utils.lib.ucmicro, and it has to stay the real uc.micro, because plugins like markdown-it-abbr build non-u regexes from ucmicro.P.source. the default entry sets it on import, so markdown-exit behaves as before. markdown-exit/core no longer imports it, and reading md.utils.lib.ucmicro there throws an error that says how to set it, the same way md.linkify works since #41. the docs and a test cover both.

KiB, minified / gzip 2.1.3 this PR
markdown-exit 109.39 / 37.03 109.64 / 37.31
markdown-exit/core 98.34 / 33.96 93.37 / 31.59

esbuild 0.28, minified ESM, gzip -9.

apps on markdown-exit/core with a plugin that reads md.utils.lib.ucmicro would need to set it. and on engines with older Unicode data, \p{} could miss punctuation added in newer Unicode versions. I only checked Node 24.

@codspeed

codspeed Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing onmax:perf/punct-regex (bcae09f) with main (ac3d1ed)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant