plusparse/entities library
HTML entity and numeric character references (&, ©,
😀), decoded the CommonMark way.
Numeric references are complete. Named ones are a curated subset of the HTML5 table: the whole Latin-1 range, the Greek alphabet, and the punctuation, arrow and maths names that turn up in prose. A name outside the subset stays literal text — which is also what CommonMark does with a name that is not an entity — so the subset can only under-decode, never mis-decode.
Functions
-
decodeEntities(
String text) → String -
textwith every reference in it decoded. Used for link destinations and titles, where CommonMark decodes references too. -
entityAt(
String text, int i) → ({int next, String value})? -
The reference starting at the
&ati, decoded, and the index just past its;— or null when the text there is not a reference.