1
/* Copyright (c) 2006-2007, Vladimir Nikic
4
Redistribution and use of this software in source and binary forms,
5
with or without modification, are permitted provided that the following
8
* Redistributions of source code must retain the above
9
copyright notice, this list of conditions and the
12
* Redistributions in binary form must reproduce the above
13
copyright notice, this list of conditions and the
14
following disclaimer in the documentation and/or other
15
materials provided with the distribution.
17
* The name of HtmlCleaner may not be used to endorse or promote
18
products derived from this software without specific prior
21
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
POSSIBILITY OF SUCH DAMAGE.
33
You can contact Vladimir Nikic by sending e-mail to
34
nikic_vladimir@yahoo.com. Please include the word "HtmlCleaner" in the
38
package org.htmlcleaner;
43
* <p>Simple HTML serializer - creates resulting HTML without indenting and/or compacting.</p>
45
public class SimpleHtmlSerializer extends HtmlSerializer {
47
public SimpleHtmlSerializer(CleanerProperties props) {
51
protected void serialize(TagNode tagNode, Writer writer) throws IOException {
52
serializeOpenTag(tagNode, writer, false);
54
if ( !isMinimizedTagSyntax(tagNode) ) {
55
for (Object item: tagNode.getChildren()) {
56
if ( item instanceof ContentNode) {
57
String content = item.toString();
58
writer.write( dontEscape(tagNode) ? content : escapeText(content) );
59
} else if (item instanceof BaseToken) {
60
((BaseToken)item).serialize(this, writer);
64
serializeEndTag(tagNode, writer, false);