[sword-svn] r2566 - trunk/src/modules/filters

scribe at crosswire.org scribe at crosswire.org
Thu Oct 14 06:40:59 MST 2010


Author: scribe
Date: 2010-10-14 06:40:59 -0700 (Thu, 14 Oct 2010)
New Revision: 2566

Modified:
   trunk/src/modules/filters/osishtmlhref.cpp
Log:
enabled nested <hi> tags to be as deep and in whatever order they want


Modified: trunk/src/modules/filters/osishtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/osishtmlhref.cpp	2010-10-05 03:45:30 UTC (rev 2565)
+++ trunk/src/modules/filters/osishtmlhref.cpp	2010-10-14 13:40:59 UTC (rev 2566)
@@ -34,14 +34,14 @@
 
 SWORD_NAMESPACE_START
 
-class OSISHTMLHREF::QuoteStack : public std::stack<char *> {
+class OSISHTMLHREF::TagStack : public std::stack<SWBuf> {
 };
 
 OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
-	inBold = false;
 	inXRefNote    = false;
 	suspendLevel = 0;
-	quoteStack = new QuoteStack();
+	quoteStack = new TagStack();
+	hiStack = new TagStack();
 	wordsOfChristStart = "<font color=\"red\"> ";
 	wordsOfChristEnd   = "</font> ";
 	if (module) {
@@ -56,13 +56,8 @@
 }
 
 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 hiStack;
 }
 
 OSISHTMLHREF::OSISHTMLHREF() {
@@ -487,17 +482,18 @@
 			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->hiStack->push(tag.toString());
 			}
 			else if (tag.isEndTag()) {
-				if(u->inBold) {
+				XMLTag tag(u->hiStack->top());
+				u->hiStack->pop();
+				SWBuf type = tag.getAttribute("type");
+				if (type == "bold" || type == "b" || type == "x-b") {
 					outText("</b>", buf, u);
-					u->inBold = false;
 				}
 				else outText("</i>", buf, u);
 			}
@@ -524,9 +520,7 @@
 			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->quoteStack->push(tag.toString());
 				}
 
 				// Do this first so quote marks are included as WoC
@@ -544,10 +538,8 @@
 			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();
+					XMLTag qTag(u->quoteStack->top());
 					u->quoteStack->pop();
-					XMLTag qTag(tagData);
-					delete [] tagData;
 
 					type    = qTag.getAttribute("type");
 					who     = qTag.getAttribute("who");




More information about the sword-cvs mailing list