Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

ThMLHTMLHREF Class Reference

this filter converts ThML text to HTML text with hrefs. More...

#include <thmlhtmlhref.h>

Inheritance diagram for ThMLHTMLHREF:

Inheritance graph
[legend]
Collaboration diagram for ThMLHTMLHREF:

Collaboration graph
[legend]
List of all members.

Public Methods

 ThMLHTMLHREF ()

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...


Detailed Description

this filter converts ThML text to HTML text with hrefs.

Definition at line 26 of file thmlhtmlhref.h.


Member Function Documentation

bool ThMLHTMLHREF::handleToken char **    buf,
const char *    token,
DualStringMap &    userData
[protected, virtual]
 

This function is called for every token encountered in the input text.

Parameters:
buf  the output buffer (FIXME: what is its size?)
token  the token (e.g. "p align='left'"
userData  FIXME: document this
Returns:
false if was not handled and should be handled in the default way (by just substituting).

Reimplemented from SWBasicFilter.

Definition at line 137 of file thmlhtmlhref.cpp.

References SWModule::getConfigEntry(), and SWBasicFilter::pushString().

00137                                                                                      {
00138         const char *tok;
00139         if (!substituteToken(buf, token)) {
00140         // manually process if it wasn't a simple substitution
00141                 if (!strncmp(token, "sync ", 5)) {
00142                         pushString(buf, "<a href=\"");
00143                         for (tok = token + 5; *(tok+1); tok++)
00144                                 if(*tok != '\"')
00145                                         *(*buf)++ = *tok;
00146                         *(*buf)++ = '\"';
00147                         *(*buf)++ = '>';
00148 
00149                         //scan for value and add it to the buffer
00150                         for (tok = token + 5; *tok; tok++) {
00151                                 if (!strncmp(tok, "value=\"", 7)) {
00152                                         tok += 7;
00153                                         for (;*tok != '\"'; tok++)
00154                                                 *(*buf)++ = *tok;
00155                                         break;
00156                                 }
00157                         }
00158                         pushString(buf, "</a>");
00159                 }
00160                 
00161                 else if (!strncmp(token, "scripture ", 10)) {
00162                         userData["inscriptRef"] = "true";
00163                         pushString(buf, "<i>");
00164                 } 
00165 
00166                 else if (!strncmp(token, "scripRef p", 10) || !strncmp(token, "scripRef v", 10)) {
00167                         userData["inscriptRef"] = "true";
00168                         pushString(buf, "<a href=\"");
00169                         for (const char *tok = token + 9; *(tok+1); tok++)                              
00170                                 if(*tok != '\"')                        
00171                                         *(*buf)++ = *tok;
00172                         *(*buf)++ = '\"';
00173                         *(*buf)++ = '>';
00174                 } 
00175 
00176                 // we're starting a scripRef like "<scripRef>John 3:16</scripRef>"
00177                 else if (!strcmp(token, "scripRef")) {
00178                         userData["inscriptRef"] = "false";
00179                         // let's stop text from going to output
00180                         userData["suspendTextPassThru"] = "true";
00181                 }
00182 
00183                 // we've ended a scripRef 
00184                 else if (!strcmp(token, "/scripRef")) {
00185                         if (userData["inscriptRef"] == "true") { // like  "<scripRef passage="John 3:16">John 3:16</scripRef>"
00186                                 userData["inscriptRef"] = "false";
00187                                 pushString(buf, "</a>");
00188                         }
00189                         
00190                         else { // like "<scripRef>John 3:16</scripRef>"
00191                                 pushString(buf, "<a href=\"passage=");
00192                                 //char *strbuf = (char *)userData["lastTextNode"].c_str();
00193                                 pushString(buf, userData["lastTextNode"].c_str());
00194                                 *(*buf)++ = '\"';
00195                                 *(*buf)++ = '>';
00196                                 pushString(buf, userData["lastTextNode"].c_str());
00197                                 // let's let text resume to output again
00198                                 userData["suspendTextPassThru"] = "false";      
00199                                 pushString(buf, "</a>");
00200                         }
00201                 }
00202                         
00203                 else if (!strncmp(token, "div class=\"sechead\"", 19)) {
00204                         userData["SecHead"] = "true";
00205                         pushString(buf, "<br /><b><i>");
00206                 }
00207                 else if (!strncmp(token, "div class=\"title\"", 19)) {
00208                         userData["SecHead"] = "true";
00209                         pushString(buf, "<br /><b><i>");
00210                 }
00211                 else if (!strncmp(token, "/div", 4)) {
00212                         if (userData["SecHead"] == "true") {
00213                                 pushString(buf, "</i></b><br />");
00214                                 userData["SecHead"] = "false";
00215                         }
00216                 }
00217 
00218                 else if (!strncmp(token, "sync type=\"Strongs\" value=\"T", 28)) {
00219                         pushString(buf, "<a href=\"");
00220                         for (tok = token + 5; *(tok+1); tok++)                          
00221                                 if(*tok != '\"')                        
00222                                         *(*buf)++ = *tok;
00223                         *(*buf)++ = '\"';
00224                         *(*buf)++ = '>';
00225                         for (tok = token + 29; *(tok+2); tok++)                         
00226                                 if(*tok != '\"')                        
00227                                         *(*buf)++ = *tok;               
00228                         pushString(buf, "</a>");
00229                 }
00230                 else if (!strncmp(token, "img ", 4)) {
00231                         const char *src = strstr(token, "src");
00232                         if (!src)               // assert we have a src attribute
00233                                 return false;
00234 
00235                         *(*buf)++ = '<';
00236                         for (const char *c = token; *c; c++) {
00237                                 if (c == src) {
00238                                         for (;((*c) && (*c != '"')); c++)
00239                                                 *(*buf)++ = *c;
00240 
00241                                         if (!*c) { c--; continue; }
00242 
00243                                         *(*buf)++ = '"';
00244                                         if (*(c+1) == '/') {
00245                                                 pushString(buf, "file:");
00246                                                 pushString(buf, module->getConfigEntry("AbsoluteDataPath"));
00247                                                 if (*((*buf)-1) == '/')
00248                                                         c++;            // skip '/'
00249                                         }
00250                                         continue;
00251                                 }
00252                                 *(*buf)++ = *c;
00253                         }
00254                         *(*buf)++ = '>';
00255                 }
00256                 else if (!strncmp(token, "note", 4)) {
00257                         pushString(buf, " <small><font color=\"#800000\">(");
00258                 }                
00259                 else {
00260                         *(*buf)++ = '<';
00261                         for (const char *tok = token; *tok; tok++)
00262                                 *(*buf)++ = *tok;
00263                         *(*buf)++ = '>';
00264                         //return false;  // we still didn't handle token
00265                 }
00266         }
00267         return true;
00268 }


The documentation for this class was generated from the following files:
Generated on Thu Jun 20 22:13:04 2002 for The Sword Project by doxygen1.2.15