This is a very simple HTML parser made for the specific purpose of parsing HTMLs on the fly, i.e. without conversion. It preserves some of the formatting: the one specified by the following tags: - [meta encoding] - [i] or [em] - [b] or [strong] - [center], [left], [right] Because of memory
| 29 | * @author albus |
| 30 | */ |
| 31 | public class HTMLTextParser extends TextParser |
| 32 | implements HTMLSubstitues, StylingConstants { |
| 33 | |
| 34 | private static final String TAG_P = "p"; |
| 35 | private static final String TAG_BR = "br"; |
| 36 | private static final String TAG_DIV = "div"; |
| 37 | private static final String TAG_TR = "tr"; |
| 38 | private static final String TAG_LI = "li"; |
| 39 | |
| 40 | private static final String TAG_IMG = "img"; |
| 41 | private static final String TAG_SVG_IMAGE = "image"; |
| 42 | |
| 43 | private static final String TAG_B = "b"; |
| 44 | private static final String TAG_STRONG = "strong"; |
| 45 | private static final String TAG_I = "i"; |
| 46 | private static final String TAG_EM = "em"; |
| 47 | |
| 48 | private static final String TAG_H1 = "h1"; |
| 49 | private static final String TAG_H2 = "h2"; |
| 50 | private static final String TAG_H3 = "h3"; |
| 51 | private static final String TAG_H4 = "h4"; |
| 52 | private static final String TAG_H5 = "h5"; |
| 53 | private static final String TAG_H6 = "h6"; |
| 54 | |
| 55 | private static final String TAG_CENTER = "center"; |
| 56 | |
| 57 | private static final String TAG_HR = "hr"; |
| 58 | |
| 59 | private static final String TAG_PRE = "pre"; |
| 60 | |
| 61 | private int ignoreTag = 0; |
| 62 | |
| 63 | private int pre = 0; |
| 64 | |
| 65 | private int bold = 0; |
| 66 | private int italic = 0; |
| 67 | private int heading = 0; |
| 68 | |
| 69 | private int center = 0; |
| 70 | |
| 71 | private boolean hr = false; |
| 72 | |
| 73 | private Vector instructions = new Vector(20); |
| 74 | |
| 75 | public HTMLTextParser() { |
| 76 | processBreaks = false; |
| 77 | } |
| 78 | |
| 79 | public final void reset() { |
| 80 | ignoreTag = 0; |
| 81 | pre = 0; |
| 82 | bold = 0; |
| 83 | italic = 0; |
| 84 | heading = 0; |
| 85 | center = 0; |
| 86 | hr = false; |
| 87 | |
| 88 | if (instructions != null) { |
nothing calls this directly
no outgoing calls
no test coverage detected