1
/******************************************************************************
3
* thmlplain - SWFilter descendant to strip out all ThML tags or convert to
4
* ASCII rendered symbols.
7
#include "bt_thmlplain.h"
12
using namespace sword;
16
BT_ThMLPlain::BT_ThMLPlain() {
19
char BT_ThMLPlain::processText(SWBuf &text, const SWKey *key, const SWModule *module)
24
bool ampersand = false;
29
for (text = ""; *from; from++)
31
if (*from == 10 || *from == 13)
42
else if (*from == '&') {
51
if (*from == ';' && ampersand) {
55
if (!strncmp("nbsp", token, 4)) text += " ";
56
else if (!strncmp("quot", token, 4)) text += "\"";
57
else if (!strncmp("amp", token, 3)) text += "&";
58
else if (!strncmp("lt", token, 2)) text += "<";
59
else if (!strncmp("gt", token, 2)) text += ">";
60
else if (!strncmp("brvbar", token, 6)) text += "¦";
61
else if (!strncmp("sect", token, 4)) text += "§";
62
else if (!strncmp("copy", token, 4)) text += "©";
63
else if (!strncmp("laquo", token, 5)) text += "«";
64
else if (!strncmp("reg", token, 3)) text += "®";
65
else if (!strncmp("acute", token, 5)) text += "´";
66
else if (!strncmp("para", token, 4)) text += "¶";
67
else if (!strncmp("raquo", token, 5)) text += "»";
69
else if (!strncmp("Aacute", token, 6)) text += "Á";
70
else if (!strncmp("Agrave", token, 6)) text += "À";
71
else if (!strncmp("Acirc", token, 5)) text += "Â";
72
else if (!strncmp("Auml", token, 4)) text += "Ä";
73
else if (!strncmp("Atilde", token, 6)) text += "Ã";
74
else if (!strncmp("Aring", token, 5)) text += "Å";
75
else if (!strncmp("aacute", token, 6)) text += "á";
76
else if (!strncmp("agrave", token, 6)) text += "à";
77
else if (!strncmp("acirc", token, 5)) text += "â";
78
else if (!strncmp("auml", token, 4)) text += "ä";
79
else if (!strncmp("atilde", token, 6)) text += "ã";
80
else if (!strncmp("aring", token, 5)) text += "å";
81
else if (!strncmp("Eacute", token, 6)) text += "É";
82
else if (!strncmp("Egrave", token, 6)) text += "È";
83
else if (!strncmp("Ecirc", token, 5)) text += "Ê";
84
else if (!strncmp("Euml", token, 4)) text += "Ë";
85
else if (!strncmp("eacute", token, 6)) text += "é";
86
else if (!strncmp("egrave", token, 6)) text += "è";
87
else if (!strncmp("ecirc", token, 5)) text += "ê";
88
else if (!strncmp("euml", token, 4)) text += "ë";
89
else if (!strncmp("Iacute", token, 6)) text += "Í";
90
else if (!strncmp("Igrave", token, 6)) text += "Ì";
91
else if (!strncmp("Icirc", token, 5)) text += "Î";
92
else if (!strncmp("Iuml", token, 4)) text += "Ï";
93
else if (!strncmp("iacute", token, 6)) text += "í";
94
else if (!strncmp("igrave", token, 6)) text += "ì";
95
else if (!strncmp("icirc", token, 5)) text += "î";
96
else if (!strncmp("iuml", token, 4)) text += "ï";
97
else if (!strncmp("Oacute", token, 6)) text += "Ó";
98
else if (!strncmp("Ograve", token, 6)) text += "Ò";
99
else if (!strncmp("Ocirc", token, 5)) text += "Ô";
100
else if (!strncmp("Ouml", token, 4)) text += "Ö";
101
else if (!strncmp("Otilde", token, 6)) text += "Õ";
102
else if (!strncmp("oacute", token, 6)) text += "ó";
103
else if (!strncmp("ograve", token, 6)) text += "ò";
104
else if (!strncmp("ocirc", token, 5)) text += "ô";
105
else if (!strncmp("ouml", token, 4)) text += "ö";
106
else if (!strncmp("otilde", token, 6)) text += "õ";
107
else if (!strncmp("Uacute", token, 6)) text += "Ú";
108
else if (!strncmp("Ugrave", token, 6)) text += "Ù";
109
else if (!strncmp("Ucirc", token, 5)) text += "Û";
110
else if (!strncmp("Uuml", token, 4)) text += "Ü";
111
else if (!strncmp("uacute", token, 6)) text += "ú";
112
else if (!strncmp("ugrave", token, 6)) text += "ù";
113
else if (!strncmp("ucirc", token, 5)) text += "û";
114
else if (!strncmp("uuml", token, 4)) text += "ü";
115
else if (!strncmp("Yacute", token, 6)) text += "Ý";
116
else if (!strncmp("yacute", token, 6)) text += "ý";
117
else if (!strncmp("yuml", token, 4)) text += "ÿ";
119
else if (!strncmp("deg", token, 3)) text += "°";
120
else if (!strncmp("plusmn", token, 6)) text += "±";
121
else if (!strncmp("sup2", token, 4)) text += "²";
122
else if (!strncmp("sup3", token, 4)) text += "³";
123
else if (!strncmp("sup1", token, 4)) text += "¹";
124
else if (!strncmp("nbsp", token, 4)) text += "º";
125
else if (!strncmp("pound", token, 5)) text += "£";
126
else if (!strncmp("cent", token, 4)) text += "¢";
127
else if (!strncmp("frac14", token, 6)) text += "¼";
128
else if (!strncmp("frac12", token, 6)) text += "½";
129
else if (!strncmp("frac34", token, 6)) text += "¾";
130
else if (!strncmp("iquest", token, 6)) text += "¿";
131
else if (!strncmp("iexcl", token, 5)) text += "¡";
132
else if (!strncmp("ETH", token, 3)) text += "Ð";
133
else if (!strncmp("eth", token, 3)) text += "ð";
134
else if (!strncmp("THORN", token, 5)) text += "Þ";
135
else if (!strncmp("thorn", token, 5)) text += "þ";
136
else if (!strncmp("AElig", token, 5)) text += "Æ";
137
else if (!strncmp("aelig", token, 5)) text += "æ";
138
else if (!strncmp("Oslash", token, 6)) text += "Ø";
139
else if (!strncmp("curren", token, 6)) text += "¤";
140
else if (!strncmp("Ccedil", token, 6)) text += "Ç";
141
else if (!strncmp("ccedil", token, 6)) text += "ç";
142
else if (!strncmp("szlig", token, 5)) text += "ß";
143
else if (!strncmp("Ntilde", token, 6)) text += "Ñ";
144
else if (!strncmp("ntilde", token, 6)) text += "ñ";
145
else if (!strncmp("yen", token, 3)) text += "¥";
146
else if (!strncmp("not", token, 3)) text += "¬";
147
else if (!strncmp("ordf", token, 4)) text += "ª";
148
else if (!strncmp("uml", token, 3)) text += "¨";
149
else if (!strncmp("shy", token, 3)) text += "";
150
else if (!strncmp("macr", token, 4)) text += "¯";
151
else if (!strncmp("micro", token, 5)) text += "µ";
152
else if (!strncmp("middot", token, 6)) text +="·";
153
else if (!strncmp("cedil", token, 5)) text += "¸";
154
else if (!strncmp("ordm", token, 4)) text += "º";
155
else if (!strncmp("times", token, 5)) text += "×";
156
else if (!strncmp("divide", token, 6)) text +="÷";
157
else if (!strncmp("oslash", token, 6)) text +="ø";
161
else if (*from == '>' && !ampersand) {
163
// process desired tokens
164
if (!strncmp(token, "sync type=\"Strongs\" value=\"", 27)) {
167
for (unsigned int i = 27; token[i] != '\"'; i++)
172
if (!strncmp(token, "sync type=\"morph\" value=\"", 25)) {
175
for (unsigned int i = 25; token[i] != '\"'; i++)
180
if (!strncmp("note", token, 4)) {
184
else if (!strncmp("br", token, 2))
186
else if (!strncmp("/p", token, 2))
188
else if (!strncmp("/note", token, 5)) {
196
token[tokpos++] = *from;
204
for (text = ""; *from; from++) { //loop to remove extra spaces
205
if ((strchr(" \t\n\r", *from))) {
206
while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) {