PublicShow sourcehtml_text.pl -- Switch between HTML and plain text output

Allow generating plain (colored) text from html//1 compatible calls. We do this in two steps, first creating a token list and next deal with state using fixup_layout/2. It would be nicer if we could avoid the latter step, but we need to maintain state such as indentation and attributes and we cannot pass that around in an additional argument as there are calls that do not know about this transformation in between.

The translation is highly specific for the calls done in html.pl. If you change CSS classes or the HTML DOM produced you likely have to make changes here as well.

To be done
- It might be better to maintain a stack of parent DOM nodes in a backtrackable global variable to deal with the state.
Source emit_as(+HTML, +Mode)//
Causes all emit//1 calls to either behave as html//1 or convert the commands to output for print_message_lines/3.
Source emitting_as(-Mode)
Current emit mode. One of plain or html
Source fixup_layout(+Tokens, -Final)
Fixup layout instructions in the token list.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

Source emit(Arg1, Arg2, Arg3)