diff options
Diffstat (limited to 'src/modules/filters/osishtmlhref.cpp')
-rw-r--r-- | src/modules/filters/osishtmlhref.cpp | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/src/modules/filters/osishtmlhref.cpp b/src/modules/filters/osishtmlhref.cpp index bdabd83..3406e1b 100644 --- a/src/modules/filters/osishtmlhref.cpp +++ b/src/modules/filters/osishtmlhref.cpp @@ -34,14 +34,21 @@ SWORD_NAMESPACE_START -class OSISHTMLHREF::QuoteStack : public std::stack<char *> { +namespace { + typedef std::stack<SWBuf> TagStack; +} + +// TODO: this bridge pattern is to preserve binary compat on 1.6.x +class OSISHTMLHREF::TagStacks { +public: + TagStack quoteStack; + TagStack hiStack; }; OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { - inBold = false; inXRefNote = false; suspendLevel = 0; - quoteStack = new QuoteStack(); + tagStacks = new TagStacks(); wordsOfChristStart = "<font color=\"red\"> "; wordsOfChristEnd = "</font> "; if (module) { @@ -56,13 +63,7 @@ OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : } OSISHTMLHREF::MyUserData::~MyUserData() { - // Just in case the quotes are not well formed - while (!quoteStack->empty()) { - char *tagData = quoteStack->top(); - quoteStack->pop(); - delete [] tagData; - } - delete quoteStack; + delete tagStacks; } OSISHTMLHREF::OSISHTMLHREF() { @@ -117,7 +118,7 @@ void processLemma(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) { // show = false; //else { if (!suspendTextPassThru) { - buf.appendFormatted("<small><em><<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\">%s</a>></em></small>", + buf.appendFormatted("<small><em class=\"strongs\"><<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\" class=\"strongs\">%s</a>></em></small>", (gh.length()) ? gh.c_str() : "", URL::encode(val2).c_str(), val2); @@ -147,7 +148,7 @@ void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) { if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2]))) val2+=2; if (!suspendTextPassThru) { - buf.appendFormatted("<small><em>(<a href=\"passagestudy.jsp?action=showMorph&type=%s&value=%s\">%s</a>)</em></small>", + buf.appendFormatted("<small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=%s&value=%s\" class=\"morph\">%s</a>)</em></small>", URL::encode(tag.getAttribute("morph")).c_str(), URL::encode(val).c_str(), val2); @@ -252,19 +253,21 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat SWCATCH ( ... ) { } if (vkey) { //printf("URL = %s\n",URL::encode(vkey->getText()).c_str()); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup>*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str(), + ch, ch); } else { - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup>*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(u->key->getText()).c_str(), + ch, ch); } } @@ -386,12 +389,15 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat // <milestone type="x-p"/> // <milestone type="cQuote" marker="x"/> else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type"))) { - if(!strcmp(tag.getAttribute("type"), "line")) { + if (!strcmp(tag.getAttribute("type"), "line")) { outText("<br />", buf, u); + if (tag.getAttribute("subType") && !strcmp(tag.getAttribute("subType"), "x-PM")) { + outText("<br />", buf, u); + } userData->supressAdjacentWhitespace = true; } - else if(!strcmp(tag.getAttribute("type"),"x-p")) { - if( tag.getAttribute("marker")) + else if (!strcmp(tag.getAttribute("type"),"x-p")) { + if (tag.getAttribute("marker")) outText(tag.getAttribute("marker"), buf, u); else outText("<!p>", buf, u); } @@ -482,17 +488,21 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat if ((!tag.isEndTag()) && (!tag.isEmpty())) { if (type == "bold" || type == "b" || type == "x-b") { outText("<b>", buf, u); - u->inBold = true; } else { // all other types outText("<i>", buf, u); - u->inBold = false; } + u->tagStacks->hiStack.push(tag.toString()); } else if (tag.isEndTag()) { - if(u->inBold) { + SWBuf type = ""; + if (!u->tagStacks->hiStack.empty()) { + XMLTag tag(u->tagStacks->hiStack.top()); + u->tagStacks->hiStack.pop(); + type = tag.getAttribute("type"); + } + if (type == "bold" || type == "b" || type == "x-b") { outText("</b>", buf, u); - u->inBold = false; } else outText("</i>", buf, u); } @@ -519,9 +529,7 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("sID"))) { // if <q> then remember it for the </q> if (!tag.isEmpty()) { - char *tagData = 0; - stdstr(&tagData, tag.toString()); - u->quoteStack->push(tagData); + u->tagStacks->quoteStack.push(tag.toString()); } // Do this first so quote marks are included as WoC @@ -538,11 +546,9 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat // close </q> or <q eID... /> else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("eID"))) { // if it is </q> then pop the stack for the attributes - if (tag.isEndTag() && !u->quoteStack->empty()) { - char *tagData = u->quoteStack->top(); - u->quoteStack->pop(); - XMLTag qTag(tagData); - delete [] tagData; + if (tag.isEndTag() && !u->tagStacks->quoteStack.empty()) { + XMLTag qTag(u->tagStacks->quoteStack.top()); + u->tagStacks->quoteStack.pop(); type = qTag.getAttribute("type"); who = qTag.getAttribute("who"); |