[sword-svn] r3482 - in trunk: examples/cmdline src/modules/filters

scribe at crosswire.org scribe at crosswire.org
Sun Jun 25 07:36:24 MST 2017


Author: scribe
Date: 2017-06-25 07:36:23 -0700 (Sun, 25 Jun 2017)
New Revision: 3482

Modified:
   trunk/examples/cmdline/lookup.cpp
   trunk/src/modules/filters/osislemma.cpp
   trunk/src/modules/filters/osisstrongs.cpp
   trunk/src/modules/filters/osisxhtml.cpp
Log:
Reworked strongs and lemma filters to better support any combo of toggle
Added osisxhtml lemma type= support for other than Greek, Hebrew strongs

Modified: trunk/examples/cmdline/lookup.cpp
===================================================================
--- trunk/examples/cmdline/lookup.cpp	2017-06-25 11:45:04 UTC (rev 3481)
+++ trunk/examples/cmdline/lookup.cpp	2017-06-25 14:36:23 UTC (rev 3482)
@@ -37,6 +37,7 @@
 using sword::SWModule;
 using sword::FMT_WEBIF;
 using sword::FMT_HTMLHREF;
+using sword::FMT_XHTML;
 using sword::FMT_RTF;
 using sword::FMT_LATEX;
 using sword::ModMap;
@@ -54,7 +55,7 @@
 //	WebMgr manager((const char *)0);
 //	manager.setJavascript(true);
 //
-	SWMgr manager(new MarkupFilterMgr(FMT_HTMLHREF));
+	SWMgr manager(new MarkupFilterMgr(FMT_XHTML));
 //	SWMgr manager(new MarkupFilterMgr(FMT_WEBIF));
 
 	SWModule *target;
@@ -78,7 +79,7 @@
 
 	// turn all filters to default values
 	manager.setGlobalOption("Headings", "On");
-	manager.setGlobalOption("Strong's Numbers", "On");
+	manager.setGlobalOption("Strong's Numbers", "Off");
 	manager.setGlobalOption("Lemmas", "Off");
 //	manager.setGlobalOption("Greek Accents", "Off");
 

Modified: trunk/src/modules/filters/osislemma.cpp
===================================================================
--- trunk/src/modules/filters/osislemma.cpp	2017-06-25 11:45:04 UTC (rev 3481)
+++ trunk/src/modules/filters/osislemma.cpp	2017-06-25 14:36:23 UTC (rev 3482)
@@ -67,6 +67,15 @@
 				intoken = false;
 				if (token.startsWith("w ")) {	// Word
 					XMLTag wtag(token);
+
+					// always save off lemma if we haven't yet
+					if (!wtag.getAttribute("savlm")) {
+						const char *l = wtag.getAttribute("lemma");
+						if (l) {
+							wtag.setAttribute("savlm", l);
+						}
+					}
+
 					int count = wtag.getAttributePartCount("lemma", ' ');
 					for (int i = 0; i < count; i++) {
 						SWBuf a = wtag.getAttribute("lemma", i, ' ');
@@ -78,6 +87,7 @@
 							count--;
 						}
 					}
+
 					token = wtag;
 					token.trim();
 					// drop <>

Modified: trunk/src/modules/filters/osisstrongs.cpp
===================================================================
--- trunk/src/modules/filters/osisstrongs.cpp	2017-06-25 11:45:04 UTC (rev 3481)
+++ trunk/src/modules/filters/osisstrongs.cpp	2017-06-25 14:36:23 UTC (rev 3482)
@@ -88,6 +88,15 @@
 
 			if (token.startsWith("w ")) {	// Word
 				XMLTag wtag(token);
+
+				// always save off lemma if we haven't yet
+				if (!wtag.getAttribute("savlm")) {
+					const char *l = wtag.getAttribute("lemma");
+					if (l) {
+						wtag.setAttribute("savlm", l);
+					}
+				}
+
 				if (module->isProcessEntryAttributes()) {
 					wordStart = from+1;
 					char gh = 0;
@@ -138,14 +147,14 @@
 						} while (++i < count);
 					}
 
-					if ((attrib = wtag.getAttribute("lemma"))) {
-						int count = wtag.getAttributePartCount("lemma", ' ');
+					if ((attrib = wtag.getAttribute("savlm"))) {
+						int count = wtag.getAttributePartCount("savlm", ' ');
 						int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
 						do {
 							gh = 0;
 							SWBuf lClass = "";
 							SWBuf l = "";
-							attrib = wtag.getAttribute("lemma", i, ' ');
+							attrib = wtag.getAttribute("savlm", i, ' ');
 							if (i < 0) i = 0;	// to handle our -1 condition
 
 							const char *m = strchr(attrib, ':');
@@ -232,35 +241,27 @@
 					wordNum++;
 				}
 
+				// if we won't want strongs, then lets get them out of lemma
 				if (!option) {
-/*
- * Code which handles multiple lemma types.  Kindof works but breaks at least WEBIF filters for strongs.
- *
 					int count = wtag.getAttributePartCount("lemma", ' ');
-					for (int i = 0; i < count; i++) {
+					for (int i = 0; i < count; ++i) {
 						SWBuf a = wtag.getAttribute("lemma", i, ' ');
 						const char *prefix = a.stripPrefix(':');
 						if ((prefix) && (!strcmp(prefix, "x-Strongs") || !strcmp(prefix, "strong") || !strcmp(prefix, "Strong"))) {
 							// remove attribute part
 							wtag.setAttribute("lemma", 0, i, ' ');
-							i--;
-							count--;
+							--i;
+							--count;
 						}
 					}
-* Instead the codee below just removes the lemma attribute
-*****/
-					const char *l = wtag.getAttribute("lemma");
-					if (l) {
-						SWBuf savlm = l;
-						wtag.setAttribute("lemma", 0);
-						wtag.setAttribute("savlm", savlm);
-						token = wtag;
-						token.trim();
-						// drop <>
-						token << 1;
-						token--;
-					}
+
+
 				}
+				token = wtag;
+				token.trim();
+				// drop <>
+				token << 1;
+				token--;
 			}
 			if (token.startsWith("/w")) {	// Word End
 				if (module->isProcessEntryAttributes()) {

Modified: trunk/src/modules/filters/osisxhtml.cpp
===================================================================
--- trunk/src/modules/filters/osisxhtml.cpp	2017-06-25 11:45:04 UTC (rev 3481)
+++ trunk/src/modules/filters/osisxhtml.cpp	2017-06-25 14:36:23 UTC (rev 3482)
@@ -76,14 +76,19 @@
 		int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
 		do {
 			attrib = tag.getAttribute("lemma", i, ' ');
+			SWBuf at = attrib;
+			const char *prefix = at.stripPrefix(':');
 			if (i < 0) i = 0;	// to handle our -1 condition
 			val = strchr(attrib, ':');
 			val = (val) ? (val + 1) : attrib;
 			SWBuf gh;
-			if(*val == 'G')
+			if (*val == 'G') {
 				gh = "Greek";
-			if(*val == 'H')
+			}
+			else if (*val == 'H') {
 				gh = "Hebrew";
+			}
+			else if (prefix) gh = prefix;
 			const char *val2 = val;
 			if ((strchr("GH", *val)) && (isdigit(val[1])))
 				val2++;




More information about the sword-cvs mailing list