Attached is an updated patch to do this as suggested by Greg. It makes RenderText() take another default-value argument. No change to old behavior, unless you explicitly provide that (4th) parameter as "true".
The patch sets a field in SWModule, which is then pulled into the filters' user data structure, and that is used to determine whether to include n=X content after *n/*x. Other ideas to replace *n/*x with something considered less ugly or more demonstrative would be good. For myself, well, it'll do for now; it's been that way for a decade, after all. Feedback welcome.
Index: src/modules/swmodule.cpp =================================================================== --- src/modules/swmodule.cpp (revision 2676) +++ src/modules/swmodule.cpp (working copy) @@ -861,7 +861,7 @@ * RET: this module's text at current key location massaged by RenderText filters */ - const char *SWModule::RenderText(const char *buf, int len, bool render) { +const char *SWModule::RenderText(const char *buf, int len, bool render, bool includeNumbers) { bool savePEA = isProcessEntryAttributes(); if (!buf) { entryAttributes.clear(); @@ -886,8 +886,10 @@ optionFilter(tmpbuf, key); if (render) { + markers = includeNumbers; renderFilter(tmpbuf, key); encodingFilter(tmpbuf, key); + markers = false; } else stripFilter(tmpbuf, key); } Index: src/modules/filters/thmlxhtml.cpp =================================================================== --- src/modules/filters/thmlxhtml.cpp (revision 2676) +++ src/modules/filters/thmlxhtml.cpp (working copy) @@ -39,6 +39,7 @@ version = module->Name(); BiblicalText = (!strcmp(module->Type(), "Biblical Texts")); SecHead = false; + markers = module->markers; } } @@ -208,6 +209,7 @@ if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { @@ -217,23 +219,25 @@ 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=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } else { char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(u->key->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } u->suspendTextPassThru = true; } @@ -267,6 +271,7 @@ } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { @@ -276,11 +281,11 @@ 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()); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x%s</sup></small></a>", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), - URL::encode(vkey->getText()).c_str()); - + URL::encode(vkey->getText()).c_str(), + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } } Index: src/modules/filters/gbfhtmlhref.cpp =================================================================== --- src/modules/filters/gbfhtmlhref.cpp (revision 2676) +++ src/modules/filters/gbfhtmlhref.cpp (working copy) @@ -35,6 +35,7 @@ GBFHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { if (module) { version = module->Name(); + markers = module->markers; } } @@ -231,6 +232,7 @@ else if (!strcmp(tag.getName(), "RF")) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { @@ -240,10 +242,11 @@ 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=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n</sup></small></a> ", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), - URL::encode(vkey->getText()).c_str()); + URL::encode(vkey->getText()).c_str(), + (u->markers ? URL::encode(noteName.c_str()).c_str(): "")); } u->suspendTextPassThru = true; } Index: src/modules/filters/osisxhtml.cpp =================================================================== --- src/modules/filters/osisxhtml.cpp (revision 2676) +++ src/modules/filters/osisxhtml.cpp (working copy) @@ -127,6 +127,7 @@ OSISXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { inXRefNote = false; + markers = module->markers; suspendLevel = 0; tagStacks = new TagStacks(); wordsOfChristStart = "<span class=\"wordsOfJesus\"> "; @@ -252,6 +253,7 @@ if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); @@ -265,22 +267,24 @@ SWCATCH ( ... ) { } if (vkey) { //printf("URL = %s\n",URL::encode(vkey->getText()).c_str()); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } else { - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(u->key->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } } } Index: src/modules/filters/osishtmlhref.cpp =================================================================== --- src/modules/filters/osishtmlhref.cpp (revision 2676) +++ src/modules/filters/osishtmlhref.cpp (working copy) @@ -114,6 +114,7 @@ OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { inXRefNote = false; + markers = module->markers; suspendLevel = 0; tagStacks = new TagStacks(); wordsOfChristStart = "<font color=\"red\"> "; @@ -240,6 +241,7 @@ if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); @@ -253,22 +255,24 @@ SWCATCH ( ... ) { } if (vkey) { //printf("URL = %s\n",URL::encode(vkey->getText()).c_str()); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } else { - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(u->key->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } } } Index: src/modules/filters/gbfxhtml.cpp =================================================================== --- src/modules/filters/gbfxhtml.cpp (revision 2676) +++ src/modules/filters/gbfxhtml.cpp (working copy) @@ -41,6 +41,7 @@ GBFXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { if (module) { version = module->Name(); + markers = module->markers; } } @@ -168,6 +169,7 @@ else if (!strcmp(tag.getName(), "RF")) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { @@ -177,10 +179,11 @@ 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=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n</sup></small></a> ", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), - URL::encode(vkey->getText()).c_str()); + URL::encode(vkey->getText()).c_str(), + (u->markers ? URL::encode(noteName.c_str()).c_str(): "")); } u->suspendTextPassThru = true; } Index: src/modules/filters/thmlhtmlhref.cpp =================================================================== --- src/modules/filters/thmlhtmlhref.cpp (revision 2676) +++ src/modules/filters/thmlhtmlhref.cpp (working copy) @@ -29,6 +29,8 @@ #include <versekey.h> #include <url.h> +#include <stdio.h> + SWORD_NAMESPACE_START @@ -37,6 +39,8 @@ version = module->Name(); BiblicalText = (!strcmp(module->Type(), "Biblical Texts")); SecHead = false; + markers = module->markers; + printf("==> markers %s\n", (markers ? "YES" : "NO")); } } @@ -206,6 +210,7 @@ if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { @@ -215,23 +220,25 @@ 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=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(vkey->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } else { char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>", ch, URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(u->key->getText()).c_str(), ch, - ch); + ch, + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } u->suspendTextPassThru = true; } @@ -265,6 +272,7 @@ } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); VerseKey *vkey = NULL; // see if we have a VerseKey * or descendant SWTRY { @@ -274,11 +282,11 @@ 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()); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x%s</sup></small></a>", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), - URL::encode(vkey->getText()).c_str()); - + URL::encode(vkey->getText()).c_str(), + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); } } Index: src/modules/filters/teihtmlhref.cpp =================================================================== --- src/modules/filters/teihtmlhref.cpp (revision 2676) +++ src/modules/filters/teihtmlhref.cpp (working copy) @@ -36,6 +36,7 @@ BiblicalText = false; if (module) { version = module->Name(); + markers = module->markers; BiblicalText = (!strcmp(module->Type(), "Biblical Texts")); } } @@ -259,11 +260,13 @@ } if (tag.isEndTag()) { SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); + SWBuf noteName = tag.getAttribute("n"); - buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n</sup></small></a>", + buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a>", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), - URL::encode(u->key->getText()).c_str()); + URL::encode(u->key->getText()).c_str(), + (u->markers ? URL::encode(noteName.c_str()).c_str() : "")); u->suspendTextPassThru = false; } Index: include/osishtmlhref.h =================================================================== --- include/osishtmlhref.h (revision 2676) +++ include/osishtmlhref.h (working copy) @@ -39,6 +39,7 @@ bool inBold; // TODO: obsolete. left for binary compat for 1.6.x bool inXRefNote; bool BiblicalText; + bool markers; int suspendLevel; SWBuf wordsOfChristStart; SWBuf wordsOfChristEnd; Index: include/gbfhtmlhref.h =================================================================== --- include/gbfhtmlhref.h (revision 2676) +++ include/gbfhtmlhref.h (working copy) @@ -33,6 +33,7 @@ public: MyUserData(const SWModule *module, const SWKey *key); bool hasFootnotePreTag; + bool markers; SWBuf version; }; virtual BasicFilterUserData *createUserData(const SWModule *module, const SWKey *key) { Index: include/thmlhtmlhref.h =================================================================== --- include/thmlhtmlhref.h (revision 2676) +++ include/thmlhtmlhref.h (working copy) @@ -37,6 +37,7 @@ bool inscriptRef; bool SecHead; bool BiblicalText; + bool markers; SWBuf version; XMLTag startTag; }; Index: include/swmodule.h =================================================================== --- include/swmodule.h (revision 2676) +++ include/swmodule.h (working copy) @@ -144,6 +144,9 @@ */ bool terminateSearch; + /** whether to include marker strings in notes/xrefs */ + bool markers; + /** SWModule c-tor * * @param imodname Internal name for module; see also getName() @@ -617,9 +620,10 @@ * if buf is 0, the current module position text will be used * @param len max len to process * @param render for internal use + * @param includeNumbers indicates rendering note/xref n=X content. * @return result buffer */ - virtual const char *RenderText(const char *buf = 0, int len = -1, bool render = true); + virtual const char *RenderText(const char *buf = 0, int len = -1, bool render = true, bool includeNumbers = false); /** Produces any header data which might be useful which associated with the * processing done with this filter. A typical example is a suggested Index: include/thmlxhtml.h =================================================================== --- include/thmlxhtml.h (revision 2676) +++ include/thmlxhtml.h (working copy) @@ -37,6 +37,7 @@ bool inscriptRef; bool SecHead; bool BiblicalText; + bool markers; SWBuf version; XMLTag startTag; }; Index: include/gbfxhtml.h =================================================================== --- include/gbfxhtml.h (revision 2676) +++ include/gbfxhtml.h (working copy) @@ -33,6 +33,7 @@ public: MyUserData(const SWModule *module, const SWKey *key); bool hasFootnotePreTag; + bool markers; SWBuf version; }; virtual BasicFilterUserData *createUserData(const SWModule *module, const SWKey *key) { Index: include/teihtmlhref.h =================================================================== --- include/teihtmlhref.h (revision 2676) +++ include/teihtmlhref.h (working copy) @@ -34,6 +34,7 @@ class MyUserData : public BasicFilterUserData { public: bool BiblicalText; + bool markers; SWBuf lastHi; SWBuf version; Index: include/osisxhtml.h =================================================================== --- include/osisxhtml.h (revision 2676) +++ include/osisxhtml.h (working copy) @@ -39,6 +39,7 @@ bool inBold; // TODO: obsolete. left for binary compat for 1.6.x bool inXRefNote; bool BiblicalText; + bool markers; int suspendLevel; SWBuf wordsOfChristStart; SWBuf wordsOfChristEnd;
_______________________________________________ sword-devel mailing list: sword-devel@crosswire.org http://www.crosswire.org/mailman/listinfo/sword-devel Instructions to unsubscribe/change your settings at above page