summaryrefslogtreecommitdiff
path: root/src/modules/filters/gbfhtmlhref.cpp
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:33 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:33 -0400
commit8d3fc864d094eeadc721f8e93436b37a5fab173e (patch)
tree05e201c67dca55b4ccdf90ad479a25d95e3b1e63 /src/modules/filters/gbfhtmlhref.cpp
Imported Upstream version 1.5.3
Diffstat (limited to 'src/modules/filters/gbfhtmlhref.cpp')
-rw-r--r--src/modules/filters/gbfhtmlhref.cpp148
1 files changed, 148 insertions, 0 deletions
diff --git a/src/modules/filters/gbfhtmlhref.cpp b/src/modules/filters/gbfhtmlhref.cpp
new file mode 100644
index 0000000..30b27ba
--- /dev/null
+++ b/src/modules/filters/gbfhtmlhref.cpp
@@ -0,0 +1,148 @@
+/***************************************************************************
+ gbfhtmlhref.cpp - GBF to HTML filter with hrefs
+ for strongs and morph tags
+ -------------------
+ begin : 2001-09-03
+ copyright : 2001 by CrossWire Bible Society
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <gbfhtmlhref.h>
+
+GBFHTMLHREF::GBFHTMLHREF() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setTokenCaseSensitive(true);
+
+ addTokenSubstitute("Rf", ")</small></font>");
+ addTokenSubstitute("Rx", "</a>");
+ addTokenSubstitute("FI", "<i>"); // italics begin
+ addTokenSubstitute("Fi", "</i>");
+ addTokenSubstitute("FB", "<n>"); // bold begin
+ addTokenSubstitute("Fb", "</n>");
+ addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin
+ addTokenSubstitute("Fr", "</font>");
+ addTokenSubstitute("FU", "<u>"); // underline begin
+ addTokenSubstitute("Fu", "</u>");
+ addTokenSubstitute("FO", "<cite>"); // Old Testament quote begin
+ addTokenSubstitute("Fo", "</cite>");
+ addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin
+ addTokenSubstitute("Fs", "</sup>");
+ addTokenSubstitute("FV", "<sub>"); // Subscript begin
+ addTokenSubstitute("Fv", "</sub>");
+ addTokenSubstitute("TT", "<big>"); // Book title begin
+ addTokenSubstitute("Tt", "</big>");
+ addTokenSubstitute("PP", "<cite>"); // poetry begin
+ addTokenSubstitute("Pp", "</cite>");
+ addTokenSubstitute("Fn", "</font>"); // font end
+ addTokenSubstitute("CL", "<br />"); // new line
+ addTokenSubstitute("CM", "<!P><br />"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
+ addTokenSubstitute("CG", ""); // ???
+ addTokenSubstitute("CT", ""); // ???
+ addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
+ addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
+ addTokenSubstitute("JL", "</div>"); // align end
+
+}
+
+
+bool GBFHTMLHREF::handleToken(char **buf, const char *token, DualStringMap &userData) {
+ const char *tok;
+
+ if (!substituteToken(buf, token)) {
+ if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
+ pushString(buf, " <small><em>&lt;<a href=\"#");
+ for (tok = token+1; *tok; tok++)
+ //if(token[i] != '\"')
+ *(*buf)++ = *tok;
+ *(*buf)++ = '\"';
+ *(*buf)++ = '>';
+ for (tok = token + 2; *tok; tok++)
+ //if(token[i] != '\"')
+ *(*buf)++ = *tok;
+ pushString(buf, "</a>&gt;</em></small>");
+ }
+
+ else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
+ pushString(buf, " <small><em>(<A HREF=\"#");
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ *(*buf)++ = *tok;
+ *(*buf)++ = '\"';
+ *(*buf)++ = '>';
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ *(*buf)++ = *tok;
+ pushString(buf, "</a>)</em></small>");
+ }
+
+ else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
+ pushString(buf, " <small><em>(<a href=\"M");
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ *(*buf)++ = *tok;
+ *(*buf)++ = '\"';
+ *(*buf)++ = '>';
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ *(*buf)++ = *tok;
+ pushString(buf, "</a>)</em></small>");
+ }
+
+ else if (!strncmp(token, "RX", 2)) {
+ pushString(buf, "<a href=\"");
+ for (tok = token + 3; *tok; tok++) {
+ if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
+ *(*buf)++ = *tok;
+ }
+ else {
+ break;
+ }
+ }
+ *(*buf)++ = '\"';
+ *(*buf)++ = '>';
+ }
+
+ else if (!strncmp(token, "RB", 2)) {
+ pushString(buf, "<i>");
+ userData["hasFootnotePreTag"] = "true";
+ }
+
+ else if (!strncmp(token, "RF", 2)) {
+ if(userData["hasFootnotePreTag"] == "true") {
+ userData["hasFootnotePreTag"] = "false";
+ pushString(buf, "</i> ");
+ }
+ pushString(buf, "<font color=\"#800000\"><small> (");
+ }
+
+ else if (!strncmp(token, "FN", 2)) {
+ pushString(buf, "<font face=\"");
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ *(*buf)++ = *tok;
+ *(*buf)++ = '\"';
+ *(*buf)++ = '>';
+ }
+
+ else if (!strncmp(token, "CA", 2)) { // ASCII value
+ *(*buf)++ = (char)atoi(&token[2]);
+ }
+
+ else {
+ return false;
+ }
+ }
+ return true;
+}