summaryrefslogtreecommitdiff
path: root/src/modules/filters/gbfhtmlhref.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/filters/gbfhtmlhref.cpp')
-rw-r--r--src/modules/filters/gbfhtmlhref.cpp165
1 files changed, 123 insertions, 42 deletions
diff --git a/src/modules/filters/gbfhtmlhref.cpp b/src/modules/filters/gbfhtmlhref.cpp
index 30b27ba..4061150 100644
--- a/src/modules/filters/gbfhtmlhref.cpp
+++ b/src/modules/filters/gbfhtmlhref.cpp
@@ -16,8 +16,13 @@
***************************************************************************/
#include <stdlib.h>
-#include <string.h>
#include <gbfhtmlhref.h>
+#include <swmodule.h>
+#include <utilxml.h>
+#include <versekey.h>
+#include <ctype.h>
+
+SWORD_NAMESPACE_START
GBFHTMLHREF::GBFHTMLHREF() {
setTokenStart("<");
@@ -25,12 +30,13 @@ GBFHTMLHREF::GBFHTMLHREF() {
setTokenCaseSensitive(true);
- addTokenSubstitute("Rf", ")</small></font>");
+ //addTokenSubstitute("Rf", ")</small></font>");
+ addTokenSubstitute("FA", "<font color=\"#800000\">"); // for ASV footnotes to mark text
addTokenSubstitute("Rx", "</a>");
addTokenSubstitute("FI", "<i>"); // italics begin
addTokenSubstitute("Fi", "</i>");
- addTokenSubstitute("FB", "<n>"); // bold begin
- addTokenSubstitute("Fb", "</n>");
+ addTokenSubstitute("FB", "<b>"); // bold begin
+ addTokenSubstitute("Fb", "</b>");
addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin
addTokenSubstitute("Fr", "</font>");
addTokenSubstitute("FU", "<u>"); // underline begin
@@ -57,87 +63,160 @@ GBFHTMLHREF::GBFHTMLHREF() {
}
-bool GBFHTMLHREF::handleToken(char **buf, const char *token, DualStringMap &userData) {
+bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
const char *tok;
+ char val[128];
+ char *valto;
+ const char *num;
+ MyUserData *u = (MyUserData *)userData;
if (!substituteToken(buf, token)) {
- if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
- pushString(buf, " <small><em>&lt;<a href=\"#");
+ XMLTag tag(token);
+ if (!strncmp(token, "w", 1)) {
+ // OSIS Word (temporary until OSISRTF is done)
+ valto = val;
+ num = strstr(token, "lemma=\"x-Strongs:");
+ if (num) {
+ for (num+=17; ((*num) && (*num != '\"')); num++)
+ *valto++ = *num;
+ *valto = 0;
+ if (atoi((!isdigit(*val))?val+1:val) < 5627) {
+ buf += " <small><em>&lt;<a href=\"type=Strongs value=";
+ for (tok = val; *tok; tok++)
+ buf += *tok;
+ buf += "\">";
+ for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
+ buf += *tok;
+ buf += "</a>&gt;</em></small> ";
+ //cout << buf;
+
+ }
+ /* forget these for now
+ else {
+ // verb morph
+ sprintf(wordstr, "%03d", word-1);
+ module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
+ }
+ */
+ }
+ valto = val;
+ num = strstr(token, "morph=\"x-Robinson:");
+ if (num) {
+ for (num+=18; ((*num) && (*num != '\"')); num++)
+ *valto++ = *num;
+ *valto = 0;
+ buf += " <small><em>(<a href=\"type=morph class=Robinson value=";
+ for (tok = val; *tok; tok++)
+ // normal robinsons tense
+ buf += *tok;
+ buf += "\">";
+ for (tok = val; *tok; tok++)
+ //if(*tok != '\"')
+ buf += *tok;
+ buf += "</a>)</em></small> ";
+ }
+ }
+
+ else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
+ buf += " <small><em>&lt;<a href=\"type=Strongs value=";
for (tok = token+1; *tok; tok++)
//if(token[i] != '\"')
- *(*buf)++ = *tok;
- *(*buf)++ = '\"';
- *(*buf)++ = '>';
+ buf += *tok;
+ buf += "\">";
for (tok = token + 2; *tok; tok++)
//if(token[i] != '\"')
- *(*buf)++ = *tok;
- pushString(buf, "</a>&gt;</em></small>");
+ buf += *tok;
+ 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=\"#");
+ buf += " <small><em>(<a href=\"type=Strongs value=";
for (tok = token + 2; *tok; tok++)
if(*tok != '\"')
- *(*buf)++ = *tok;
- *(*buf)++ = '\"';
- *(*buf)++ = '>';
+ buf += *tok;
+ buf += "\">";
for (tok = token + 3; *tok; tok++)
if(*tok != '\"')
- *(*buf)++ = *tok;
- pushString(buf, "</a>)</em></small>");
+ buf += *tok;
+ 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");
+ buf += " <small><em>(<a href=\"type=morph class=none value=";
for (tok = token + 2; *tok; tok++)
if(*tok != '\"')
- *(*buf)++ = *tok;
- *(*buf)++ = '\"';
- *(*buf)++ = '>';
+ buf += *tok;
+ buf += "\">";
for (tok = token + 2; *tok; tok++)
if(*tok != '\"')
- *(*buf)++ = *tok;
- pushString(buf, "</a>)</em></small>");
+ buf += *tok;
+ buf += "</a>)</em></small>";
}
- else if (!strncmp(token, "RX", 2)) {
- pushString(buf, "<a href=\"");
+ else if (!strcmp(tag.getName(), "RX")) {
+ buf += "<a href=\"";
for (tok = token + 3; *tok; tok++) {
if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
- *(*buf)++ = *tok;
+ buf += *tok;
}
else {
break;
}
}
- *(*buf)++ = '\"';
- *(*buf)++ = '>';
+ buf += "\">";
}
-
+ else if (!strcmp(tag.getName(), "RF")) {
+ SWBuf type = tag.getAttribute("type");
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ VerseKey *vkey;
+ // see if we have a VerseKey * or descendant
+ try {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ catch ( ... ) { }
+ if (vkey) {
+ // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
+ //char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+ buf.appendFormatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), 'n', footnoteNumber.c_str(), 'n');
+ }
+ u->suspendTextPassThru = true;
+ }
+ else if (!strcmp(tag.getName(), "Rf")) {
+ u->suspendTextPassThru = false;
+ }
+/*
else if (!strncmp(token, "RB", 2)) {
- pushString(buf, "<i>");
- userData["hasFootnotePreTag"] = "true";
+ buf += "<i> ";
+ u->hasFootnotePreTag = true;
}
+ else if (!strncmp(token, "Rf", 2)) {
+ buf += "&nbsp<a href=\"note=";
+ buf += u->lastTextNode.c_str();
+ buf += "\">";
+ buf += "<small><sup>*n</sup></small></a>&nbsp";
+ // let's let text resume to output again
+ u->suspendTextPassThru = false;
+ }
+
else if (!strncmp(token, "RF", 2)) {
- if(userData["hasFootnotePreTag"] == "true") {
- userData["hasFootnotePreTag"] = "false";
- pushString(buf, "</i> ");
+ if (u->hasFootnotePreTag) {
+ u->hasFootnotePreTag = false;
+ buf += "</i> ";
}
- pushString(buf, "<font color=\"#800000\"><small> (");
+ u->suspendTextPassThru = true;
}
-
+*/
else if (!strncmp(token, "FN", 2)) {
- pushString(buf, "<font face=\"");
+ buf += "<font face=\"";
for (tok = token + 2; *tok; tok++)
if(*tok != '\"')
- *(*buf)++ = *tok;
- *(*buf)++ = '\"';
- *(*buf)++ = '>';
+ buf += *tok;
+ buf += "\">";
}
else if (!strncmp(token, "CA", 2)) { // ASCII value
- *(*buf)++ = (char)atoi(&token[2]);
+ buf += (char)atoi(&token[2]);
}
else {
@@ -146,3 +225,5 @@ bool GBFHTMLHREF::handleToken(char **buf, const char *token, DualStringMap &user
}
return true;
}
+
+SWORD_NAMESPACE_END