1
/******************************************************************************
3
* thmlfootnotes - SWFilter descendant to hide or show footnotes
9
#include <thmlfootnotes.h>
21
const char oName[] = "Footnotes";
22
const char oTip[] = "Toggles Footnotes On and Off if they exist";
24
const SWBuf choices[3] = {"On", "Off", ""};
25
const StringList oValues(&choices[0], &choices[2]);
27
ThMLFootnotes::ThMLFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
28
setOptionValue("Off");
32
ThMLFootnotes::~ThMLFootnotes() {
36
char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
45
VerseKey parser = key->getText();
48
const char *from = orig.c_str();
50
for (text = ""; *from; from++) {
56
if (*from == '>') { // process tokens
60
if (!strcmp(tag.getName(), "note")) {
61
if (!tag.isEndTag()) {
70
if (hide && tag.isEndTag()) {
71
if (module->isProcessEntryAttributes()) {
72
SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"];
73
footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0;
74
sprintf(buf, "%i", ++footnoteNum);
75
module->getEntryAttributes()["Footnote"]["count"]["value"] = buf;
76
StringList attributes = startTag.getAttributeNames();
77
for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
78
module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
80
module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
81
startTag.setAttribute("swordFootnote", buf);
82
if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
84
refs = parser.ParseVerseList(tagText.c_str(), parser, true).getRangeText();
85
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
89
if ((option) || ((startTag.getAttribute("type") && (!strcmp(startTag.getAttribute("type"), "crossReference"))))) { // we want the tag in the text; crossReferences are handled by another filter
97
// if not a note token, keep token in text
98
if ((!strcmp(tag.getName(), "scripRef")) && (!tag.isEndTag())) {
99
SWBuf osisRef = tag.getAttribute("passage");
111
tagText.append(token);
116
if (intoken) { //copy token
119
else if (!hide) { //copy text which is not inside a token
122
else tagText += *from;