[sword-svn] r3391 - in trunk: . src/modules/filters
refdoc at crosswire.org
refdoc at crosswire.org
Fri Dec 18 08:49:12 MST 2015
Author: refdoc
Date: 2015-12-18 08:49:12 -0700 (Fri, 18 Dec 2015)
New Revision: 3391
Modified:
trunk/ChangeLog
trunk/src/modules/filters/teihtmlhref.cpp
trunk/src/modules/filters/teixhtml.cpp
Log:
added patch by Dominique Corbex to add image support to TEI filters
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-09-09 08:16:38 UTC (rev 3390)
+++ trunk/ChangeLog 2015-12-18 15:49:12 UTC (rev 3391)
@@ -1,4 +1,7 @@
API ChangeLog
+18-Dec-2015 Peter von Kaehne <refdoc at crosswire.org>
+ Added image and table handling to TEI xhtml and htmlhref filters
+ contributed by Dominique Corbex <dominique.corbex at gmail.com>
15-Dec-2014 DM Smith <dmsmith at crosswire.org>
Fixed endless loop in osis2mod for some inputs.
Modified: trunk/src/modules/filters/teihtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/teihtmlhref.cpp 2015-09-09 08:16:38 UTC (rev 3390)
+++ trunk/src/modules/filters/teihtmlhref.cpp 2015-12-18 15:49:12 UTC (rev 3391)
@@ -275,7 +275,53 @@
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
}
Modified: trunk/src/modules/filters/teixhtml.cpp
===================================================================
--- trunk/src/modules/filters/teixhtml.cpp 2015-09-09 08:16:38 UTC (rev 3390)
+++ trunk/src/modules/filters/teixhtml.cpp 2015-12-18 15:49:12 UTC (rev 3391)
@@ -306,7 +306,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
}
More information about the sword-cvs
mailing list