@OVasileva (WMF): Just to note that those examples are from enwiki. HTML previews are only enabled on the Beta Cluster wikifarm. This may explain the behavior in your last two examples.
Now, the chem template produces span
s with inline styles, not super- or subscript tags (sup
and sub
respectively). For the former case, TextExtracts will strip the inline styles from the span
, thus losing its formatting; for the latter case, TextExtracts will preserve the tags.
The reason that the chem template produces span
s with inline styles is so that it can correctly format things like charge. Consider the example in the template's documentation: if the template were to produce sup
and sub
tags, then the 4 and 2- in the example wouldn't be above and below one another.
I see two ways of solving this.
- The chem template does wrap its output in a
span class="chemf"
element. We could disable the inline style stripping behavior for this wrapper element and its children.
- Create a
page-preview-preserve
or pp-preserve
class, which, like the above, would disable all stripping behavior in the API for this element. We'd then ask the chem template author(s) to use the class in their template.
I'm leaning towards something like #2 as it'd also allow editors to mark, say, parentheticals that they want preserved in the preview… OTOH #1 would be quicker to implement but puts the burden of finding and adding exceptions to the whitelist firmly on the maintainers of Popups.
Also, I've updated the spec to add an exception for sup
and sub
tags.