[sword-cvs] sword/src/modules/filters gbfhtmlhref.cpp,1.21,1.22 gbffootnotes.cpp,1.20,1.21
sword@www.crosswire.org
sword@www.crosswire.org
Mon, 22 Dec 2003 11:49:55 -0700
Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv2669
Modified Files:
gbfhtmlhref.cpp gbffootnotes.cpp
Log Message:
work on footnotes
Index: gbfhtmlhref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/gbfhtmlhref.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- gbfhtmlhref.cpp 21 Dec 2003 01:34:29 -0000 1.21
+++ gbfhtmlhref.cpp 22 Dec 2003 18:49:53 -0000 1.22
@@ -15,7 +15,11 @@
* *
***************************************************************************/
+#include <stdlib.h>
#include <gbfhtmlhref.h>
+#include <swmodule.h>
+#include <utilxml.h>
+#include <versekey.h>
#include <ctype.h>
SWORD_NAMESPACE_START
@@ -27,6 +31,7 @@
setTokenCaseSensitive(true);
//addTokenSubstitute("Rf", ")</small></font>");
+ addTokenSubstitute("FA", "<font color=\"#800000\">");
addTokenSubstitute("Rx", "</a>");
addTokenSubstitute("FI", "<i>"); // italics begin
addTokenSubstitute("Fi", "</i>");
@@ -65,18 +70,9 @@
const char *num;
MyUserData *u = (MyUserData *)userData;
- if (!substituteToken(buf, token)) {
- // deal with OSIS note tags. Just hide till OSISRTF
- if (!strncmp(token, "note ", 5)) {
- // let's stop text from going to output
- u->suspendTextPassThru = true;
- }
-
- else if (!strncmp(token, "/note", 5)) {
- u->suspendTextPassThru = false;
- }
-
- else if (!strncmp(token, "w", 1)) {
+ if (!substituteToken(buf, token)) {
+ XMLTag tag(token);
+ if (!strncmp(token, "w", 1)) {
// OSIS Word (temporary until OSISRTF is done)
valto = val;
num = strstr(token, "lemma=\"x-Strongs:");
@@ -169,6 +165,29 @@
}
buf += "\">";
}
+ else if (!strcmp(tag.getName(), "RF")) {
+ 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
+ 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.
+ char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+ buf.appendFormatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), ch, footnoteNumber.c_str(), ch);
+ }
+ u->suspendTextPassThru = true;
+ }
+ }
+ }
+/* else if (!strcmp(tag.getName(), "Rf")) {
+ u->suspendTextPassThru = false;
+ }
else if (!strncmp(token, "RB", 2)) {
buf += "<i> ";
@@ -191,7 +210,7 @@
}
u->suspendTextPassThru = true;
}
-
+*/
else if (!strncmp(token, "FN", 2)) {
buf += "<font face=\"";
for (tok = token + 2; *tok; tok++)
Index: gbffootnotes.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/gbffootnotes.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- gbffootnotes.cpp 7 Jul 2003 01:16:15 -0000 1.20
+++ gbffootnotes.cpp 22 Dec 2003 18:49:53 -0000 1.21
@@ -7,6 +7,10 @@
#include <stdlib.h>
#include <gbffootnotes.h>
+#include <swmodule.h>
+#include <swbuf.h>
+#include <versekey.h>
+#include <utilxml.h>
#ifndef __GNUC__
#else
#include <unixstr.h>
@@ -32,6 +36,105 @@
char GBFFootnotes::processText (SWBuf &text, const SWKey *key, const SWModule *module)
{
+
+ 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 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(), "RF")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ refs = "";
+ startTag = tag;
+ hide = true;
+ tagText = "";
+ continue;
+ }
+ }
+ }
+ else if (!strcmp(tag.getName(), "Rf")) {
+ if (module->isProcessEntryAttributes()) {
+ if(tagText.length() == 1) {
+ if (option) {
+ text += " <FA>(";
+ text.append(tagText);
+ text += ")<Fr>";
+ hide = false;
+ continue;
+ }
+ }
+ 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);
+ if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
+ if (!refs.length())
+ refs = parser.ParseVerseList(tagText.c_str(), parser, true).getRangeText();
+ module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
+ }
+ }
+ hide = false;
+ if (option) {
+ text += startTag;
+ text.append(tagText);
+ }
+ else continue;
+ }
+ if (!hide) {
+ text += '<';
+ text.append(token);
+ text += '>';
+ }
+ 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;
+
+
+
+
+
+
+
+
+ /*
if (!option) { // if we don't want footnotes
char token[4096]; // cheese. Fix.
int tokpos = 0;
@@ -39,10 +142,10 @@
int len;
bool hide = false;
- const char *from;
- SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) {
+ const char *from;
+ SWBuf orig = text;
+ from = orig.c_str();
+ for (text = ""; *from; from++) {
if (*from == '<') {
intoken = true;
tokpos = 0;
@@ -97,7 +200,7 @@
}
}
}
- return 0;
+ return 0;*/
}
SWORD_NAMESPACE_END