#include <thmlhtml.h>
Inheritance diagram for ThMLHTML:
Public Methods | |
ThMLHTML () | |
Protected Methods | |
virtual bool | handleToken (char **buf, const char *token, DualStringMap &userData) |
This function is called for every token encountered in the input text. More... |
Definition at line 28 of file thmlhtml.h.
|
This function is called for every token encountered in the input text.
Reimplemented from SWBasicFilter. Definition at line 137 of file thmlhtml.cpp. References SWModule::getConfigEntry(), and SWBasicFilter::pushString().
00137 { 00138 if (!substituteToken(buf, token)) { 00139 // manually process if it wasn't a simple substitution 00140 if (!strncmp(token, "sync type=\"Strongs\" value=\"", 27)) { 00141 if (token[27] == 'H' || token[27] == 'G' || token[27] == 'A') { 00142 pushString(buf, "<small><em>"); 00143 for (const char *tok = token + 5; *tok; tok++) 00144 if(*tok != '\"') 00145 *(*buf)++ = *tok; 00146 pushString(buf, "</em></small>"); 00147 } 00148 else if (token[27] == 'T') { 00149 pushString(buf, "<small><i>"); 00150 for (unsigned int i = 29; token[i] != '\"'; i++) 00151 *(*buf)++ = token[i]; 00152 pushString(buf, "</i></small>"); 00153 } 00154 } 00155 else if (!strncmp(token, "sync type=\"morph\" value=\"", 25)) { 00156 pushString(buf, "<small><em>"); 00157 for (unsigned int i = 25; token[i] != '\"'; i++) 00158 *(*buf)++ = token[i]; 00159 pushString(buf, "</em></small>"); 00160 } 00161 else if (!strncmp(token, "sync type=\"lemma\" value=\"", 25)) { 00162 pushString(buf, "<small><em>("); 00163 for (unsigned int i = 25; token[i] != '\"'; i++) 00164 *(*buf)++ = token[i]; 00165 pushString(buf, ")</em></small>"); 00166 } 00167 else if (!strncmp(token, "scripRef", 8)) { 00168 pushString(buf, "<a href=\""); 00169 for (const char *tok = token + 9; *tok; tok++) 00170 if(*tok != '\"') 00171 *(*buf)++ = *tok; 00172 *(*buf)++ = '\"'; 00173 *(*buf)++ = '>'; 00174 } 00175 else if (!strncmp(token, "img ", 4)) { 00176 const char *src = strstr(token, "src"); 00177 if (!src) // assert we have a src attribute 00178 return false; 00179 00180 *(*buf)++ = '<'; 00181 for (const char *c = token; *c; c++) { 00182 if (c == src) { 00183 for (;((*c) && (*c != '"')); c++) 00184 *(*buf)++ = *c; 00185 00186 if (!*c) { c--; continue; } 00187 00188 *(*buf)++ = '"'; 00189 if (*(c+1) == '/') { 00190 pushString(buf, "file:"); 00191 pushString(buf, module->getConfigEntry("AbsoluteDataPath")); 00192 if (*((*buf)-1) == '/') 00193 c++; // skip '/' 00194 } 00195 continue; 00196 } 00197 *(*buf)++ = *c; 00198 } 00199 *(*buf)++ = '>'; 00200 } 00201 else if(!strncmp(token, "note", 4)) { 00202 pushString(buf, " <font color=\"#800000\"><small>("); 00203 } 00204 00205 else { 00206 return false; // we still didn't handle token 00207 } 00208 } 00209 return true; 00210 } |