[sword-cvs] sword/src/modules/filters thmlfootnotes.cpp,1.14,1.15 thmlhtmlhref.cpp,1.41,1.42 thmlscripref.cpp,1.15,1.16
sword@www.crosswire.org
sword@www.crosswire.org
Sun, 21 Dec 2003 16:33:12 -0700
Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv23989/src/modules/filters
Modified Files:
thmlfootnotes.cpp thmlhtmlhref.cpp thmlscripref.cpp
Log Message:
Fixed scripRef to use entryAttributes
Index: thmlfootnotes.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlfootnotes.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- thmlfootnotes.cpp 21 Dec 2003 10:42:01 -0000 1.14
+++ thmlfootnotes.cpp 21 Dec 2003 23:33:10 -0000 1.15
@@ -69,7 +69,10 @@
}
if (hide && tag.isEndTag()) {
if (module->isProcessEntryAttributes()) {
- sprintf(buf, "%i", footnoteNum++);
+ SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"];
+ footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0;
+ sprintf(buf, "%i", ++footnoteNum);
+ module->getEntryAttributes()["Footnote"]["count"]["value"] = buf;
StringList attributes = startTag.getAttributeNames();
for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
Index: thmlhtmlhref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlhtmlhref.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- thmlhtmlhref.cpp 21 Dec 2003 10:42:01 -0000 1.41
+++ thmlhtmlhref.cpp 21 Dec 2003 23:33:10 -0000 1.42
@@ -36,6 +36,7 @@
setTokenEnd(">");
setTokenCaseSensitive(true);
+ addTokenSubstitute("scripture", "<i> ");
addTokenSubstitute("/scripture", "</i> ");
}
@@ -103,65 +104,54 @@
u->suspendTextPassThru = false;
}
}
- else if (tag.getName() && !strcmp(tag.getName(), "scripRef")) {
- if (tag.isEndTag()) {
- if (u->inscriptRef) { // like "<scripRef passage="John 3:16">John 3:16</scripRef>"
- if (u->BiblicalText)
- buf += "<small><sup>*x</sup></small>";
- buf += "</a> ";
- u->inscriptRef = false;
- u->suspendTextPassThru = false;
- }
- else { // end of scripRef like "<scripRef>John 3:16</scripRef>"
- buf += " <a href=\"";
+ // <scripRef> tag
+ else if (!strcmp(tag.getName(), "scripRef")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
if (u->BiblicalText) {
- if (u->version) {
- buf += "version=";
- buf += u->version;
- buf += " ";
+ VerseKey *vkey;
+ // see if we have a VerseKey * or descendant
+ try {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ catch ( ... ) {}
+ if (vkey) {
+ // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
+ buf.appendFormatted("<a href=\"noteID=%s.x.%s\"><small><sup>*x</sup></small></a> ", vkey->getText(), footnoteNumber.c_str());
}
+ u->suspendTextPassThru = true;
}
- buf += "passage=";
- buf += u->lastTextNode.c_str();
- buf += "\">";
- if (u->BiblicalText)
- buf += "<small><sup>*x</sup></small>";
else {
- buf += u->lastTextNode.c_str();
+ SWBuf refList = u->module->getEntryAttributes()["Footnote"][footnoteNumber]["refList"];
+ SWBuf version = tag.getAttribute("version");
+ buf += " <a href=\"";
+ if (version.length()) {
+ buf += "version=";
+ buf += version;
+ buf += " ";
+ }
+ buf += "passage=";
+ buf += refList.c_str();
+ buf += "\">";
}
- buf += "</a> ";
- // let's let text resume to output again
- u->suspendTextPassThru = false;
}
}
- else if (tag.getAttribute("passage")) { //passage given
- u->inscriptRef = true;
-
- buf += " <a href=\"";
- SWBuf version = tag.getAttribute("version");
- if (version.length()) {
- buf += "version=";
- buf += version;
- buf += " ";
- }
- SWBuf passage = tag.getAttribute("passage");
- if (passage.length()) {
- buf += "passage=";
- buf += passage;
+ if (tag.isEndTag()) { // </scripRef>
+ if (!u->BiblicalText) {
+ buf += u->lastTextNode.c_str();
+ buf += "</a> ";
}
- buf += "\">";
- u->suspendTextPassThru = true;
- }
- else { //no passage or version given
- u->inscriptRef = false;
- // let's stop text from going to output
- u->suspendTextPassThru = true;
+ // let's let text resume to output again
+ u->suspendTextPassThru = false;
}
}
+/* not sure what this is but looked at the spec and this is just around quoted Scripture, not Scripture references; plus needs to check if it's not an endtag; added to simple replacement at top of this file.
else if (tag.getName() && !strcmp(tag.getName(), "scripture")) {
u->inscriptRef = true;
buf += "<i>";
}
+*/
else if (tag.getName() && !strcmp(tag.getName(), "div")) {
if (tag.isEndTag() && u->SecHead) {
buf += "</i></b><br />";
Index: thmlscripref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/thmlscripref.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- thmlscripref.cpp 7 Jul 2003 01:24:16 -0000 1.15
+++ thmlscripref.cpp 21 Dec 2003 23:33:10 -0000 1.16
@@ -7,6 +7,9 @@
#include <stdlib.h>
#include <thmlscripref.h>
+#include <utilxml.h>
+#include <versekey.h>
+#include <swmodule.h>
#ifndef __GNUC__
#else
#include <unixstr.h>
@@ -30,45 +33,92 @@
char ThMLScripref::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- if (!option) { // if we don't want scriprefs
- bool intoken = false;
- bool hide = false;
+ SWBuf token;
+ bool intoken = false;
+ bool hide = false;
+ SWBuf tagText;
+ XMLTag startTag;
+ SWBuf refs = "";
+ int footnoteNum = 1;
+ char buf[254];
+ VerseKey parser = key->getText();
- SWBuf token;
- SWBuf orig = text;
- const char *from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '<') { //new token was found
- intoken = true;
- token = "";
- continue;
- }
- else if (*from == '>') { // process tokens
- intoken = false;
- if (!strnicmp(token.c_str(), "scripRef", 8)) {
- hide = true;
- continue;
+ SWBuf orig = text;
+ const char *from = orig.c_str();
+
+ for (text = ""; *from; from++) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ if (*from == '>') { // process tokens
+ intoken = false;
+
+ XMLTag tag(token);
+ if (!strcmp(tag.getName(), "scripRef")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ refs = "";
+ startTag = tag;
+ hide = true;
+ tagText = "";
+ continue;
+ }
}
- else if (!strnicmp(token.c_str(), "/scripRef", 9)) {
- hide = false;
- continue;
+ if (hide && tag.isEndTag()) {
+ if (module->isProcessEntryAttributes()) {
+ SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"];
+ footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0;
+ sprintf(buf, "%i", ++footnoteNum);
+ module->getEntryAttributes()["Footnote"]["count"]["value"] = buf;
+ StringList attributes = startTag.getAttributeNames();
+ for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
+ module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
+ }
+ module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
+ startTag.setAttribute("swordFootnote", buf);
+ SWBuf passage = startTag.getAttribute("passage");
+ if (passage.length())
+ refs = parser.ParseVerseList(passage.c_str(), parser, true).getRangeText();
+ else refs = parser.ParseVerseList(tagText.c_str(), parser, true).getRangeText();
+ module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
+ }
+ hide = false;
+ if (option) { // we want the tag in the text
+ text += startTag;
+ text.append(tagText);
+ }
+ else continue;
}
+ }
- // if not a scripref token, keep token in text
- if (!hide) {
- text += '<';
- text += token;
- text += '>';
- }
- continue;
+ // if not a scripRef token, keep token in text
+ if ((!strcmp(tag.getName(), "scripRef")) && (!tag.isEndTag())) {
+ SWBuf osisRef = tag.getAttribute("passage");
+ if (refs.length())
+ refs += "; ";
+ refs += osisRef;
}
- if (intoken) {
- token += *from; //copy chars of found token
+ if (!hide) {
+ text += '<';
+ text.append(token);
+ text += '>';
}
- else if (!hide) {
- text += *from;
+ else {
+ tagText += '<';
+ tagText.append(token);
+ tagText += '>';
}
+ continue;
}
+ if (intoken) { //copy token
+ token += *from;
+ }
+ else if (!hide) { //copy text which is not inside a token
+ text += *from;
+ }
+ else tagText += *from;
}
return 0;
}