/*************************************************************************** thmlcgi.cpp - ThML to Diatheke/CGI format ------------------- begin : 2001-11-12 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 #include #include "thmlcgi.h" SWORD_NAMESPACE_START ThMLCGI::ThMLCGI() { setTokenStart("<"); setTokenEnd(">"); setTokenCaseSensitive(true); addTokenSubstitute("note", " ("); addTokenSubstitute("/note", ") "); } bool ThMLCGI::handleToken(char **buf, const char *token, DualStringMap &userData) { unsigned long i; if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution if (!strncmp(token, "sync ", 5)) { pushString(buf, ""); } else if (!strncmp(token, "scripRef p", 10) || !strncmp(token, "scripRef v", 10)) { userData["inscriptRef"] = "true"; pushString(buf, "John 3:16" else if (!strcmp(token, "scripRef")) { userData["inscriptRef"] = "false"; // let's stop text from going to output userData["suspendTextPassThru"] = "true"; } // we've ended a scripRef else if (!strcmp(token, "/scripRef")) { if (userData["inscriptRef"] == "true") { // like "John 3:16" userData["inscriptRef"] = "false"; pushString(buf, ""); } else { // like "John 3:16" pushString(buf, ""); } } else if (!strncmp(token, "div class=\"sechead\"", 19)) { userData["SecHead"] = "true"; pushString(buf, "
"); } else if (!strncmp(token, "div class=\"title\"", 19)) { userData["SecHead"] = "true"; pushString(buf, "
"); } else if (!strncmp(token, "/div", 4)) { if (userData["SecHead"] == "true") { pushString(buf, "
"); userData["SecHead"] = "false"; } } else if(!strncmp(token, "note", 4)) { pushString(buf, " {"); } else { *(*buf)++ = '<'; for (i = 0; i < strlen(token); i++) *(*buf)++ = token[i]; *(*buf)++ = '>'; //return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END