The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GBFThML Class Reference

#include <gbfthml.h>

+ Inheritance diagram for GBFThML:
+ Collaboration diagram for GBFThML:

Public Member Functions

 GBFThML ()
 
virtual const char * getHeader () const
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 

Detailed Description

this filter converts GBF text into ThML text

Definition at line 33 of file gbfthml.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START GBFThML::GBFThML ( )

Definition at line 31 of file gbfthml.cpp.

32 {
33 }

Member Function Documentation

virtual const char* SWFilter::getHeader ( ) const
inlinevirtualinherited

This method can supply a header associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Reimplemented in OSISLaTeX, OSISXHTML, ThMLLaTeX, ThMLXHTML, TEIXHTML, GBFLaTeX, and GBFXHTML.

Definition at line 62 of file swfilter.h.

62 { return ""; }
char GBFThML::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtual

This method processes and appropriately modifies the text given it for a particular filter task

Parameters
textThe text to be filtered/converted
keyCurrent key That was used.
moduleCurrent module.
Returns
0

Implements SWFilter.

Definition at line 36 of file gbfthml.cpp.

36  {
37  const char *from;
38  char token[2048];
39  int tokpos = 0;
40  bool intoken = false;
41  const char *tok;
42 
43  SWBuf orig = text;
44  from = orig.c_str();
45 
46  for (text = ""; *from; from++) {
47  if (*from == '<') {
48  intoken = true;
49  tokpos = 0;
50  token[0] = 0;
51  token[1] = 0;
52  token[2] = 0;
53  continue;
54  }
55  if (*from == '>') {
56  intoken = false;
57  // process desired tokens
58  switch (*token) {
59  case 'W': // Strongs
60  switch(token[1]) {
61  case 'G':
62  case 'H':
63  text += "<sync type=\"Strongs\" value=\"";
64  for (tok = token + 1; *tok; tok++)
65  text += *tok;
66  text += "\" />";
67  continue;
68 
69  case 'T': // Tense
70  text += "<sync type=\"Morph\" value=\"";
71  for (tok = token + 2; *tok; tok++)
72  text += *tok;
73  text += "\" />";
74  continue;
75  }
76  break;
77  case 'R':
78  switch(token[1])
79  {
80  case 'X':
81  text += "<a href=\"";
82  for (tok = token + 3; *tok; tok++) {
83  if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
84  text += *tok;
85  }
86  else {
87  break;
88  }
89  }
90  text += "\">";
91  continue;
92  case 'x':
93  text += "</a>";
94  continue;
95  case 'F': // footnote begin
96  text += "<note>";
97  continue;
98  case 'f': // footnote end
99  text += "</note>";
100  continue;
101  }
102  break;
103  case 'F': // font tags
104  switch(token[1])
105  {
106  case 'N':
107  text += "<font face=\"";
108  for (tok = token + 2; *tok; tok++)
109  text += *tok;
110  text += "\">";
111  continue;
112  case 'n':
113  text += "</font>";
114  continue;
115  case 'I': // italic start
116  text += "<i>";
117  continue;
118  case 'i': // italic end
119  text += "</i>";
120  continue;
121  case 'B': // bold start
122  text += "<b>";
123  continue;
124  case 'b': // bold end
125  text += "</b>";
126  continue;
127 
128  case 'R': // words of Jesus begin
129  text += "<font color=\"#ff0000\">";
130  continue;
131  case 'r': // words of Jesus end
132  text += "</font>";
133  continue;
134  case 'U': // Underline start
135  text += "<u>";
136  continue;
137  case 'u': // Underline end
138  text += "</u>";
139  continue;
140  case 'O': // Old Testament quote begin
141  text += "<cite>";
142  continue;
143  case 'o': // Old Testament quote end
144  text += "</cite>";
145  continue;
146  case 'S': // Superscript begin
147  text += "<sup>";
148  continue;
149  case 's': // Superscript end
150  text += "</sup>";
151  continue;
152  case 'V': // Subscript begin
153  text += "<sub>";
154  continue;
155  case 'v': // Subscript end
156  text += "</sub>";
157  continue;
158  }
159  break;
160  case 'C': // special character tags
161  switch(token[1])
162  {
163  case 'A': // ASCII value
164  text += (char)atoi(&token[2]);
165  continue;
166  case 'G':
167  //*to++ = ' ';
168  continue;
169  case 'L': // line break
170  text += "<br /> ";
171  continue;
172  case 'M': // new paragraph
173  text += "<p />";
174  continue;
175  case 'T':
176  //*to++ = ' ';
177  continue;
178  }
179  break;
180  case 'T': // title formatting
181  switch(token[1])
182  {
183  case 'T': // Book title begin
184  text += "<big>";
185  continue;
186  case 't':
187  text += "</big>";
188  continue;
189  case 'S':
190  text += "<div class=\"sechead\">";
191  continue;
192  case 's':
193  text += "</div>";
194  continue;
195  }
196  break;
197 
198  case 'P': // special formatting
199  switch(token[1]) {
200  case 'P': // Poetry begin
201  text += "<verse>";
202  continue;
203  case 'p':
204  text += "</verse>";
205  continue;
206  }
207  break;
208  }
209  continue;
210  }
211  if (intoken) {
212  if (tokpos < 2045) {
213  token[tokpos++] = *from;
214  //TODO: why is this + 2? Are we trying to keep 2 or 3 nulls after the last valid char?
215  // tokpos has been incremented past the last valid token. it should be pointing to null
216  // +1 should give us 2 nulls, but we're +2 here, which actually keeps 3 nulls after the
217  // last valid char. Why are we doing any of this? These were written before SWBuf and should
218  // probably be switched to SWBuf, but perf tests before and after the switch should be run
219  token[tokpos+2] = 0;
220  }
221  }
222  else text += *from;
223  }
224  return 0;
225 }
Definition: swbuf.h:47
const char * c_str() const
Definition: swbuf.h:158

The documentation for this class was generated from the following files: