Show:

Wikitext to HTML serializer.

This serializer is designed to eventually

  • accept arbitrary HTML and
  • serialize that to wikitext in a way that round-trips back to the same HTML DOM as far as possible within the limitations of wikitext.

Not much effort has been invested so far on supporting non-Parsoid/VE-generated HTML. Some of this involves adaptively switching between wikitext and HTML representations based on the values of attributes and DOM context. A few special cases are already handled adaptively (multi-paragraph list item contents are serialized as HTML tags for example, generic A elements are serialized to HTML A tags), but in general support for this is mostly missing.

Example issue:

<h1><p>foo</p></h1> will serialize to =\nfoo\n= whereas the
       correct serialized output would be: =<p>foo</p>=

What to do about this?

  • add a generic 'can this HTML node be serialized to wikitext in this context' detection method and use that to adaptively switch between wikitext and HTML serialization.

Classes

WikitextSerializer