001 /*
002 * HtmlConstants.java
003 * Copyright (c) 1998-2008, The University of Sheffield.
004 *
005 * This code is from the GATE project (http://gate.ac.uk/) and is free
006 * software licenced under the GNU General Public License version 3. It is
007 * distributed without any warranty. For more details see COPYING.txt in the
008 * top level directory (or at http://gatewiki.sf.net/COPYING.txt).
009 *
010 * Hamish Cunningham, 13th May 2006
011 */
012
013 package gate.yam.translate;
014
015 /**
016 * Constants used when translating HTML. One entry for each type of parse tree
017 * node. Each entry contains the node type name, the start constant and the
018 * end constant.
019 * <pre>
020 * constantsTable[CONSTANTNAME] is the node type name
021 * constantsTable[CONSTANTSTART] is the start string
022 * constantsTable[CONSTANTEND] is the end string
023 * </pre>
024 * A separate map is defined for predicates, and there are misc patterns for
025 * e.g. headings construction.
026 * @author Hamish Cunningham
027 */
028 public interface HtmlConstants
029 {
030 /** Array mapping node type name to start/end strings. */
031 final String[][] htmlConstantsTable = {
032
033 // ordinary nodes
034 { "YamDocument", "", "</body></html>\n" },
035 { "Sep", "", "" },
036 { "Title", "", "" },
037 { "Text", "", "" },
038 { "Verbatim", "<pre>", "</pre>" },
039 { "Word", "", "" },
040 { "Escape", "<span class=\"cow-escape\">", "</span>" },
041 { "Plain", "", "" },
042 { "Control", "", "" },
043 { "TargetControl", "", "" },
044 { "Hr", "<hr>", "" },
045 { "Url", "<a class=\"_Y_\" href=\"_X_\">", "</a>" },
046 { "Anchor", "<a name=\"_X_\">", "</a>" },
047 { "Br", "<br>", "" },
048 { "Nbsp", " ", "" },
049 { "Unit", "", "" },
050 { "SectionHead", "", "" },
051 { "SectionText", "", "" },
052 { "Paragraph", "<p>", "</p>" },
053 { "List", "", "" },
054 { "ListItem", "<li>", "</li>" },
055 { "OList", "<ol>", "</ol>" },
056 { "UList", "<ul>", "</ul>" },
057 { "Table", "<table>", "</table>" },
058 { "Row", "<tr>", "</tr>" },
059 { "Column", "<td>", "</td>" },
060 { "TableSep", "", "" },
061 { "Whsp", "", "" },
062 { "Contents", "<div class=\"cow-contents\">", "</div>" },
063 { "Predicate", "", "" },
064 { "TextOrTable", "", "" },
065 { "Skip", "", "" },
066
067 // controls
068 { "*", "<b>", "</b>" },
069 { "^", "<tt>", "</tt>" },
070 { "_", "<em>", "</em>" },
071 { "__", "<u>", "</u>" },
072 { "<", "<", "" },
073 { "&", "&", "" },
074 { "%\"", "<blockquote>", "</blockquote>" },
075
076 // predicates
077 { "image", "<img", ">" },
078 { "footnote", "<footnote>", "</footnote>" },
079 { "cite", "<span class=\"cow-cite\" keys=\"_X_\">",
080 "</span>" },
081 { "include", "", "" },
082
083 // misc useful constants
084 { "olistPara", "<p><ol>", "</ol></p>", },
085 { "ulistPara", "<p><ul>", "</ul></p>", },
086 { "anchorPattern", "<a class=\"_Y_\" name=\"_X_\"></a>", "", },
087 { "linkPattern", "<a href=\"_X_\">_Y_</a>", "", },
088 { "headingPattern", "<h_X_ class=\"_Z_\">_Y_</h_X_>", "", },
089 { "nbSpace", " ", "", },
090 { "headNumber", "<span class=\"cow-sec-number\">", "</span>" },
091 { "footnoteText", "<span class=\"cow-footnote-text\" name=\"_X_\">",
092 "</span>" },
093 { "footnoteSection","<span class=\"cow-footnote-section\">",
094 "</span>" },
095 { "comment", "<!--", "-->", },
096
097 // headings
098 { "1", "1", "", },
099 { "2", "2", "", },
100 { "3", "3", "", },
101 { "4", "4", "", },
102 { "5", "5", "", },
103 { "6", "6", "", },
104 { "7", "7", "", },
105 { "8", "8", "", },
106 { "9", "9", "", },
107 };
108
109 /** Attributes allowed on images. */
110 final String[] imageAttrs =
111 { " src=\"_X_\"", " alt=\"_X_\"", " width=\"_X_\"", " height=\"_X_\"",
112 " align=\"_X_\"", " border=\"_X_\"", };
113
114 /** Attributes allowed on footnotes. */
115 final String[] footnoteAttrs = { "_X_" };
116
117 /** Attributes allowed on includes. */
118 final String[] includeAttrs = { "_X_" };
119
120 /** Array mapping predicate type name to attributes. */
121 final Object[][] htmlPredicatesTable = {
122 { "image", imageAttrs },
123 { "footnote", footnoteAttrs },
124 { "include", includeAttrs },
125 };
126
127 } // HtmlConstants
|