Mercurial > projects > dwt-addons
comparison dwtx/jface/internal/text/html/HTML2TextReader.d @ 150:5cf141e43417
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 23:05:26 +0200 |
parents | 000f9136b8f7 |
children | f70d9508c95c |
comparison
equal
deleted
inserted
replaced
149:b411f1c62131 | 150:5cf141e43417 |
---|---|
47 | 47 |
48 private static const String EMPTY_STRING= ""; //$NON-NLS-1$ | 48 private static const String EMPTY_STRING= ""; //$NON-NLS-1$ |
49 private static const Map fgEntityLookup; | 49 private static const Map fgEntityLookup; |
50 private static const Set fgTags; | 50 private static const Set fgTags; |
51 | 51 |
52 static { | 52 static this() { |
53 | 53 |
54 fgTags= new HashSet(); | 54 fgTags= new HashSet(); |
55 fgTags.add("b"); //$NON-NLS-1$ | 55 fgTags.add("b"); //$NON-NLS-1$ |
56 fgTags.add("br"); //$NON-NLS-1$ | 56 fgTags.add("br"); //$NON-NLS-1$ |
57 fgTags.add("br/"); //$NON-NLS-1$ | 57 fgTags.add("br/"); //$NON-NLS-1$ |
155 | 155 |
156 if (html is null || html.length() is 0) | 156 if (html is null || html.length() is 0) |
157 return EMPTY_STRING; | 157 return EMPTY_STRING; |
158 | 158 |
159 html= html.toLowerCase(); | 159 html= html.toLowerCase(); |
160 | 160 |
161 String tag= html; | 161 String tag= html; |
162 if ('/' is tag.charAt(0)) | 162 if ('/' is tag.charAt(0)) |
163 tag= tag.substring(1); | 163 tag= tag.substring(1); |
164 | 164 |
165 if (!fgTags.contains(tag)) | 165 if (!fgTags.contains(tag)) |
223 return LINE_DELIM; | 223 return LINE_DELIM; |
224 } | 224 } |
225 | 225 |
226 if ("/dd".equals(html)) //$NON-NLS-1$ | 226 if ("/dd".equals(html)) //$NON-NLS-1$ |
227 return LINE_DELIM; | 227 return LINE_DELIM; |
228 | 228 |
229 if ("head".equals(html) && !fHeaderDetected) { //$NON-NLS-1$ | 229 if ("head".equals(html) && !fHeaderDetected) { //$NON-NLS-1$ |
230 fHeaderDetected= true; | 230 fHeaderDetected= true; |
231 fIgnore= true; | 231 fIgnore= true; |
232 return EMPTY_STRING; | 232 return EMPTY_STRING; |
233 } | 233 } |
234 | 234 |
235 if ("/head".equals(html) && fHeaderDetected && fIgnore) { //$NON-NLS-1$ | 235 if ("/head".equals(html) && fHeaderDetected && fIgnore) { //$NON-NLS-1$ |
236 fIgnore= false; | 236 fIgnore= false; |
237 return EMPTY_STRING; | 237 return EMPTY_STRING; |
238 } | 238 } |
239 | 239 |
278 buf.append(cast(wchar) ch); | 278 buf.append(cast(wchar) ch); |
279 } while (true); | 279 } while (true); |
280 | 280 |
281 return html2Text(buf.toString()); | 281 return html2Text(buf.toString()); |
282 } | 282 } |
283 | 283 |
284 private static bool isInComment(StringBuffer buf) { | 284 private static bool isInComment(StringBuffer buf) { |
285 return buf.length() >= 3 && "!--".equals(buf.substring(0, 3)); //$NON-NLS-1$ | 285 return buf.length() >= 3 && "!--".equals(buf.substring(0, 3)); //$NON-NLS-1$ |
286 } | 286 } |
287 | 287 |
288 private static bool isCommentEnd(StringBuffer buf) { | 288 private static bool isCommentEnd(StringBuffer buf) { |
289 int tagLen= buf.length(); | 289 int tagLen= buf.length(); |
290 return tagLen >= 5 && "--".equals(buf.substring(tagLen - 2)); //$NON-NLS-1$ | 290 return tagLen >= 5 && "--".equals(buf.substring(tagLen - 2)); //$NON-NLS-1$ |
291 } | 291 } |
292 | 292 |