+ public @bind.as static class KeyVal extends Dump {
+ public @bind.arg String key;
+ public @bind.arg Object val;
+ }
+
+ public abstract static class Paragraph extends Dump implements ToHTML { }
+
+ public @bind.as("P") static class P extends Paragraph {
+ public Text[] text;
+ public P() { }
+ public P(Text[] text) { this.text = text; }
+ public void toHTML(HTML h) { if (text != null) for (Text t : text) if (t != null) t.toHTML(h); }
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ ToHTML.HTML h = new ToHTML.HTML(sb);
+ toHTML(h);
+ return sb.toString();
+ }
+ }
+
+ public @bind.as("HR") static class HR extends Paragraph {
+ public void toHTML(HTML h) { h.tag("hr"); }
+ }
+
+ public @bind.as("Blockquote") static class Blockquote extends Paragraph {
+ Text[] text;
+ public void toHTML(HTML h) { h.tag("blockquote", new P(text)); }
+ }
+
+ public abstract static class Text extends Dump implements ToHTML { }
+ public @bind.as static class Chars extends Text {
+ public String text;
+ public Chars() { }
+ public Chars(String text) { this.text = text; }
+ public void toHTML(HTML h) { h.appendText(" " + text + " "); }
+ public String toString() { return text; }
+ }
+ public @bind.as static class Block extends Text {
+ public Text[] text;
+ public void toHTML(HTML h) { for(Text t : text) t.toHTML(h); }
+ }
+ public static class TextWrap extends Text {
+ public Text text;
+ public void toHTML(HTML h) {
+ if (htmlTag()!=null)
+ h.tag(htmlTag(), htmlTagParams(), text);
+ else
+ text.toHTML(h);
+ }
+ public String htmlTag() { return null; }
+ public Object[] htmlTagParams() { return null; }
+ }
+ public static @bind.as class Verbatim extends Text { public char[] c; public void toHTML(HTML h) { } }
+ //public @bind.as class Blockquote extends TextWrap { }
+ public static @bind.as class Underline extends TextWrap { public String htmlTag() { return "u"; } }
+ public static @bind.as class Footnote extends TextWrap { public String htmlTag() { return "small"; } }
+ public static @bind.as class TT extends TextWrap { public String htmlTag() { return "tt"; } }
+ //public @bind.as class Citation extends Text { "[" word "]" }
+ public static @bind.as class Strikethrough extends TextWrap { public String htmlTag() { return "strikethrough"; } }
+ public static @bind.as class Superscript extends TextWrap { public String htmlTag() { return "sup"; } }
+ public static @bind.as class Subscript extends TextWrap { public String htmlTag() { return "sub"; } }
+ public static @bind.as class Smallcap extends TextWrap { public String htmlTag() { return "sc"; } }
+ public static @bind.as class Keyword extends TextWrap { public String htmlTag() { return "sc"; } }
+ public static @bind.as class Bold extends TextWrap { public String htmlTag() { return "b"; } }
+ public static @bind.as class Italic extends TextWrap { public String htmlTag() { return "i"; } }
+
+ public abstract static class Command extends Text { }
+ public static @bind.as class Today extends Command { public void toHTML(HTML h) { } }
+ public static @bind.as class LineBreak extends Command { public void toHTML(HTML h) { h.tag("br"); } }
+
+ public abstract static class Glyph extends Text { }
+ public static @bind.as("emdash") class Emdash extends Glyph { public void toHTML(HTML h) { h.append("&emdash;"); } }
+
+ public static class Link extends Text {
+ public Text[] t;
+ public Url u;
+ public @bind.as("LinkText") Link(Text[] t, Url u) { this.t = t; this.u = u; }
+ public @bind.as("LinkChars") Link(String s, Url u) { this(new Text[] { new Chars(s) }, u); }
+ public void toHTML(HTML h) {
+ h.tag("a",
+ new Object[] { "href", u==null ? "" : u.toString() },
+ new P(t));
+ }