[sword-devel] HTML filter patches

Terry Biggs sword-devel@crosswire.org
28 Feb 2001 11:16:42 -0500


--=-l3CK68X/oaDA9BYaul+G
Content-Type: multipart/alternative; boundary="=-zRR2xuy74gt5UEfNAQpo"


--=-zRR2xuy74gt5UEfNAQpo
Content-Type: text/plain

Joachim and Troy,

It seems I saw a place to send patches but I don't remember where it
was.
Joachim you need to look at these since they are html filters I tried
them with BibleTime 3.1 
and they worked ok. 

I need them for gnomesword - the next release will use GtkHTML to
display Bible and Commentary text.
These patches work well on jfb and mhcc.

God Bless

Terry
Rev 1:5

--=-zRR2xuy74gt5UEfNAQpo
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/0.8.2">
</HEAD>
<BODY>Joachim and Troy,<br>
<br>
It seems I saw a place to send patches but I don't remember where it was.<br>
Joachim you need to look at these since they are html filters I tried them with BibleTime 3.1 <br>
and they worked ok. <br>
<br>
I need them for gnomesword - the next release will use GtkHTML to display Bible and Commentary text.<br>
These patches work well on jfb and mhcc.<br>
<br>
God Bless<br>
<br>
Terry<br>
Rev 1:5</BODY>
</HTML>

--=-zRR2xuy74gt5UEfNAQpo--

--=-l3CK68X/oaDA9BYaul+G
Content-Type: text/plain
Content-Disposition: attachment; filename=rwphtml.cpp.diff
Content-Transfer-Encoding: 7bit

--- /home/tbiggs/rwphtml.cpp	Fri Oct 15 14:26:10 1999
+++ /home/tbiggs/Projects/sword-1.5.1a/src/modules/filters/rwphtml.cpp	Mon Feb 19 18:01:27 2001
@@ -28,34 +28,149 @@
 char RWPHTML::ProcessText(char *text, int maxlen, const SWKey *key)
 {
 	char *to, *from;
-	bool ingreek = false;
 	bool inverse = false;
+	bool first_letter = false;
 	int len;
 
-	len = strlen(text) + 1;						// shift string to right of buffer
+	len = strlen(text) + 1;	// shift string to right of buffer
 	if (len < maxlen) {
 		memmove(&text[maxlen - len], text, len);
 		from = &text[maxlen - len];
-	}
-	else	from = text;							// -------------------------------
+	} else	from = text;	// -------------------------------
 	for (to = text; *from; from++) {
 		if (*from == '\\')
 		{
-			if(!ingreek) {
-				ingreek = true;
-				// donīt know what this means, find out later
-				//*to++ = ' ';
+				++from;
+				*to++ = '<';
+				*to++ = 'I';
+				*to++ = '>';
+				*to++ = ' ';
+				*to++ = '<';
+				*to++ = '/';
+				*to++ = 'I';
+				*to++ = '>';				
+				*to++ = '<';
+				*to++ = 'F';
+				*to++ = 'O';
+				*to++ = 'N';
+				*to++ = 'T';
+				*to++ = ' ';
+				*to++ = 'F';
+				*to++ = 'A';
+				*to++ = 'C';
+				*to++ = 'E';
+				*to++ = '=';
+				*to++ = '\"';
+				*to++ = 's';
+				*to++ = 'y';
+				*to++ = 'm';
+				*to++ = 'b';
+				*to++ = 'o';
+				*to++ = 'l';
+				*to++ = '\"';
+				*to++ = '>';
+				first_letter = true;
+				while(*from != '\\')
+				{
+					
+					if((first_letter) && (*from == 'h')){
+						if ( from[1] == 'o') {
+							++from;
+							*to++ = *from;
+							++from;
+							first_letter = false;
+							continue;
+						} else if ( from[1] == 'a') {
+							++from;
+							*to++ = *from;
+							++from;
+							first_letter = false;
+							continue;
+						} else if ( from[1] == 'w') {
+							++from;
+							*to++ = *from;
+							++from;
+							first_letter = false;
+							continue;
+						} else if ( from[1] == 'u') {
+							++from;
+							*to++ = *from;
+							++from;
+							first_letter = false;
+							continue;
+						} else if ( from[1] == -120) {
+							++from;
+							*to++  = 'h';
+							++from;
+							first_letter = false;
+							continue;
+						} else if ( from[1] == 'i') {
+							++from;
+							*to++ = *from;
+							++from;
+							first_letter = false;
+							continue;
+						}
+						first_letter = false;
+					}
+					if((*from == 't') && (from[1] == 'h')) {
+						*to++ = 'q';
+						++from;
+						++from;
+						continue;
+					}
+					if((*from == 'c') && (from[1] == 'h')) {
+						*to++ = 'c';
+						++from;
+						++from;
+						continue;
+					}			
+					if((*from == 'p') && (from[1] == 'h')) {
+						*to++ = 'f';
+						++from;
+						++from;
+						continue; 
+					}			
+					if(*from == 39) ++from;
+					if (*from == 's') {	
+						if (from[1] == ' '
+				    		    || from[1] == ')'
+				    		    || from[1] == '\\'){
+					 		*to++ = 'V';
+						} else *to++ = 's';
+						++from;
+						continue;						
+					}	
+					if (*from == -120) {					
+						++from;					
+					 	*to++ = 'h';						
+						continue; 
+					}		
+					if (*from == -125) {
+						++from;
+						*to++ = 'a';
+						continue;
+					}
+					if (*from == -109) {
+						++from;
+						*to++ = 'w';
+						continue; 
+					}
+					if(*from == '\\') continue;
+					if(*from == ' ') first_letter = true;
+					*to++ = *from;
+					from++;					
+				}
+				*to++ = '<';
+				*to++ = '/';
+				*to++ = 'F';
+				*to++ = 'O';
+				*to++ = 'N';
+				*to++ = 'T';
+				*to++ = '>';
 				continue;
-			}
-			else {
-				ingreek = false;
-				continue;
-			}
-		}
-
-		if ((ingreek) && ((*from == 'h') || (*from == 'H')))
-			continue;		// 'h's are mostly useless in RWP translitterations.  The greek is more correct without them.
-
+			
+		}		
 		if (*from == '#') {	// verse markings (e.g. "#Mark 1:1|")
 			inverse = true;
 			*to++ = '<';

--=-l3CK68X/oaDA9BYaul+G
Content-Type: text/plain
Content-Disposition: attachment; filename=thmlhtml.cpp.diff
Content-Transfer-Encoding: 7bit

--- /home/tbiggs/thmlhtml.cpp	Wed Dec  8 13:12:55 1999
+++ /home/tbiggs/Projects/sword-1.5.1a/src/modules/filters/thmlhtml.cpp	Thu Feb  8 12:12:54 2001
@@ -27,7 +27,7 @@
 
 char ThMLHTML::ProcessText(char *text, int maxlen)
 {
-  char *to, *from, token[50], tokpos = 0;
+  char *to, *from, token[150], tokpos = 0;
   bool intoken 	= false;
   int len;
 
@@ -42,7 +42,7 @@
       if (*from == '<') {
 	intoken = true;
 	tokpos = 0;
-	memset(token, 0, 50);
+	memset(token, 0, 150);
 	continue;
       }
       if (*from == '>')	{
@@ -77,6 +77,28 @@
 	  *to++ = 'L';
 	  *to++ = '>';
 	}
+	else if (!strncmp(token, "scripRef version", 16)) {
+	  *to++ = '<';
+	  *to++ = 'A';
+	  *to++ = ' ';
+	  *to++ = 'H';
+	  *to++ = 'R';
+	  *to++ = 'E';	
+	  *to++ = 'F';	
+	  *to++ = '=';
+	  *to++ = '\"';	
+	  for (unsigned int i = 32; token[i] != '\"'; i++)
+	    *to++ = token[i];
+	  *to++ = '\"';
+	  *to++ = '>';
+  	} 
+	else if (!strncmp(token, "/scripRef", 9)) { 
+	  *to++ = ' ';
+	  *to++ = '<';
+	  *to++ = '/';
+	  *to++ = 'A';
+	  *to++ = '>';	  
+	}	
 	else if (!strncmp(token, "sync type=\"Strongs\" value=\"T", 28)) {
 	  *to++ = '<';
 	  *to++ = 'S';

--=-l3CK68X/oaDA9BYaul+G
Content-Type: text/plain
Content-Disposition: attachment; filename=thmlplain.cpp.diff
Content-Transfer-Encoding: 7bit

--- /home/tbiggs/thmlplain.cpp	Wed Dec  8 13:12:55 1999
+++ /home/tbiggs/Projects/sword-1.5.1a/src/modules/filters/thmlplain.cpp	Mon Feb  5 17:14:35 2001
@@ -16,7 +16,7 @@
 
 char ThMLPlain::ProcessText(char *text, int maxlen)
 {
-  char *to, *from, token[50], tokpos = 0;
+  char *to, *from, token[150], tokpos = 0;
   bool intoken = false;
   int len;
 
@@ -31,7 +31,7 @@
     if (*from == '<') {
       intoken = true;
       tokpos = 0;
-      memset(token, 0, 50);
+      memset(token, 0, 150);
       continue;
     }
     if (*from == '>') {

--=-l3CK68X/oaDA9BYaul+G--