diff options
Diffstat (limited to 'src/modules/filters/teixhtml.cpp')
-rw-r--r-- | src/modules/filters/teixhtml.cpp | 149 |
1 files changed, 111 insertions, 38 deletions
diff --git a/src/modules/filters/teixhtml.cpp b/src/modules/filters/teixhtml.cpp index 4ae0d89..1eab978 100644 --- a/src/modules/filters/teixhtml.cpp +++ b/src/modules/filters/teixhtml.cpp @@ -2,7 +2,7 @@ * * teixhtml.cpp - TEI to XHTML filter * - * $Id: teixhtml.cpp 3161 2014-04-17 04:04:03Z greg.hellings $ + * $Id: teixhtml.cpp 3548 2017-12-10 05:11:38Z scribe $ * * Copyright 2012-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society @@ -32,11 +32,41 @@ SWORD_NAMESPACE_START +const char *TEIXHTML::getHeader() const { + // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def> <tr> <orth> <etym> <usg> + const static char *header = "\n\ + .entryFree, .form, .etym, .def, .usg, .quote {display:block;}\n\ + .pron, .pos, .oVar, .ref, {display:inline}\n\ + [type=headword] {font-weight:bold; font-variant:small-caps; text-decoration:underline;}\n\ + [type=derivative] {font-weight:bold; font-variant:small-caps;}\n\ + [rend=italic] {font-style:italic;}\n\ + [rend=bold] {font-weight:bold;}\n\ + [rend=small-caps] {font-variant:small-caps}\n\ + .pos:before {content: \"Pos.: \"; font-weight:bold;}\n\ + .pron:before {content:\" \\\\ \";}\n\ + .pron:after {content:\" \\\\ \";}\n\ + .etym:before {content:\"Etym.:\"; display:block; font-weight:bold;}\n\ + .usg:before {content:\"Usg.:\"; display:block; font-weight:bold;}\n\ + .def:before {content:\"Def.:\" display:block; font-weight:bold;}\n\ + .quote {background-color:#cfcfdf; padding:0.3em; margin:0.5em; border-width:1px; border-style:solid;}\n\ + .cit:before {content:\"quote:\" ; display:block; margin-top:0.5em; font-size:small;}\n\ + .cit {align:center;}\n\ + .persName:before {content:\" (\"; font-size:small;}\n\ + .persName:after {content:\") \"; font-size:small;}\n\ + .persName {font-size:small;}\n\ + .number {font-style:bold;}\n\ + .def {font-style:bold;}\n\ + "; + return header; +} + + + TEIXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { - BiblicalText = false; + isBiblicalText = false; if (module) { version = module->getName(); - BiblicalText = (!strcmp(module->getType(), "Biblical Texts")); + isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } @@ -119,9 +149,9 @@ bool TEIXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *u if ((!tag.isEndTag()) && (!tag.isEmpty())) { SWBuf n = tag.getAttribute("n"); if (n != "") { - buf += "<b>"; + buf += "<span class=\"entryFree\">"; buf += n; - buf += "</b>"; + buf += "</span>"; } } } @@ -130,11 +160,17 @@ bool TEIXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *u else if (!strcmp(tag.getName(), "sense")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { SWBuf n = tag.getAttribute("n"); + buf += "<br/><span class=\"sense"; if (n != "") { - buf += "<br /><b>"; + buf += "\" n=\""; buf += n; - buf += "</b>"; + + } + buf += "\">"; + } + else if (tag.isEndTag()) { + buf += "</span> "; } } @@ -153,47 +189,41 @@ bool TEIXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *u buf += "<br />"; } - // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def> + // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def> <tr> <orth> <etym> <usg> else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || - !strcmp(tag.getName(), "pron") /*|| - !strcmp(tag.getName(), "def")*/) { - if ((!tag.isEndTag()) && (!tag.isEmpty())) { - buf += "<i>"; - } - else if (tag.isEndTag()) { - buf += "</i>"; - } - } - - // <tr> - else if (!strcmp(tag.getName(), "tr")) { - if ((!tag.isEndTag()) && (!tag.isEmpty())) { - buf += "<i>"; - } - else if (tag.isEndTag()) { - buf += "</i>"; - } - } - - // orth - else if (!strcmp(tag.getName(), "orth")) { + !strcmp(tag.getName(), "pron") || + !strcmp(tag.getName(), "def") || + !strcmp(tag.getName(), "tr") || + !strcmp(tag.getName(), "orth") || + !strcmp(tag.getName(), "etym") || + !strcmp(tag.getName(), "usg") || + !strcmp(tag.getName(), "quote")|| + !strcmp(tag.getName(), "cit")|| + !strcmp(tag.getName(), "persName")|| + !strcmp(tag.getName(), "oVar")) + { if ((!tag.isEndTag()) && (!tag.isEmpty())) { - buf += "<b>"; + buf += "<span class=\""; + buf += tag.getName(); + if (tag.getAttribute("type")) { + buf += "\" type =\""; + buf += tag.getAttribute("type"); + } + if (tag.getAttribute("rend")) { + buf += "\" rend =\""; + buf += tag.getAttribute("rend"); + } + buf += "\">"; } else if (tag.isEndTag()) { - buf += "</b>"; + buf += "</span>"; } } - // <etym>, <usg> - else if (!strcmp(tag.getName(), "etym") || - !strcmp(tag.getName(), "usg")) { - // do nothing here - } else if (!strcmp(tag.getName(), "ref")) { if (!tag.isEndTag()) { u->suspendTextPassThru = true; @@ -276,7 +306,50 @@ bool TEIXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *u u->suspendTextPassThru = false; } } - + // <graphic> image tag + else if (!strcmp(tag.getName(), "graphic")) { + const char *url = tag.getAttribute("url"); + if (url) { // assert we have a url attribute + SWBuf filepath; + if (userData->module) { + filepath = userData->module->getConfigEntry("AbsoluteDataPath"); + if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (url[0] != '/')) + filepath += '/'; + } + filepath += url; + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showImage&value=%s&module=%s\"><img src=\"file:%s\" border=\"0\" /></a>", + URL::encode(filepath.c_str()).c_str(), + URL::encode(u->version.c_str()).c_str(), + filepath.c_str()); + u->suspendTextPassThru = false; + } + } + // <table> <row> <cell> + else if (!strcmp(tag.getName(), "table")) { + if ((!tag.isEndTag()) && (!tag.isEmpty())) { + buf += "<table><tbody>\n"; + } + else if (tag.isEndTag()) { + buf += "</tbody></table>\n"; + u->supressAdjacentWhitespace = true; + } + } + else if (!strcmp(tag.getName(), "row")) { + if ((!tag.isEndTag()) && (!tag.isEmpty())) { + buf += "\t<tr>"; + } + else if (tag.isEndTag()) { + buf += "</tr>\n"; + } + } + else if (!strcmp(tag.getName(), "cell")) { + if ((!tag.isEndTag()) && (!tag.isEmpty())) { + buf += "<td>"; + } + else if (tag.isEndTag()) { + buf += "</td>"; + } + } else { return false; // we still didn't handle token } |