1
/***************************************************************************
2
* gbfhtml.cpp - GBF to HTML filter
5
* copyright : 2001 by CrossWire Bible Society
7
* Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
8
* CrossWire Bible Society
10
* Tempe, AZ 85280-2528
12
* This program is free software; you can redistribute it and/or modify it
13
* under the terms of the GNU General Public License as published by the
14
* Free Software Foundation version 2.
16
* This program is distributed in the hope that it will be useful, but
17
* WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* General Public License for more details.
33
setTokenCaseSensitive(true);
35
addTokenSubstitute("Rf", ")</small></font>");
36
addTokenSubstitute("Rx", "</a>");
37
addTokenSubstitute("FI", "<i>"); // italics begin
38
addTokenSubstitute("Fi", "</i>");
39
addTokenSubstitute("FB", "<n>"); // bold begin
40
addTokenSubstitute("Fb", "</n>");
41
addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin
42
addTokenSubstitute("Fr", "</font>");
43
addTokenSubstitute("FU", "<u>"); // underline begin
44
addTokenSubstitute("Fu", "</u>");
45
addTokenSubstitute("FO", "<cite>"); // Old Testament quote begin
46
addTokenSubstitute("Fo", "</cite>");
47
addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin
48
addTokenSubstitute("Fs", "</sup>");
49
addTokenSubstitute("FV", "<sub>"); // Subscript begin
50
addTokenSubstitute("Fv", "</sub>");
51
addTokenSubstitute("TT", "<big>"); // Book title begin
52
addTokenSubstitute("Tt", "</big>");
53
addTokenSubstitute("PP", "<cite>"); // poetry begin
54
addTokenSubstitute("Pp", "</cite>");
55
addTokenSubstitute("Fn", "</font>"); // font end
56
addTokenSubstitute("CL", "<br />"); // new line
57
addTokenSubstitute("CM", "<!P><br />"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
58
addTokenSubstitute("CG", ""); // ???
59
addTokenSubstitute("CT", ""); // ???
60
addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
61
addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
62
addTokenSubstitute("JL", "</div>"); // align end
67
bool GBFHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
72
MyUserData *u = (MyUserData *)userData;
74
if (!substituteToken(buf, token)) {
75
// deal with OSIS note tags. Just hide till OSISRTF
76
if (!strncmp(token, "note ", 5)) {
77
// let's stop text from going to output
78
u->suspendTextPassThru = true;
81
else if (!strncmp(token, "/note", 5)) {
82
u->suspendTextPassThru = false;
85
else if (!strncmp(token, "w", 1)) {
86
// OSIS Word (temporary until OSISRTF is done)
88
num = strstr(token, "lemma=\"x-Strongs:");
90
for (num+=17; ((*num) && (*num != '\"')); num++)
93
if (atoi((!isdigit(*val))?val+1:val) < 5627) {
94
buf += " <small><em><";
95
for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
97
buf += "></em></small> ";
100
num = strstr(token, "lemma=\"strong:");
102
for (num+=14; ((*num) && (*num != '\"')); num++)
105
if (atoi((!isdigit(*val))?val+1:val) < 5627) {
106
buf += " <small><em><";
107
for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
109
buf += "></em></small> ";
114
num = strstr(token, "morph=\"x-Robinson:");
116
for (num+=18; ((*num) && (*num != '\"')); num++)
119
// normal robinsons tense
120
buf += " <small><em>(";
121
for (tok = val; *tok; tok++)
123
buf += ")</em></small> ";
127
else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
128
buf += " <small><em><";
129
for (tok = token + 2; *tok; tok++)
131
buf += "></em></small> ";
134
else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
135
buf += " <small><em><";
136
for (tok = token + 3; *tok; tok++)
139
buf += ")</em></small> ";
142
else if (!strncmp(token, "RX", 2)) {
144
for (tok = token + 3; *tok; tok++) {
145
if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
155
else if (!strncmp(token, "RB", 2)) {
157
u->hasFootnotePreTag = true;
160
else if (!strncmp(token, "RF", 2)) {
161
if (u->hasFootnotePreTag) {
162
u->hasFootnotePreTag = false;
165
buf += "<font color=\"#800000\"><small> (";
168
else if (!strncmp(token, "FN", 2)) {
169
buf += "<font face=\"";
170
for (tok = token + 2; *tok; tok++)
176
else if (!strncmp(token, "CA", 2)) { // ASCII value
177
buf += (char)atoi(&token[2]);