[sword-cvs] sword/src/modules/filters osishtmlhref.cpp,1.14,1.15 osisrtf.cpp,1.24,1.25

sword@www.crosswire.org sword@www.crosswire.org
Sun, 17 Aug 2003 03:00:56 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv11520/src/modules/filters

Modified Files:
	osishtmlhref.cpp osisrtf.cpp 
Log Message:
updated osisrtf and osishtmlhref to be in sync


Index: osishtmlhref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osishtmlhref.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- osishtmlhref.cpp	12 Aug 2003 05:36:30 -0000	1.14
+++ osishtmlhref.cpp	17 Aug 2003 10:00:54 -0000	1.15
@@ -28,10 +28,9 @@
 }
 
 
-OSISHTMLHref::OSISHTMLHref()
-{
-        setTokenStart("<");
-        setTokenEnd(">");
+OSISHTMLHref::OSISHTMLHref() {
+	setTokenStart("<");
+	setTokenEnd(">");
 
 	setEscapeStart("&");
 	setEscapeEnd(";");
@@ -43,17 +42,19 @@
 	addEscapeStringSubstitute("lt", "<");
 	addEscapeStringSubstitute("gt", ">");
 	addEscapeStringSubstitute("quot", "\"");
+	addTokenSubstitute("lg", "<br />");
+	addTokenSubstitute("/lg", "<br />");
 
-        setTokenCaseSensitive(true);
+	setTokenCaseSensitive(true);
 }
 
+
 bool OSISHTMLHref::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
   // manually process if it wasn't a simple substitution
 	if (!substituteToken(buf, token)) {
 		MyUserData *u = (MyUserData *)userData;
 		XMLTag tag(token);
 
-		//printf("token = %s\n",token);
 		// <w> tag
 		if (!strcmp(tag.getName(), "w")) {
 
@@ -103,18 +104,23 @@
 					} while (++i < count);
 				}
 				if ((attrib = tag.getAttribute("morph")) && (show)) {
-					int count = tag.getAttributePartCount("morph");
-					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("morph", i);
-						if (i < 0) i = 0;	// to handle our -1 condition
-						val = strchr(attrib, ':');
-						val = (val) ? (val + 1) : attrib;
-						const char *val2 = val;
-						if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
-							val2+=2;
-						buf.appendFormatted(" <small><em>(<a href=\"type=morph class=%s value=%s\">%s</a>)</em></small> ", tag.getAttribute("morph"), val, val2);
-					} while (++i < count);
+					SWBuf savelemma = tag.getAttribute("savlm");
+					if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
+						show = false;
+					if (show) {
+						int count = tag.getAttributePartCount("morph");
+						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("morph", i);
+							if (i < 0) i = 0;	// to handle our -1 condition
+							val = strchr(attrib, ':');
+							val = (val) ? (val + 1) : attrib;
+							const char *val2 = val;
+							if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
+								val2+=2;
+							buf.appendFormatted(" <small><em>(<a href=\"type=morph class=%s value=%s\">%s</a>)</em></small> ", tag.getAttribute("morph"), val, val2);
+						} while (++i < count);
+					}
 				}
 				if (attrib = tag.getAttribute("POS")) {
 					val = strchr(attrib, ':');
@@ -129,32 +135,31 @@
 
 		// <note> tag
 		else if (!strcmp(tag.getName(), "note")) {
-			if (!tag.isEmpty() && !tag.isEndTag()) {
-				SWBuf footnoteNum = u->fn;
-				SWBuf type = tag.getAttribute("type");
+			if (!tag.isEndTag()) {
+				if (!tag.isEmpty()) {
+					SWBuf type = tag.getAttribute("type");
 
-				if (type != "strongsMarkup") {	// leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
-					int footnoteNumber = (footnoteNum.length()) ? atoi(footnoteNum.c_str()) : 1;
-					VerseKey *vkey;
-					// see if we have a VerseKey * or descendant
-					try {
-						vkey = SWDYNAMIC_CAST(VerseKey, userData->key);
-					}
-					catch ( ... ) {	}
-					if (vkey) {
-						char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
-						    buf.appendFormatted("<a href=\"noteID=%s.%c.%i\"><small><sup>*%c</sup></small></a> ", vkey->getText(), ch, footnoteNumber, ch);
-						SWBuf tmp;
-						tmp.appendFormatted("%i", ++footnoteNumber);
-						u->fn = tmp.c_str();
+					if (type != "strongsMarkup") {	// leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
+						SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+						VerseKey *vkey;
+						// see if we have a VerseKey * or descendant
+						try {
+							vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+						}
+						catch ( ... ) {	}
+						if (vkey) {
+							char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+							buf.appendFormatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), ch, footnoteNumber.c_str(), ch);
+						}
 					}
+					u->suspendTextPassThru = true;
 				}
-				u->suspendTextPassThru = true;
 			}
 			if (tag.isEndTag()) {
 				u->suspendTextPassThru = false;
 			}
 		}
+
 		// <p> paragraph tag
 		else if (!strcmp(tag.getName(), "p")) {
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {	// non-empty start tag
@@ -162,9 +167,11 @@
 			}
 			else if (tag.isEndTag()) {	// end tag
 				buf += "<!/P><br />";
+				userData->supressAdjacentWhitespace = true;
 			}
 			else {					// empty paragraph break marker
 				buf += "<!P><br />";
+				userData->supressAdjacentWhitespace = true;
 			}
 		}
 
@@ -186,17 +193,16 @@
 			else if (tag.isEndTag()) {
 				buf += "<br />";
 			}
+			else if (tag.getAttribute("sID")) {	// empty line marker
+				buf += "<br />";
+			}
 		}
 
-                // <lg>
-                else if (!strcmp(tag.getName(), "lg")) {
-                        buf += "<br />";
-                }
-
-                // <milestone type="line"/>
-                else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line"))) {
-        		buf += "<br />";
-                }
+		// <milestone type="line"/>
+		else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line"))) {
+			buf += "<br />";
+			userData->supressAdjacentWhitespace = true;
+		}
 
 		// <title>
 		else if (!strcmp(tag.getName(), "title")) {
@@ -278,6 +284,46 @@
 			}
 			else {	// empty transChange marker?
 			}
+		}
+
+		// image
+		else if (!strcmp(tag.getName(), "figure")) {
+			const char *src = tag.getAttribute("src");
+			if (!src)		// assert we have a src attribute
+				return false;
+
+			char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)];
+			*filepath = 0;
+			strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath"));
+			strcat(filepath, src);
+
+// we do this because BibleCS looks for this EXACT format for an image tag
+			buf+="<figure src=\"";
+			buf+=filepath;
+			buf+="\" />";
+/*
+			char imgc;
+			for (c = filepath + strlen(filepath); c > filepath && *c != '.'; c--);
+			c++;
+			FILE* imgfile;
+				    if (stricmp(c, "jpg") || stricmp(c, "jpeg")) {
+						  imgfile = fopen(filepath, "r");
+						  if (imgfile != NULL) {
+								buf += "{\\nonshppict {\\pict\\jpegblip ";
+								while (feof(imgfile) != EOF) {
+									   buf.appendFormatted("%2x", fgetc(imgfile));
+								}
+								fclose(imgfile);
+								buf += "}}";
+						  }
+				    }
+				    else if (stricmp(c, "png")) {
+						  buf += "{\\*\\shppict {\\pict\\pngblip ";
+
+						  buf += "}}";
+				    }
+*/
+			delete [] filepath;
 		}
 		
 		else {

Index: osisrtf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisrtf.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- osisrtf.cpp	12 Aug 2003 05:36:30 -0000	1.24
+++ osisrtf.cpp	17 Aug 2003 10:00:54 -0000	1.25
@@ -42,8 +42,9 @@
 	addEscapeStringSubstitute("lt", "<");
 	addEscapeStringSubstitute("gt", ">");
 	addEscapeStringSubstitute("quot", "\"");
-        addTokenSubstitute("lg", "{\\par}");
-        addTokenSubstitute("/lg", "{\\par}");
+	addTokenSubstitute("lg", "{\\par}");
+	addTokenSubstitute("/lg", "{\\par}");
+
 	setTokenCaseSensitive(true);
 }
 
@@ -195,11 +196,11 @@
 			}
 		}
 
-                // <milestone type="line"/>
-                else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line"))) {
-        		buf += "{\\par}";
+		// <milestone type="line"/>
+		else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line"))) {
+			buf += "{\\par}";
 			userData->supressAdjacentWhitespace = true;
-                }
+		}
 
 		// <title>
 		else if (!strcmp(tag.getName(), "title")) {
@@ -270,6 +271,7 @@
 			}
 		}
 
+		// image
 		else if (!strcmp(tag.getName(), "figure")) {
 			const char *src = tag.getAttribute("src");
 			if (!src)		// assert we have a src attribute
@@ -281,7 +283,7 @@
 			strcat(filepath, src);
 
 // we do this because BibleCS looks for this EXACT format for an image tag
-			buf+="<figure src=\"";
+			buf+="<img src=\"";
 			buf+=filepath;
 			buf+="\" />";
 /*