59 |
private MemberDoc contextMember; |
private MemberDoc contextMember; |
60 |
private StringBuffer output = new StringBuffer(); |
private StringBuffer output = new StringBuffer(); |
61 |
private Stack tagStack = new Stack(); |
private Stack tagStack = new Stack(); |
62 |
|
private boolean isLeadingTag = true; |
63 |
|
private boolean throwAwayLeadingPara = false; |
64 |
|
|
65 |
private static Map tagInfoMap; |
private static Map tagInfoMap; |
66 |
|
|
77 |
|
|
78 |
public HtmlRepairer(DocErrorReporter warningReporter, |
public HtmlRepairer(DocErrorReporter warningReporter, |
79 |
boolean noWarn, boolean noEmailWarn, |
boolean noWarn, boolean noEmailWarn, |
80 |
ClassDoc contextClass, MemberDoc contextMember) { |
ClassDoc contextClass, MemberDoc contextMember, |
81 |
|
boolean throwAwayLeadingPara) { |
82 |
this.warningReporter = warningReporter; |
this.warningReporter = warningReporter; |
83 |
this.noWarn = noWarn; |
this.noWarn = noWarn; |
84 |
this.noEmailWarn = noEmailWarn; |
this.noEmailWarn = noEmailWarn; |
85 |
this.contextClass = contextClass; |
this.contextClass = contextClass; |
86 |
this.contextMember = contextMember; |
this.contextMember = contextMember; |
87 |
|
this.throwAwayLeadingPara = throwAwayLeadingPara; |
88 |
} |
} |
89 |
|
|
90 |
private static String replaceStr(String haystack, String needle, String replacement) { |
private static String replaceStr(String haystack, String needle, String replacement) { |
98 |
|
|
99 |
private void haveText(String text) { |
private void haveText(String text) { |
100 |
|
|
101 |
|
if (isLeadingTag && throwAwayLeadingPara) { |
102 |
|
if (0 != text.trim().length()) { |
103 |
|
isLeadingTag = false; |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
text = replaceStr(text, "<1", "<1"); |
text = replaceStr(text, "<1", "<1"); |
108 |
text = replaceStr(text, "&&", "&&"); |
text = replaceStr(text, "&&", "&&"); |
109 |
text = replaceStr(text, "& ", "& "); |
text = replaceStr(text, "& ", "& "); |
118 |
|
|
119 |
private void haveStartOrEndTag(String tag) { |
private void haveStartOrEndTag(String tag) { |
120 |
|
|
121 |
|
boolean _isLeadingTag = isLeadingTag; |
122 |
|
isLeadingTag = false; |
123 |
|
|
124 |
tag = tag.trim(); |
tag = tag.trim(); |
125 |
|
|
126 |
boolean isEndTag = tag.startsWith("/"); |
boolean isEndTag = tag.startsWith("/"); |
157 |
} |
} |
158 |
|
|
159 |
tagName = tagName.toLowerCase(); |
tagName = tagName.toLowerCase(); |
160 |
|
|
161 |
|
if (_isLeadingTag && "p".equals(tagName) && !isEndTag && throwAwayLeadingPara) { |
162 |
|
return; |
163 |
|
} |
164 |
|
|
165 |
if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) { |
if ("p".equals(tagName) || "br".equals(tagName) || "hr".equals(tagName)) { |
166 |
// throw away </p> and </br> |
// throw away </p> and </br> |
167 |
if (isEndTag) { |
if (isEndTag) { |