Index: java/org/chromium/distiller/webdocument/WebText.java |
diff --git a/java/org/chromium/distiller/webdocument/WebText.java b/java/org/chromium/distiller/webdocument/WebText.java |
index ae81ee6f97f2d9ca41ddfa00be521cf7646ab7bb..203f0516b300e98ebf5ace2c84aea5d5d63a2b50 100644 |
--- a/java/org/chromium/distiller/webdocument/WebText.java |
+++ b/java/org/chromium/distiller/webdocument/WebText.java |
@@ -69,10 +69,16 @@ public class WebText extends WebElement { |
DomUtil.stripIds(clonedRoot); |
DomUtil.stripFontColorAttributes(clonedRoot); |
+ // Since there are tag elements that are being wrapped |
+ // by a pair of {@link WebTag}s, we only need to |
+ // get the innerHTML, otherwise these tags would be duplicated. |
+ Element elementClonedRoot = Element.as(clonedRoot); |
if (textOnly) { |
- return Element.as(clonedRoot).getInnerText(); |
+ return elementClonedRoot.getInnerText(); |
+ } else if (WebTag.canBeNested(elementClonedRoot.getTagName())) { |
+ return elementClonedRoot.getInnerHTML(); |
} |
- return Element.as(clonedRoot).getString(); |
+ return elementClonedRoot.getString(); |
} |
public List<Node> getTextNodes() { |