/*************************************************************************** * * gbfhtmlhref.cpp - GBF to HTML filter with hrefs * * $Id: gbfhtmlhref.cpp 2833 2013-06-29 06:40:28Z chrislit $ * * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 * * 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 version 2. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * */ #include #include #include #include #include #include #include SWORD_NAMESPACE_START GBFHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { if (module) { version = module->getName(); } } GBFHTMLHREF::GBFHTMLHREF() { setTokenStart("<"); setTokenEnd(">"); setTokenCaseSensitive(true); //addTokenSubstitute("Rf", ")"); addTokenSubstitute("FA", ""); // for ASV footnotes to mark text addTokenSubstitute("Rx", ""); addTokenSubstitute("FI", ""); // italics begin addTokenSubstitute("Fi", ""); addTokenSubstitute("FB", ""); // bold begin addTokenSubstitute("Fb", ""); addTokenSubstitute("FR", ""); // words of Jesus begin addTokenSubstitute("Fr", ""); addTokenSubstitute("FU", ""); // underline begin addTokenSubstitute("Fu", ""); addTokenSubstitute("FO", ""); // Old Testament quote begin addTokenSubstitute("Fo", ""); addTokenSubstitute("FS", ""); // Superscript begin// Subscript begin addTokenSubstitute("Fs", ""); addTokenSubstitute("FV", ""); // Subscript begin addTokenSubstitute("Fv", ""); addTokenSubstitute("TT", ""); // Book title begin addTokenSubstitute("Tt", ""); addTokenSubstitute("PP", ""); // poetry begin addTokenSubstitute("Pp", ""); addTokenSubstitute("Fn", ""); // font end addTokenSubstitute("CL", "
"); // new line addTokenSubstitute("CM", "
"); // paragraph is a non showing comment that can be changed in the front end to

if desired addTokenSubstitute("CG", ""); // ??? addTokenSubstitute("CT", ""); // ??? addTokenSubstitute("JR", "

"); // right align begin addTokenSubstitute("JC", "
"); // center align begin addTokenSubstitute("JL", "
"); // align end renderNoteNumbers = false; } bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { const char *tok; MyUserData *u = (MyUserData *)userData; if (!substituteToken(buf, token)) { 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 += " <"; for (tok = (!isdigit(*val))?val+1:val; *tok; tok++) buf += *tok; buf += "> "; //cout << buf; } // forget these for now //else { // verb morph //sprintf(wordstr, "%03d", word-1); //module->getEntryAttributes()["Word"][wordstr]["Morph"] = val; //} } else { num = strstr(token, "lemma=\"strong:"); if (num) { for (num+=14; ((*num) && (*num != '\"')); num++) *valto++ = *num; *valto = 0; if (atoi((!isdigit(*val))?val+1:val) < 5627) { buf += " <"; for (tok = (!isdigit(*val))?val+1:val; *tok; tok++) buf += *tok; buf += "> "; //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 += " ("; for (tok = val; *tok; tok++) //if(*tok != '\"') buf += *tok; buf += ") "; } }*/ // else if (!strncmp(token, "WG", 2)) { // strong's numbers //buf += " <<"; for (tok = token + 2; *tok; tok++) //if(token[i] != '\"') buf += *tok; buf += ">"; } else if (!strncmp(token, "WH", 2)) { // strong's numbers //buf += " <<"; for (tok = token + 2; *tok; tok++) //if(token[i] != '\"') buf += *tok; buf += ">"; } else if (!strncmp(token, "WTG", 3)) { // strong's numbers tense //buf += " (("; for (tok = token + 3; *tok; tok++) if(*tok != '\"') buf += *tok; buf += ")"; } else if (!strncmp(token, "WTH", 3)) { // strong's numbers tense //buf += " (("; for (tok = token + 3; *tok; tok++) if(*tok != '\"') buf += *tok; buf += ")"; } else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags //buf += " (("; for (tok = token + 2; *tok; tok++) if(*tok != '\"') buf += *tok; buf += ")"; } else if (!strcmp(tag.getName(), "RX")) { buf += ""; } else if (!strcmp(tag.getName(), "RF")) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { vkey = SWDYNAMIC_CAST(VerseKey, u->key); } SWCATCH ( ... ) { } 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("*n%s ", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str(), (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str(): "")); } u->suspendTextPassThru = true; } else if (!strcmp(tag.getName(), "Rf")) { u->suspendTextPassThru = false; } /* else if (!strncmp(token, "RB", 2)) { buf += " "; u->hasFootnotePreTag = true; } else if (!strncmp(token, "Rf", 2)) { buf += " lastTextNode.c_str(); buf += "\">"; buf += "*n "; // let's let text resume to output again u->suspendTextPassThru = false; } else if (!strncmp(token, "RF", 2)) { if (u->hasFootnotePreTag) { u->hasFootnotePreTag = false; buf += " "; } u->suspendTextPassThru = true; } */ else if (!strncmp(token, "FN", 2)) { buf += ""; } else if (!strncmp(token, "CA", 2)) { // ASCII value buf += (char)atoi(&token[2]); } else { return false; } } return true; } SWORD_NAMESPACE_END