Add utils::character_reference - #981
Conversation
|
Fair enough, I agree that this is something you don't necessarily want to implement yourself. Just for binary size it might be better that we split the data into a separate crate or use the existing https://github.com/p-jackson/entities. The implementation is also rather specific to CommonMark and there are a couple cases that behave differently from HTML.. In some use cases it could be that the function is not safe for parsing actual HTML. I think the relevant chapter of the spec should be mentioned in the doc comment, or even as part of the function name. |
|
I see – you’re right about CommonMark and HTML differing. In that case, in the interests of not wanting to design a HTML parser, I don’t think this function is the best way forward. Are you okay with an |
|
Hmm.
Building the There’s a tradeoff, I suppose. I opened p-jackson/entities#14 to see what the maintainer of that crate is interested in. |
|
Yeah, on closer look it might not be a great fit for us. In addition to the different sorting and extra codepoint data, it contains some of the entities both with and without |
I am a consumer of this crate, but I’m not outputting HTML, and I would like to transform
InlineHtmlandHtmlBlocknodes according to my own needs. Writing a small HTML parser myself is easy enough, butpulldown-cmarkalready has the large table required to resolved named HTML entities, and for binary size’s sake I’d prefer to avoid duplicating all of this in my own code.Therefore, this feature request exposes the functionality of resolving HTML character references in the public API of the crate, via the
utilsmodule.While it may be nice to expose more HTML parsing, such an API would be more subjective and would be hard to make fit everybody’s needs. By contrast, this function is minimal and self-contained, and has legitimate disadvantages to users rolling their own versions of.