On Thu, 26 Nov 2015 15:17:24 +0000
Peter von Kaehne <[email protected]> wrote:

> There is nothing in svn either. I just now looked at the support in
> OSIS and it should be a doodle to port this over. I am in the last
> throes of my thesis for uni, so not just now, but during the Christmas
> holidays I will address this if it has not been done by others. 


Please find attached:

A patch against sword 1.7.5, for adding support to images and tables.

-- 
domcox <[email protected]>
diff -bru sword-1.7.5/src/modules/filters/teihtmlhref.cpp sword-1.7.5a2+dfsg/src/modules/filters/teihtmlhref.cpp
--- sword-1.7.5/src/modules/filters/teihtmlhref.cpp	2014-04-17 06:02:17.000000000 +0200
+++ sword-1.7.5a2+dfsg/src/modules/filters/teihtmlhref.cpp	2015-11-28 16:10:41.485646005 +0100
@@ -275,6 +275,52 @@
 				u->suspendTextPassThru = false;
 			}
 		}
+		// <graphic> image tag
+		else if (!strcmp(tag.getName(), "graphic")) {
+			const char *url = tag.getAttribute("url");
+			if (url) {		// assert we have a url attribute
+				SWBuf filepath;
+				if (userData->module) {
+					filepath = userData->module->getConfigEntry("AbsoluteDataPath");
+					if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (url[0] != '/'))
+						filepath += '/';
+				}
+				filepath += url;
+				// images become clickable, if the UI supports showImage.
+				buf.appendFormatted("<a href=\"passagestudy.jsp?action=showImage&value=%s&module=%s\"><img src=\"file:%s\" border=\"0\" /></a>",
+						    URL::encode(filepath.c_str()).c_str(),
+						    URL::encode(u->version.c_str()).c_str(),
+						    filepath.c_str());
+				u->suspendTextPassThru = true;
+			}
+		}
+		// <table> <row> <cell>
+		else if (!strcmp(tag.getName(), "table")) {
+			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+				buf += "<table><tbody>\n";
+			}
+			else if (tag.isEndTag()) {
+				buf += "</tbody></table>\n";
+				u->supressAdjacentWhitespace = true;
+			}
+
+		}
+		else if (!strcmp(tag.getName(), "row")) {
+			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+				buf += "\t<tr>";
+			}
+			else if (tag.isEndTag()) {
+				buf += "</tr>\n";
+			}
+		}
+		else if (!strcmp(tag.getName(), "cell")) {
+			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+				buf += "<td>";
+			}
+			else if (tag.isEndTag()) {
+				buf += "</td>";
+			}
+		}
 
 		else {
 			return false;  // we still didn't handle token
diff -bru sword-1.7.5/src/modules/filters/teixhtml.cpp sword-1.7.5a2+dfsg/src/modules/filters/teixhtml.cpp
--- sword-1.7.5/src/modules/filters/teixhtml.cpp	2014-04-17 06:04:03.000000000 +0200
+++ sword-1.7.5a2+dfsg/src/modules/filters/teixhtml.cpp	2015-11-28 16:46:46.638563403 +0100
@@ -276,7 +276,50 @@
 				u->suspendTextPassThru = false;
 			}
 		}
-
+		// <graphic> image tag
+		else if (!strcmp(tag.getName(), "graphic")) {
+			const char *url = tag.getAttribute("url");
+			if (url) {		// assert we have a url attribute
+				SWBuf filepath;
+				if (userData->module) {
+					filepath = userData->module->getConfigEntry("AbsoluteDataPath");
+					if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (url[0] != '/'))
+						filepath += '/';
+				}
+				filepath += url;
+				buf.appendFormatted("<a href=\"passagestudy.jsp?action=showImage&value=%s&module=%s\"><img src=\"file:%s\" border=\"0\" /></a>",
+						    URL::encode(filepath.c_str()).c_str(),
+						    URL::encode(u->version.c_str()).c_str(),
+						    filepath.c_str());
+				u->suspendTextPassThru = false;
+			}
+		}
+		// <table> <row> <cell>
+		else if (!strcmp(tag.getName(), "table")) {
+			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+				buf += "<table><tbody>\n";
+			}
+			else if (tag.isEndTag()) {
+				buf += "</tbody></table>\n";
+				u->supressAdjacentWhitespace = true;
+			}
+		}
+		else if (!strcmp(tag.getName(), "row")) {
+			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+				buf += "\t<tr>";
+			}
+			else if (tag.isEndTag()) {
+				buf += "</tr>\n";
+			}
+		}
+		else if (!strcmp(tag.getName(), "cell")) {
+			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+				buf += "<td>";
+			}
+			else if (tag.isEndTag()) {
+				buf += "</td>";
+			}
+		}
 		else {
 			return false;  // we still didn't handle token
 		}
_______________________________________________
sword-devel mailing list: [email protected]
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Reply via email to