sidekick.html.parser.html
Class HtmlFormatter
java.lang.Object
sidekick.html.parser.html.HtmlVisitor
sidekick.html.parser.html.HtmlFormatter
public class HtmlFormatter
- extends HtmlVisitor
HtmlFormatter is a Visitor which traverses an HtmlDocument, dumping the
contents of the document to a specified output stream. It assumes that
the documents has been preprocessed by HtmlCollector (which matches up
beginning and end tags) and by HtmlScrubber (which formats tags in a
consistent way). In particular, HtmlScrubber should be invoked with the
TRIM_SPACES option to remove trailing spaces, which can confuse the
formatting algorithm.
The right margin and indent increment can be specified as properties.
danson:
Modified for Beauty plugin for jEdit, added ability to handle jsps. Removed
the PrintWriter from the MarginWriter as PrintWriter munges line separators
in its own weird way. For jEdit, I want the same line separator that has
been specified for the current buffer, which is not necessarily the system
line separator. Formatted content is now written to a StringBuffer and can
be retrieved with the toString method.
Did some minor modification to the handling of PRE, SCRIPT, and STYLE blocks.
Formatting once would be fine, formatting the same file a second time would
cause extra blank lines to be added just before the closing tag. This also
required some minor modification to the .jj file too.
- Author:
- Brian Goetz, Quiotix
- See Also:
HtmlVisitor,
HtmlCollector,
HtmlScrubber
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
out
protected sidekick.html.parser.html.MarginWriter out
rightMargin
protected int rightMargin
indentSize
protected int indentSize
lineSeparator
protected java.lang.String lineSeparator
tagsIndentBlock
protected static java.util.Set<java.lang.String> tagsIndentBlock
tagsNewlineBefore
protected static java.util.Set<java.lang.String> tagsNewlineBefore
tagsPreformatted
protected static java.util.Set<java.lang.String> tagsPreformatted
tagsTryMatch
protected static java.util.Set<java.lang.String> tagsTryMatch
blockRenderer
protected sidekick.html.parser.html.TagBlockRenderer blockRenderer
previousElement
protected HtmlDocument.HtmlElement previousElement
inPreBlock
protected boolean inPreBlock
HtmlFormatter
public HtmlFormatter()
throws java.lang.Exception
- Throws:
java.lang.Exception
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
setRightMargin
public void setRightMargin(int margin)
setIndent
public void setIndent(int indent)
setLineSeparator
public void setLineSeparator(java.lang.String ls)
visit
public void visit(HtmlDocument.TagBlock block)
- Overrides:
visit in class HtmlVisitor
visit
public void visit(HtmlDocument.Tag t)
- Overrides:
visit in class HtmlVisitor
visit
public void visit(HtmlDocument.EndTag t)
- Overrides:
visit in class HtmlVisitor
visit
public void visit(HtmlDocument.Comment c)
- Overrides:
visit in class HtmlVisitor
visit
public void visit(HtmlDocument.Text t)
- Overrides:
visit in class HtmlVisitor
visit
public void visit(HtmlDocument.Newline n)
- Overrides:
visit in class HtmlVisitor
start
public void start()
- Overrides:
start in class HtmlVisitor
finish
public void finish()
- Overrides:
finish in class HtmlVisitor