Open obecker opened 3 years ago
I like this idea. I'd take it further for the Indenter and say that we don't need to pass in the text anymore. We'd just need to represent the indentation itself: Indentation.append(int level, Appendable out)
since the text can be appended by the caller at some point in the future.
I think it is worth focusing on 2.0 right now; to clean away the deprecated items and fix the API difficulties that we've come to recognize over the past few months.
I'd take it further for the Indenter and say that we don't need to pass in the text anymore. We'd just need to represent the indentation itself:
Indentation.append(int level, Appendable out)
since the text can be appended by the caller at some point in the future.
Yes, definitely. Otherwise it would be difficult to combine the two aspects (the indented text needs also to be escaped).
Concerning the TextEscaper
: another possibility would be to wrap or decorate the given Appendable
by an EscapingAppendable
when writing text contents and attribute values.
The performance of the rendering process can be improved by
TextEscaper
interface method tovoid appendEscaped(Appendable out, String text);
- thus preventing the intermediate step of creating a new String containing the escaped textIndenter
interface method tovoid appendIndented(Appendable out, int level, String text);
- same idea: don't create a temporary string, but write indent and text directly toout
I'm not sure if this can be realized in a backward compatible way - so probably this is something for 2.0