Permalink
Browse files

HTML: translating of HTML-entities like < added

  • Loading branch information...
1 parent 746daea commit 4a670ab691cb1d8e0b05c53e008b2ae160b8d61b void committed May 13, 2012
@@ -6,6 +6,7 @@
import org.htmlparser.Tag;
import org.htmlparser.Text;
+import org.htmlparser.util.Translate;
import org.htmlparser.visitors.NodeVisitor;
import de.lessvoid.nifty.Nifty;
@@ -224,7 +225,7 @@ private void appendText(final Text textNode) {
currentText.append(currentColor);
currentText.append("#");
}
- currentText.append(removeNewLine(textNode.getText()));
+ currentText.append(removeNewLineAndTabs(translateHTMLEntities(textNode.getText())));
}
public ElementBuilder builder() throws Exception {
@@ -331,7 +332,11 @@ private boolean isStrongTag(final Tag tag) {
return "STRONG".equals(tag.getTagName());
}
- private String removeNewLine(final String text) {
+ private String removeNewLineAndTabs(final String text) {
return text.replaceAll("\n", "").replaceAll("\t", "");
}
+
+ private String translateHTMLEntities(final String text) {
+ return Translate.decode(text);
+ }
}
@@ -1,6 +1,6 @@
<html>
<body>
-<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr,</p>
+<p>L&lt;orem ipsum dolor sit amet, consetetur sadipscing elitr,</p>
<p>dolor sit amet, consetetur sadipscing elitr, </p>
<p>dolor sit amet consetetur sadipscing </p>
<p>Lorem ipsum dolor sit </p>

0 comments on commit 4a670ab

Please sign in to comment.