1
/******************************************************************************
3
* gbfheadings - SWFilter descendant to hide or show headings
6
* Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
7
* CrossWire Bible Society
11
* This program is free software; you can redistribute it and/or modify it
12
* under the terms of the GNU General Public License as published by the
13
* Free Software Foundation version 2.
15
* This program is distributed in the hope that it will be useful, but
16
* WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
* General Public License for more details.
23
#include <gbfheadings.h>
28
const char oName[] = "Headings";
29
const char oTip[] = "Toggles Headings On and Off if they exist";
31
const SWBuf choices[3] = {"Off", "On", ""};
32
const StringList oValues(&choices[0], &choices[2]);
34
GBFHeadings::GBFHeadings() : SWOptionFilter(oName, oTip, &oValues) {
35
setOptionValue("Off");
39
GBFHeadings::~GBFHeadings() {
43
char GBFHeadings::processText (SWBuf &text, const SWKey *key, const SWModule *module) {
44
if (!option) { // if we don't want headings
45
char token[2048]; // cheese. Fix.
53
for (text = ""; *from; from++) {
57
// memset(token, 0, 2048);
63
if (*from == '>') { // process tokens
66
case 'T': // Reference
68
case 'S': // Begin heading
71
case 's': // end heading
75
continue; // skip token
77
// if not a heading token, keep token in text
80
for (char *tok = token; *tok; tok++)
88
token[tokpos++] = *from;