public WtNode visit(WtNewline newline) { WtNodeList result = closeRemainingTags(); if (result == null) return newline; state = State.None; result.add(newline); return result; }
public WtNode visit(WtWhitespace ws) { if (!ws.getHasNewline()) return ws; WtNodeList result = closeRemainingTags(); if (result == null) return ws; state = State.None; result.add(ws); return result; }
private void finishLine(WtNodeList body) { WtNodeList result = closeRemainingTags(); if (result == null) return; state = State.None; body.add(result); }
private WtNodeList closeRemainingTags() { WtNodeList result = null; switch (state) { case Italics: result = nf.list(); result.add(ITALICS.createClose(nf, true)); break; case Bold: result = nf.list(); result.add(BOLD.createClose(nf, true)); break; case BoldItalics: result = nf.list(); result.add(ITALICS.createClose(nf, true)); result.add(BOLD.createClose(nf, true)); break; case ItalicsBold: result = nf.list(); result.add(BOLD.createClose(nf, true)); result.add(ITALICS.createClose(nf, true)); break; case None: break; } return result; }
private void toTag(LineEntry entry, WtNodeList result) { switch (entry.tickCount) { case 2: switch (state) { case Italics: result.add(ITALICS.createClose(nf, false)); state = State.None; break; case BoldItalics: result.add(ITALICS.createClose(nf, false)); state = State.Bold; break; case ItalicsBold: result.add(BOLD.createClose(nf, true)); result.add(ITALICS.createClose(nf, false)); result.add(BOLD.createOpen(nf, true)); state = State.Bold; break; case Bold: result.add(ITALICS.createOpen(nf, false)); state = State.BoldItalics; break; case None: result.add(ITALICS.createOpen(nf, false)); state = State.Italics; break; } break; case 3: switch (state) { case Bold: result.add(BOLD.createClose(nf, false)); state = State.None; break; case BoldItalics: result.add(ITALICS.createClose(nf, true)); result.add(BOLD.createClose(nf, false)); result.add(ITALICS.createOpen(nf, true)); state = State.Italics; break; case ItalicsBold: result.add(BOLD.createClose(nf, false)); state = State.Italics; break; case Italics: result.add(BOLD.createOpen(nf, false)); state = State.ItalicsBold; break; case None: result.add(BOLD.createOpen(nf, false)); state = State.Bold; break; } break; case 5: switch (state) { case Italics: result.add(ITALICS.createClose(nf, false)); result.add(BOLD.createOpen(nf, false)); state = State.Bold; break; case Bold: result.add(BOLD.createClose(nf, false)); result.add(ITALICS.createOpen(nf, false)); state = State.Italics; break; case BoldItalics: result.add(ITALICS.createClose(nf, false)); result.add(BOLD.createClose(nf, false)); state = State.None; break; case ItalicsBold: result.add(BOLD.createClose(nf, false)); result.add(ITALICS.createClose(nf, false)); state = State.None; break; case None: result.add(ITALICS.createOpen(nf, false)); result.add(BOLD.createOpen(nf, false)); state = State.ItalicsBold; break; } break; } }