Open ctrlcctrlv opened 4 years ago
Thoughts?
I agree. I think the best way to reason about this is a concept of the complexity of a (sub)expression. Sufficiently complex nodes are broken up with whitespace, while less complex ones are kept on one line.
First of all, this is a great parser, thanks for writing it.
This is a follow up to #245, which taught me that
mwparserfromhell.wikicode.Wikicode.get_tree
is this library's pretty printer.It doesn't seem configurable though, and some of its output seems to be overly verbose. That is to say, in an attempt to prettify, perhaps we're making it too pretty, and therefore not pretty. 🤗
Consider the following:
Output:
Full output
Of course, I am aware that the best way to write this code is via a Lua module. Just a real-world example I found in enwiki Template:Userbox COI.
For me, "pretty" output would look more like:
It would be nice to be able to configure the indentation level, and a level of, for lack of a better term, "linebreakyness".
Thoughts?