[sword-cvs] sword/src/modules/filters osishtmlhref.cpp,1.10,1.11 osisplain.cpp,1.6,1.7 osisrtf.cpp,1.15,1.16

sword@www.crosswire.org sword@www.crosswire.org
Sat, 26 Jul 2003 17:02:46 -0700


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

Modified Files:
	osishtmlhref.cpp osisplain.cpp osisrtf.cpp 
Log Message:
OSIS filter updates

Index: osishtmlhref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osishtmlhref.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- osishtmlhref.cpp	28 Jun 2003 22:00:32 -0000	1.10
+++ osishtmlhref.cpp	27 Jul 2003 00:02:44 -0000	1.11
@@ -24,10 +24,21 @@
 
 OSISHTMLHref::OSISHTMLHref()
 {
-  setTokenStart("<");
-  setTokenEnd(">");
-	
-  setTokenCaseSensitive(true);  
+        setTokenStart("<");
+        setTokenEnd(">");
+
+	setEscapeStart("&");
+	setEscapeEnd(";");
+
+	setEscapeStringCaseSensitive(true);
+
+	addEscapeStringSubstitute("amp", "&");
+	addEscapeStringSubstitute("apos", "'");
+	addEscapeStringSubstitute("lt", "<");
+	addEscapeStringSubstitute("gt", ">");
+	addEscapeStringSubstitute("quot", "\"");
+
+        setTokenCaseSensitive(true);
 }
 
 bool OSISHTMLHref::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
@@ -56,7 +67,7 @@
 					lastText = userData["lastTextNode"].c_str();
 				}
 				else lastText = "stuff";
-					
+
 				const char *attrib;
 				const char *val;
 				if (attrib = tag.getAttribute("xlit")) {
@@ -94,7 +105,7 @@
 						val = strchr(attrib, ':');
 						val = (val) ? (val + 1) : attrib;
 						const char *val2 = val;
-						if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2]))) 
+						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);
@@ -108,14 +119,14 @@
 				/*if (endTag)
 					buf += "}";*/
 			}
-		}				
- 
+		}
+
 		// <note> tag
-		else if (!strcmp(tag.getName(), "note")) {	
-			if (!tag.isEmpty() && !tag.isEndTag()) {		
+		else if (!strcmp(tag.getName(), "note")) {
+			if (!tag.isEmpty() && !tag.isEndTag()) {
 				SWBuf footnoteNum = userData["fn"];
 				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;
@@ -133,8 +144,8 @@
 					}
 				}
 				userData["suspendTextPassThru"] = "true";
-			}	   
-			if (tag.isEndTag()) {	
+			}
+			if (tag.isEndTag()) {
 				userData["suspendTextPassThru"] = "false";
 			}
 		}
@@ -150,7 +161,7 @@
 				buf += "<!P><br />";
 			}
 		}
-		
+
 		// <reference> tag
 		else if (!strcmp(tag.getName(), "reference")) {
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
@@ -159,24 +170,28 @@
 			else if (tag.isEndTag()) {
 				buf += "</a>";
 			}
-			else {	// empty reference marker
-				// -- what should we do?  nothing for now.
-			}
 		}
 
-		// <line> poetry, etc
-		else if (!strcmp(tag.getName(), "line")) {
-			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
-				buf += "<>";
-			}
-			else if (tag.isEndTag()) {
+		// <l> poetry, etc
+		else if (!strcmp(tag.getName(), "l")) {
+			if (tag.isEmpty()) {
 				buf += "<br />";
 			}
-			else {	// empty line marker
+			else if (tag.isEndTag()) {
 				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 />";
+                }
+
 		// <title>
 		else if (!strcmp(tag.getName(), "title")) {
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
@@ -185,17 +200,13 @@
 			else if (tag.isEndTag()) {
 				buf += "</b><br />";
 			}
-			else {	// empty title marker
-				// what to do?  is this even valid?
-				buf += "<br />";
-			}
 		}
 
 		// <hi> hi?  hi contrast?
 		else if (!strcmp(tag.getName(), "hi")) {
 			SWBuf type = tag.getAttribute("type");
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
-				if (type == "b") {
+				if (type == "b" || type == "x-b") {
 					buf += "<b> ";
 					userData["inBold"] = "true";
 				}

Index: osisplain.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisplain.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- osisplain.cpp	26 Jul 2003 23:11:06 -0000	1.6
+++ osisplain.cpp	27 Jul 2003 00:02:44 -0000	1.7
@@ -24,19 +24,26 @@
 OSISPlain::OSISPlain() {
 	setTokenStart("<");
 	setTokenEnd(">");
-  
+
 	setEscapeStart("&");
 	setEscapeEnd(";");
-  
+
 	setEscapeStringCaseSensitive(true);
-  
+
 	addEscapeStringSubstitute("amp", "&");
 	addEscapeStringSubstitute("apos", "'");
 	addEscapeStringSubstitute("lt", "<");
 	addEscapeStringSubstitute("gt", ">");
 	addEscapeStringSubstitute("quot", "\"");
-  
-	setTokenCaseSensitive(true);  
+
+
+        addTokenSubstitute("title", "\n");
+        addTokenSubstitute("/title", "\n");
+        addTokenSubstitute("/l", "\n");
+        addTokenSubstitute("lg", "\n");
+        addTokenSubstitute("/lg", "\n");
+
+        setTokenCaseSensitive(true);
 }
 
 char OSISPlain::processText(SWBuf &text, const SWKey *key, const SWModule *module)
@@ -61,8 +68,9 @@
 }
 
 bool OSISPlain::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
-  // manually process if it wasn't a simple substitution
+        // manually process if it wasn't a simple substitution
 	if (!substituteToken(buf, token)) {
+                XMLTag tag(token);
 		if (((*token == 'w') && (token[1] == ' ')) ||
 		((*token == '/') && (token[1] == 'w') && (!token[2]))) {
 			bool start = false;
@@ -73,11 +81,11 @@
 				}
 				start = true;
 			}
-			XMLTag tag = (start) ? token : userData["w"].c_str();
+			tag = (start) ? token : userData["w"].c_str();
 			bool show = true;	// to handle unplaced article in kjv2003-- temporary till combined
 
 			SWBuf lastText = (start) ? "stuff" : userData["lastTextNode"].c_str();
-					
+
 			const char *attrib;
 			const char *val;
 			if (attrib = tag.getAttribute("xlit")) {
@@ -144,16 +152,10 @@
 				buf += "\n";
 		}
 
-		// <line> poetry, etc
-		else if ((!strncmp(token, "line", 4)) ||
-			(!strncmp(token, "/line", 5))) {
-				buf += "\n";
-		}
-
-		// <title>
-		else if (!strncmp(token, "/title", 6)) {
-			buf += "\n";
-		}
+                // <milestone type="line"/>
+                else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line"))) {
+        		buf += "\n";
+                }
 
 		else {
 			return false;  // we still didn't handle token

Index: osisrtf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisrtf.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- osisrtf.cpp	25 Jul 2003 18:50:25 -0000	1.15
+++ osisrtf.cpp	27 Jul 2003 00:02:44 -0000	1.16
@@ -30,14 +30,17 @@
 	setEscapeEnd(";");
   
 	setEscapeStringCaseSensitive(true);
-  
+
 	addEscapeStringSubstitute("amp", "&");
 	addEscapeStringSubstitute("apos", "'");
 	addEscapeStringSubstitute("lt", "<");
 	addEscapeStringSubstitute("gt", ">");
 	addEscapeStringSubstitute("quot", "\"");
-  
-	setTokenCaseSensitive(true);  
+
+        addTokenSubstitute("lg", "\\par ");
+        addTokenSubstitute("/lg", "\\par ");
+
+	setTokenCaseSensitive(true);
 }
 
 char OSISRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module)
@@ -191,9 +194,6 @@
 			else if (tag.isEndTag()) {
 				buf += "</a>}";
 			}
-			else {	// empty reference marker
-				// -- what should we do?  nothing for now.
-			}
 		}
 
 		// <l> poetry
@@ -204,14 +204,16 @@
 			else if (tag.isEndTag()) {
 				buf += "\\par}";
 			}
-			else {	// empty line marker
-				buf += "\\par";
+			else if (tag.getAttribute("sID")) {	// empty line marker
+				buf += "\\par ";
 			}
 		}
+
                 // <milestone type="line"/>
                 else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line"))) {
-        		buf += "\\par";
+        		buf += "\\par ";
                 }
+
 		// <title>
 		else if (!strcmp(tag.getName(), "title")) {
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
@@ -220,13 +222,9 @@
 			else if (tag.isEndTag()) {
 				buf += "\\par}";
 			}
-			else {	// empty title marker
-				// what to do?  is this even valid?
-				buf += "\\par";
-			}
 		}
 
-		// <hi> hi?  hi contrast?
+		// <hi>
 		else if (!strcmp(tag.getName(), "hi")) {
 			SWBuf type = tag.getAttribute("type");
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
@@ -238,9 +236,6 @@
 			else if (tag.isEndTag()) {
 				buf += "}";
 			}
-			else {	// empty hi marker
-				// what to do?  is this even valid?
-			}
 		}
 
 		// <q> quote
@@ -285,8 +280,6 @@
 			}
 			else if (tag.isEndTag()) {
 				buf += "}";
-			}
-			else {	// empty transChange marker?
 			}
 		}