Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Side by Side Diff: java/org/chromium/distiller/webdocument/WebTag.java

Issue 1513143006: Add <pre> to nesting tags (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: add test Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | javatests/org/chromium/distiller/ContentExtractorTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package org.chromium.distiller.webdocument; 1 package org.chromium.distiller.webdocument;
2 2
3 import java.util.HashSet; 3 import java.util.HashSet;
4 import java.util.Set; 4 import java.util.Set;
5 5
6 /** 6 /**
7 * This class represents HTML tags that need to be preserved over 7 * This class represents HTML tags that need to be preserved over
8 * the distillation process. 8 * the distillation process.
9 */ 9 */
10 public class WebTag extends WebElement { 10 public class WebTag extends WebElement {
11 private String tagName; 11 private String tagName;
12 private TagType tagType; 12 private TagType tagType;
13 13
14 public enum TagType { 14 public enum TagType {
15 START, END 15 START, END
16 } 16 }
17 17
18 private static Set<String> nestingTags; 18 private static Set<String> nestingTags;
19 static { 19 static {
20 nestingTags = new HashSet<String>(); 20 nestingTags = new HashSet<String>();
21 nestingTags.add("UL"); 21 nestingTags.add("UL");
22 nestingTags.add("OL"); 22 nestingTags.add("OL");
23 nestingTags.add("LI"); 23 nestingTags.add("LI");
24 nestingTags.add("BLOCKQUOTE"); 24 nestingTags.add("BLOCKQUOTE");
25 nestingTags.add("PRE");
25 } 26 }
26 27
27 public WebTag(String tagName, TagType tagType) { 28 public WebTag(String tagName, TagType tagType) {
28 this.tagName = tagName; 29 this.tagName = tagName;
29 this.tagType = tagType; 30 this.tagType = tagType;
30 } 31 }
31 32
32 public boolean isStartTag() { 33 public boolean isStartTag() {
33 return tagType == TagType.START; 34 return tagType == TagType.START;
34 } 35 }
35 36
36 public String getTagName() { 37 public String getTagName() {
37 return tagName; 38 return tagName;
38 } 39 }
39 40
40 @Override 41 @Override
41 public String generateOutput(boolean textOnly) { 42 public String generateOutput(boolean textOnly) {
42 if (textOnly) { 43 if (textOnly) {
43 return ""; 44 return "";
44 } 45 }
45 return "<" + (isStartTag() ? "" : "/") + tagName + ">"; 46 return "<" + (isStartTag() ? "" : "/") + tagName + ">";
46 } 47 }
47 48
48 public static boolean canBeNested(String tagName) { 49 public static boolean canBeNested(String tagName) {
49 return nestingTags.contains(tagName); 50 return nestingTags.contains(tagName);
50 } 51 }
51 } 52 }
OLDNEW
« no previous file with comments | « no previous file | javatests/org/chromium/distiller/ContentExtractorTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698