[sword-svn] r2081 - trunk/src/modules/filters
chrislit at www.crosswire.org
chrislit at www.crosswire.org
Wed Sep 19 14:51:31 MST 2007
Author: chrislit
Date: 2007-09-19 14:51:30 -0700 (Wed, 19 Sep 2007)
New Revision: 2081
Modified:
trunk/src/modules/filters/osisstrongs.cpp
trunk/src/modules/filters/teirtf.cpp
trunk/src/modules/filters/thmlrtf.cpp
Log:
some filter updates
Modified: trunk/src/modules/filters/osisstrongs.cpp
===================================================================
--- trunk/src/modules/filters/osisstrongs.cpp 2007-09-17 06:21:29 UTC (rev 2080)
+++ trunk/src/modules/filters/osisstrongs.cpp 2007-09-19 21:51:30 UTC (rev 2081)
@@ -118,7 +118,7 @@
lClass.append(attrib, len);
attrib += (len+1);
}
- if ((lClass == "x-Strongs") || (lClass == "strong")) {
+ if ((lClass == "x-Strongs") || (lClass == "strong") || (lClass == "Strong")) {
gh = isdigit(attrib[0]) ? 0:attrib[0];
if (!gh) {
if (vkey) {
Modified: trunk/src/modules/filters/teirtf.cpp
===================================================================
--- trunk/src/modules/filters/teirtf.cpp 2007-09-17 06:21:29 UTC (rev 2080)
+++ trunk/src/modules/filters/teirtf.cpp 2007-09-19 21:51:30 UTC (rev 2081)
@@ -1,207 +1,182 @@
-/***************************************************************************
- teirtf.cpp - TEI to RTF filter
- -------------------
- begin : 2006-07-03
- copyright : 2006 by CrossWire Bible Society
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <teirtf.h>
-#include <utilxml.h>
-#include <swmodule.h>
-
-SWORD_NAMESPACE_START
-
-
-TEIRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
- BiblicalText = false;
- if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
- }
-}
-
-
-TEIRTF::TEIRTF() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setEscapeStart("&");
- setEscapeEnd(";");
-
- setEscapeStringCaseSensitive(true);
-
- addEscapeStringSubstitute("amp", "&");
- addEscapeStringSubstitute("apos", "'");
- addEscapeStringSubstitute("lt", "<");
- addEscapeStringSubstitute("gt", ">");
- addEscapeStringSubstitute("quot", "\"");
-
- setTokenCaseSensitive(true);
-}
-
-
-bool TEIRTF::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);
-
- // <p> paragraph tag
- if (!strcmp(tag.getName(), "p")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) { // non-empty start tag
- buf += "{\\par}";
- }
- else if (tag.isEndTag()) { // end tag
- buf += "{\\par}";
- userData->supressAdjacentWhitespace = true;
- }
- else { // empty paragraph break marker
- buf += "{\\par\\par}";
- userData->supressAdjacentWhitespace = true;
- }
- }
-
- // <hi>
- else if (!strcmp(tag.getName(), "hi")) {
- SWBuf rend = tag.getAttribute("rend");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (rend == "ital")
- buf += "{\\i1 ";
- else if (rend == "bold")
- buf += "{\\b1 ";
- else if (rend == "sup")
- buf += "{\\super ";
-
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <entryFree>
- else if (!strcmp(tag.getName(), "entryFree")) {
- SWBuf n = tag.getAttribute("n");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (n != "") {
- buf += "{\\b1 ";
- buf += n;
- buf += ". }"; }
- }
- }
-
- // <sense>
- else if (!strcmp(tag.getName(), "sense")) {
- SWBuf n = tag.getAttribute("n");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (n != "") {
- buf += "{\\par\\b1 ";
- buf += n;
- buf += ". }";
- }
- }
- else if (tag.isEndTag()) {
- buf += "\\par ";
- }
- }
-
- // <div>
- else if (!strcmp(tag.getName(), "div")) {
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf.append("\\par\\par\\pard ");
- }
- else if (tag.isEndTag()) {
- }
- }
-
- // <pos>
- else if (!strcmp(tag.getName(), "pos")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <gen>
- else if (!strcmp(tag.getName(), "gen")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <case>
- else if (!strcmp(tag.getName(), "case")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <tr>
- else if (!strcmp(tag.getName(), "tr")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <number>
- else if (!strcmp(tag.getName(), "number")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <mood>
- else if (!strcmp(tag.getName(), "mood")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <etym>
- else if (!strcmp(tag.getName(), "etym")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "[";
- }
- else if (tag.isEndTag()) {
- buf += "]";
- }
- }
-
- else {
- return false; // we still didn't handle token
- }
- }
- return true;
-}
-
-
-SWORD_NAMESPACE_END
-
+/***************************************************************************
+ teirtf.cpp - TEI to RTF filter
+ -------------------
+ begin : 2006-07-03
+ copyright : 2006 by CrossWire Bible Society
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <teirtf.h>
+#include <utilxml.h>
+#include <swmodule.h>
+#include <versekey.h>
+
+SWORD_NAMESPACE_START
+
+
+TEIRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ BiblicalText = false;
+ if (module) {
+ version = module->Name();
+ BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ }
+}
+
+
+TEIRTF::TEIRTF() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+
+ addEscapeStringSubstitute("amp", "&");
+ addEscapeStringSubstitute("apos", "'");
+ addEscapeStringSubstitute("lt", "<");
+ addEscapeStringSubstitute("gt", ">");
+ addEscapeStringSubstitute("quot", "\"");
+
+ setTokenCaseSensitive(true);
+}
+
+
+bool TEIRTF::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);
+
+ // <p> paragraph tag
+ if (!strcmp(tag.getName(), "p")) {
+ if (!tag.isEndTag()) { // non-empty start tag
+ buf += "{\\sb100\\fi200\\par}";
+ }
+ }
+
+ // <hi>
+ else if (!strcmp(tag.getName(), "hi")) {
+ SWBuf rend = tag.getAttribute("rend");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (rend == "ital")
+ buf += "{\\i1 ";
+ else if (rend == "bold")
+ buf += "{\\b1 ";
+ else if (rend == "sup")
+ buf += "{\\super ";
+
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <entryFree>
+ else if (!strcmp(tag.getName(), "entryFree")) {
+ SWBuf n = tag.getAttribute("n");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (n != "") {
+ buf += "{\\b1 ";
+ buf += n;
+ buf += ". }"; }
+ }
+ }
+
+ // <sense>
+ else if (!strcmp(tag.getName(), "sense")) {
+ SWBuf n = tag.getAttribute("n");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (n != "") {
+ buf += "{\\sb100\\par\\b1 ";
+ buf += n;
+ buf += ". }";
+ }
+ }
+ }
+
+ // <div>
+ else if (!strcmp(tag.getName(), "div")) {
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf.append("{\\pard\\sa300}");
+ }
+ else if (tag.isEndTag()) {
+ }
+ }
+
+ // <pos>, <gen>, <case>, <gram>, <number>, <mood>
+ else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || !strcmp(tag.getName(), "mood")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "{\\i1 ";
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <tr>
+ else if (!strcmp(tag.getName(), "tr")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "{\\i1 ";
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <etym>
+ else if (!strcmp(tag.getName(), "etym")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "[";
+ }
+ else if (tag.isEndTag()) {
+ buf += "]";
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ SWBuf type = tag.getAttribute("type");
+
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ VerseKey *vkey;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ if (vkey) {
+ buf.appendFormatted("{\\super <a href=\"\">*%s</a>} ", footnoteNumber.c_str());
+ }
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) {
+ u->suspendTextPassThru = false;
+ }
+ }
+
+ else {
+ return false; // we still didn't handle token
+ }
+
+ }
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
+
Modified: trunk/src/modules/filters/thmlrtf.cpp
===================================================================
--- trunk/src/modules/filters/thmlrtf.cpp 2007-09-17 06:21:29 UTC (rev 2080)
+++ trunk/src/modules/filters/thmlrtf.cpp 2007-09-19 21:51:30 UTC (rev 2081)
@@ -147,7 +147,7 @@
addTokenSubstitute("/i", "}");
addTokenSubstitute("b", "{\\b1 ");
addTokenSubstitute("/b", "}");
- addTokenSubstitute("p", "\\par ");
+ addTokenSubstitute("p", "{\\fi200\\par}");
addTokenSubstitute("p /", "\\par\\pard ");
//we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant
More information about the sword-cvs
mailing list