Closed gpbmike closed 3 years ago
Maybe we should allow configuration to override the ordering.
Is there a case to maintain separate 'sanitize' and 'normalize' phases? Could all HTMLFormatters be run in the order they are added?
scribe.use(firstFormatter);
scribe.use(secondFormatter);
I'm trying to use the sanitizer plugin together with the semantic elements plugin. The sanitizer plugin runs during the 'sanitize' phase before the semantic elements plugin runs in the 'normalize' phase.
https://github.com/guardian/scribe/blob/a62186405271aa52c131ab8313a4f5f027096d6d/src/scribe.js#L322-L330
My problem is that if I pass
<p><b>hello</b></p>
into Scribe, the sanitizer plugin (withstrong
whitelisted, but notb
) will be run first and strip out the italics tag resulting in<p>hello</p>
. Ideally I would be able to switch out the<b>
tag for a<strong>
tag before the sanitize phase. If I whitelist bothstrong
andb
,<p><strong>hello</strong><p>
is the result but that doesn't feel right. Is that the best way? Any suggestions?