/*************************************************************************** * thmlcgi.cpp - ThML 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 "thmlcgi.h" #include SWORD_NAMESPACE_START ThMLCGI::ThMLCGI() { setTokenStart("<"); setTokenEnd(">"); setTokenCaseSensitive(true); addTokenSubstitute("note", " ("); addTokenSubstitute("/note", ") "); } bool ThMLCGI::handleToken(SWBuf &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)) { buf += ""; if (*val) { buf += val; } buf += ""; } else if (!strncmp(token, "scripRef p", 10) || !strncmp(token, "scripRef v", 10)) { userData["inscriptRef"] = "true"; buf += ""; } // we're starting a scripRef like "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"; buf += ""; } else { // like "John 3:16" buf += ""; buf += userData["lastTextNode"].c_str(); // let's let text resume to output again userData["suspendTextPassThru"] = "false"; buf += ""; } } else if (!strncmp(token, "div class=\"sechead\"", 19)) { userData["SecHead"] = "true"; buf += "
"; } else if (!strncmp(token, "div class=\"title\"", 19)) { userData["SecHead"] = "true"; buf += "
"; } else if (!strncmp(token, "/div", 4)) { if (userData["SecHead"] == "true") { buf += "
"; userData["SecHead"] = "false"; } } else if(!strncmp(token, "note", 4)) { 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