- public static class HTMLWalker extends ReflectiveWalker {
- //public void header() { throw new Error(); }
- public String ul(Object o) { return "<ul>"+o+"</ul>"; }
- private Tree<String> lone(String s) {
- StringBuffer sb = new StringBuffer();
- for(int i=0; i<s.length(); i++) {
- switch(s.charAt(i)) {
- case '&': sb.append("&"); break;
- case '<': sb.append("<"); break;
- case '>': sb.append(">"); break;
- case '\'': sb.append("'"); break;
- case '\"': sb.append("""); break;
- default: sb.append(s.charAt(i)); break;
- }
+ // Tags //////////////////////////////////////////////////////////////////////////////
+
+ public static class Keyword extends TextString { public String tag() { return "tt"; } }
+ public static class Bold extends TextArray { public String tag() { return "b"; } }
+ public static class Smallcap extends TextArray { public String tag() { return "sc"; } }
+ public static class Subscript extends TextString { public String tag() { return "sub"; } }
+ public static class Superscript extends TextString { public String tag() { return "super"; } }
+ public static class Strikethrough extends TextArray { public String tag() { return "strike"; } }
+ public static class TT extends TextArray { public String tag() { return "tt"; } }
+ public static class Underline extends TextArray { public String tag() { return "u"; } }
+ public static class Citation extends TextArray { /* FIXME */ }
+ public static class Footnote extends TextArray { /* FIXME */ }
+
+ public static class Chars extends TextString { }
+ public static class Symbol extends TextString { }
+
+ public static interface Host extends ToHTML { }
+ public static class DNS implements Host {
+ public String[] part;
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append("<tt>");
+ for(int i=0; i<part.length; i++)
+ sb.append((i==0 ? "" : ".")+part[i]);
+ sb.append("</tt>");
+ }
+ }
+ public static class IP implements Host {
+ public int a, b, c, d;
+ public void toHTML(ToHTML.HTML sb) { sb.append("<tt>"+a+"."+b+"."+c+"."+d+"</tt>"); }
+ }
+
+ public static interface URI extends ToHTML {
+ public static final Class[] subclasses = new Class[] { URL.class, Email.class };
+ }
+ public static class URL extends Text implements URI {
+ public String method;
+ public Login login;
+ public Host host;
+ public int port;
+ public String path;
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append(method);
+ sb.append("://");
+ // login.toHTML(sb); FIXME
+ host.toHTML(sb);
+ // sb.append(":"); FIXME
+ // sb.append(port);
+ sb.append("/");
+ sb.append(path);
+ }
+ }
+ public static class Email extends Text implements URI {
+ public String user;
+ public Host host;
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append(user);
+ sb.append('@');
+ host.toHTML(sb);
+ }
+ }
+
+ public static class Login {
+ public String username;
+ public String password;
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append(username);
+ sb.append(':');
+ sb.append(password);
+ sb.append('@');
+ }
+ }
+ public static class Italic extends Text {
+ public Text[] body;
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append("<i>");
+ sb.append(body);
+ sb.append("</i>");
+ }
+ }
+
+ public static class LineBreak extends Text {
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append("<br/>");
+ }
+ }
+ public static class Today extends Text { }
+ public static class Euro extends Text {
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append("€");
+ }
+ }
+ public static class Link extends Text {
+ public static final Class[] subclasses = new Class[] { LinkWord.class, LinkText.class };
+ public static class LinkWord extends Link {
+ public String word;
+ public URI href;
+ public void toHTML(ToHTML.HTML sb) {
+ sb.append("<a href='");
+ href.toHTML(sb);
+ sb.append("'>");
+ sb.append(word);
+ sb.append("</a>");