/*************************************************************************** * gbfcgi.cpp - GBF to Diatheke/CGI format * ------------------- * begin : 2001-11-12 * copyright : 2001 by CrossWire Bible Society * * * Copyright 2009 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 "gbfcgi.h" SWORD_NAMESPACE_START GBFCGI::GBFCGI() { setTokenStart("<"); setTokenEnd(">"); setTokenCaseSensitive(true); addTokenSubstitute("Rf", ")"); 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 addTokenSubstitute("CG", ">"); // ??? addTokenSubstitute("CT", "<"); // ??? addTokenSubstitute("JR", "
"); // right align begin addTokenSubstitute("JC", "
"); // center align begin addTokenSubstitute("JL", "
"); // align end } bool GBFCGI::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) { unsigned long i; if (!substituteToken(buf, token)) { if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers buf += " <"; for (i = 2; i < strlen(token); i++) buf += token[i]; buf += ">"; } else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense buf += " <"; for (i = 3; i < strlen(token); i++) buf += token[i]; buf += ">"; } else if (!strncmp(token, "WT", 2)) { // morph tags buf += " ("; for (i = 1; i < strlen(token); i++) buf += token[i]; buf += ")"; } else if (!strncmp(token, "RB", 2)) { buf += ""; userData["hasFootnotePreTag"] = "true"; } else if (!strncmp(token, "RF", 2)) { if(userData["hasFootnotePreTag"] == "true") { userData["hasFootnotePreTag"] = "false"; buf += " "; } buf += " ("; } 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