Showing posts with label prettyprint. Show all posts
Showing posts with label prettyprint. Show all posts
Thursday, May 22, 2008
HTML prettyprint, cont.
Came to realization that I am trying to anticipate browser failures from lack of whitespace, but I would know nothing about it until I start rendering a few dozen pages programmatically.
So skip the whitespace tom-foolery.
Trim all the whitespace, normalize all to spaces, just use "textwrap" to wrap nicely.
The idea, since the general algorithm has the potential to be exponential, is to use heuristics at the tips of the branches and the base of the tree, then clean up.
Then use recursive algorithm, but with checks before descending if a computation is deemed to be "likely expensive".
Going to add "minimum_total_charlength", because easy to calculate.
Why did I forget to clean "tail" along with "text"?
Labels:
exponential,
heuristic,
HTML,
prettyprint,
whitespace
Wednesday, May 21, 2008
more work on HTML prettyprint
today did not have chance to work on HTML pretty print
was going to first lay out all the "text" and "tail" in a line
seperated by the "whitespace preserving" tags
text tail text tail text text <whitespace preserving> text tail <whitespace preserving> text tailthen we have the: 1) empties 2) only whitespace 3) printing characters 4) printing characters with some whitespace at ends we only care about the whitespace that seperates printing characters, for the most part, printing characters in the "text" and seperating whitespace in the immediately following "tail" might be too much work, but, I would not be surprised if ran into issue later (all this work is not in vain, also I will need such stuff when I start programmically generating Python code, to compare my Python bytecode generation against Python's own, against the same algorithm, because of the work I am planning to do with AST, either Python's own in 2.6, or my own form)
Subscribe to:
Posts (Atom)