001: package vqwiki.lex;
002:
003: import org.apache.log4j.Logger;
004:
005: public class ExFormatLexConvert {
006: protected boolean em, strong, underline, center, table, row, cell,
007: allowHtml, code, h1, h2, h3, color;
008:
009: protected int listLevel;
010:
011: protected boolean ordered;
012:
013: private String virtualwiki;
014:
015: protected static Logger cat = Logger
016: .getLogger(ExFormatLexConvert.class);
017:
018: public String onBold(String string) {
019: cat.debug("'''");
020: if (strong) {
021: strong = false;
022: return ("</strong>");
023: } else {
024: strong = true;
025: return ("<strong>");
026: }
027: }
028:
029: public String onColorEnd(String string) {
030: if (color) {
031: cat.debug("color end");
032: color = false;
033: return ("</font>");
034: } else {
035: return string;
036: }
037: }
038:
039: public String onColorStart(String string) {
040: cat.debug("color start");
041: StringBuffer sb = new StringBuffer();
042: if (color) {
043: sb.append("</font>");
044: }
045: color = true;
046: sb.append("<font color=\"").append(
047: string.substring(1, string.length() - 1)).append("\">");
048: return sb.toString();
049: }
050:
051: public String onCenter(String string) {
052: cat.debug("::");
053: if (center) {
054: center = false;
055: return ("</div>");
056: } else {
057: center = true;
058: return ("<div align=\"center\">");
059: }
060: }
061:
062: public String onHeadlineTwo(String string) {
063: cat.debug("!!...!!");
064: return "<h2>"
065: + string.substring(2,
066: string.substring(2).indexOf('!') + 2)
067: + "</h2>\r";
068: }
069:
070: public String onHeadlineThree(String string) {
071: cat.debug("!...!");
072: return "<h3>"
073: + string.substring(1,
074: string.substring(1).indexOf('!') + 1)
075: + "</h3>\r";
076: }
077:
078: public String onNbsp() {
079: return " ";
080: }
081:
082: public String onItalic(String string) {
083: cat.debug("''");
084: if (em) {
085: em = false;
086: return ("</em>");
087: } else {
088: em = true;
089: return ("<em>");
090: }
091: }
092:
093: public String onCodeEnd() {
094: return "</code>";
095: }
096:
097: public String onUnderline(String string) {
098: cat.debug("===");
099: if (underline) {
100: underline = false;
101: return ("</u>");
102: } else {
103: underline = true;
104: return ("<u>");
105: }
106: }
107:
108: public String onEndOfLine(String string) {
109: cat.debug("{newline}");
110: if (h1) {
111: h1 = false;
112: return ("</h1>");
113: }
114: if (h2) {
115: h2 = false;
116: return ("</h2>");
117: }
118: if (h3) {
119: h3 = false;
120: return ("</h3>");
121: }
122: return string;
123: }
124:
125: public String onHeadlineOne(String string) {
126: cat.debug("!!!...!!!");
127: return "<h1>"
128: + string.substring(3,
129: string.substring(3).indexOf('!') + 3)
130: + "</h1>\r";
131: }
132:
133: public String onCodeBegin() {
134: return "<code>";
135: }
136:
137: public String onNewline() {
138: return "<br/>";
139: }
140:
141: public String onEOF() {
142: if (strong) {
143: strong = false;
144: return ("</strong>");
145: }
146: if (em) {
147: em = false;
148: return ("</em>");
149: }
150: return null;
151: }
152:
153: public void setVirtualWiki(String wiki) {
154: this.virtualwiki = wiki;
155: }
156: }
|