1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/***************************************************************************
*
* gbfcgi.cpp - GBF to Diatheke/CGI format
*
* $Id: gbfcgi.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
* Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*/
#include <stdlib.h>
#include <string.h>
#include <map>
#include "gbfcgi.h"
SWORD_NAMESPACE_START
typedef std::map<SWBuf, SWBuf> DualStringMap;
namespace {
class MyUserData : public BasicFilterUserData {
public:
MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {}
DualStringMap properties;
};
}
BasicFilterUserData *GBFCGI::createUserData(const SWModule *module, const SWKey *key) {
return new MyUserData(module, key);
}
GBFCGI::GBFCGI() {
setTokenStart("<");
setTokenEnd(">");
setTokenCaseSensitive(true);
addTokenSubstitute("Rf", ")</small></font>");
addTokenSubstitute("FI", "<i>"); // italics begin
addTokenSubstitute("Fi", "</i>");
addTokenSubstitute("FB", "<n>"); // bold begin
addTokenSubstitute("Fb", "</n>");
addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin
addTokenSubstitute("Fr", "</font>");
addTokenSubstitute("FU", "<u>"); // underline begin
addTokenSubstitute("Fu", "</u>");
addTokenSubstitute("FO", "<cite>"); // Old Testament quote begin
addTokenSubstitute("Fo", "</cite>");
addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin
addTokenSubstitute("Fs", "</sup>");
addTokenSubstitute("FV", "<sub>"); // Subscript begin
addTokenSubstitute("Fv", "</sub>");
addTokenSubstitute("TT", "<big>"); // Book title begin
addTokenSubstitute("Tt", "</big>");
addTokenSubstitute("PP", "<cite>"); // poetry begin
addTokenSubstitute("Pp", "</cite>");
addTokenSubstitute("Fn", "</font>"); // font end
addTokenSubstitute("CL", "<br />"); // new line
addTokenSubstitute("CM", "<br />"); // paragraph
addTokenSubstitute("CG", ">"); // ???
addTokenSubstitute("CT", "<"); // ???
addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
addTokenSubstitute("JL", "</div>"); // align end
}
bool GBFCGI::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *baseUserData) {
MyUserData *userData = (MyUserData *) baseUserData;
unsigned long i;
if (!substituteToken(buf, token)) {
if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
buf += " <small><em><<a href=\"!DIATHEKE_URL!";
if (token[1] == 'H') {
buf += "StrongsHebrew";
}
else if (token[1] == 'G') {
buf += "StrongsGreek";
}
buf += "=on&verse=";
for (i = 2; i < strlen(token); i++)
buf += token[i];
buf += "\">";
for (i = 2; i < strlen(token); i++)
buf += token[i];
buf += "</a>></em></small>";
}
else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
buf += " <small><em><<a href=\"!DIATHEKE_URL!";
if (token[2] == 'H') {
buf += "StrongsHebrew";
}
else if (token[2] == 'G') {
buf += "StrongsGreek";
}
buf += "=on&verse=";
for (i = 3; i < strlen(token); i++)
buf += token[i];
buf += "\">";
for (i = 3; i < strlen(token); i++)
buf += token[i];
buf += "</a>></em></small>";
}
else if (!strncmp(token, "WT", 2)) { // morph tags
buf += " <small><em>(<a href=\"!DIATHEKE_URL!Packard=on&verse=";
for (i = 1; i < strlen(token); i++)
buf += token[i];
buf += "\">";
for (i = 1; i < strlen(token); i++)
buf += token[i];
buf += "</a>)</em></small>";
}
else if (!strncmp(token, "RB", 2)) {
buf += "<i>";
userData->properties["hasFootnotePreTag"] = "true";
}
else if (!strncmp(token, "RF", 2)) {
if(userData->properties["hasFootnotePreTag"] == "true") {
userData->properties["hasFootnotePreTag"] = "false";
buf += "</i> ";
}
buf += "<font color=\"#800000\"><small> (";
}
else if (!strncmp(token, "FN", 2)) {
buf += "<font face=\"";
for (i = 2; i < strlen(token); i++)
buf += token[i];
buf += "\">";
}
else if (!strncmp(token, "CA", 2)) { // ASCII value
buf += (char)atoi(&token[2]);
}
else {
return false;
}
}
return true;
}
SWORD_NAMESPACE_END
|