Class EntityTable
java.lang.Object
dev.jcputney.mjml.parser.EntityTable
Maps HTML5 named entities to their numeric character references. This allows MJML content with
HTML entities to be parsed by the strict JDK XML parser which only supports XML entities
(&, <, etc).
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringreplaceEntities(String input) Replaces all known HTML named entities in the input string with their numeric character references.
-
Method Details
-
replaceEntities
Replaces all known HTML named entities in the input string with their numeric character references. XML entities (&, <, >, ', ") are left as-is since the XML parser handles them natively.This is a single-pass O(n) implementation that scans for
&characters and looks up the entity name in a hash map.- Parameters:
input- the input string potentially containing HTML named entities- Returns:
- the string with HTML named entities replaced by numeric character references
-