This function is called for every token encountered in the input text.
160 MyUserData *u = (MyUserData *)userData;
168 if (!strcmp(tag.getName(),
"w")) {
171 if ((!tag.isEmpty()) && (!tag.isEndTag())) {
177 bool endTag = tag.isEndTag();
183 lastText = u->lastTextNode.
c_str();
185 else lastText =
"stuff";
189 if ((attrib = tag.getAttribute(
"xlit"))) {
190 val = strchr(attrib,
':');
191 val = (val) ? (val + 1) : attrib;
195 if ((attrib = tag.getAttribute(
"gloss"))) {
202 outText(
"</rb><rp>(</rp><rt>", buf, u);
203 val = strchr(attrib,
':');
204 val = (val) ? (val + 1) : attrib;
206 outText(
"</rt><rp>)</rp></ruby>", buf, u);
216 if ((attrib = tag.getAttribute(
"POS"))) {
217 val = strchr(attrib,
':');
218 val = (val) ? (val + 1) : attrib;
229 else if (!strcmp(tag.getName(),
"note")) {
230 if (!tag.isEndTag()) {
231 SWBuf type = tag.getAttribute(
"type");
232 bool strongsMarkup = (type ==
"x-strongsMarkup" || type ==
"strongsMarkup");
237 if (!tag.isEmpty()) {
239 if (!strongsMarkup) {
240 SWBuf footnoteNumber = tag.getAttribute(
"swordFootnote");
241 SWBuf noteName = tag.getAttribute(
"n");
242 char ch = ((tag.getAttribute(
"type") && ((!strcmp(tag.getAttribute(
"type"),
"crossReference")) || (!strcmp(tag.getAttribute(
"type"),
"x-cross-ref")))) ?
'x':
'n');
244 u->inXRefNote =
true;
246 buf.
appendFormatted(
"<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
250 URL::encode(u->vkey ? u->vkey->getText() : u->key->getText()).c_str(),
256 u->suspendTextPassThru = (++u->suspendLevel);
258 if (tag.isEndTag()) {
259 u->suspendTextPassThru = (--u->suspendLevel);
260 u->inXRefNote =
false;
261 u->lastSuspendSegment =
"";
266 else if (!strcmp(tag.getName(),
"p") || !strcmp(tag.getName(),
"lg")) {
267 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
270 else if (tag.isEndTag()) {
271 outText(
"<!/P><br />", buf, u);
283 else if (tag.isEmpty() && !strcmp(tag.getName(),
"div") && tag.getAttribute(
"type") && (!strcmp(tag.getAttribute(
"type"),
"x-p") || !strcmp(tag.getAttribute(
"type"),
"paragraph"))) {
285 if (tag.getAttribute(
"sID")) {
289 else if (tag.getAttribute(
"eID")) {
290 outText(
"<!/P><br />", buf, u);
296 else if (!strcmp(tag.getName(),
"reference")) {
297 if (!u->inXRefNote) {
298 if (!tag.isEndTag()) {
302 bool is_scripRef =
false;
304 target = tag.getAttribute(
"osisRef");
305 const char* the_ref = strchr(target,
':');
321 if(!strncmp(work,
"Bible", 5))
327 buf.
appendFormatted(
"<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=\">",
348 else if (!strcmp(tag.getName(),
"l")) {
350 if (tag.getAttribute(
"eID")) {
355 else if (tag.isEmpty() && !tag.getAttribute(
"sID")) {
359 else if (tag.isEndTag()) {
365 else if (!strcmp(tag.getName(),
"lb") && (!tag.getAttribute(
"type") || strcmp(tag.getAttribute(
"type"),
"x-optional"))) {
372 else if ((!strcmp(tag.getName(),
"milestone")) && (tag.getAttribute(
"type"))) {
373 if (!strcmp(tag.getAttribute(
"type"),
"line")) {
375 if (tag.getAttribute(
"subType") && !strcmp(tag.getAttribute(
"subType"),
"x-PM")) {
380 else if (!strcmp(tag.getAttribute(
"type"),
"x-p")) {
381 if (tag.getAttribute(
"marker"))
382 outText(tag.getAttribute(
"marker"), buf, u);
385 else if (!strcmp(tag.getAttribute(
"type"),
"cQuote")) {
386 const char *tmp = tag.getAttribute(
"marker");
389 tmp = tag.getAttribute(
"level");
390 int level = (tmp) ? atoi(tmp) : 1;
396 else if (u->osisQToTick)
397 outText((level % 2) ?
'\"' :
'\'', buf, u);
402 else if (!strcmp(tag.getName(),
"title")) {
403 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
406 else if (tag.isEndTag()) {
412 else if (!strcmp(tag.getName(),
"list")) {
413 if((!tag.isEndTag()) && (!tag.isEmpty())) {
416 else if (tag.isEndTag()) {
422 else if (!strcmp(tag.getName(),
"item")) {
423 if((!tag.isEndTag()) && (!tag.isEmpty())) {
426 else if (tag.isEndTag()) {
431 else if (!strcmp(tag.getName(),
"rdg") || !strcmp(tag.getName(),
"catchWord")) {
432 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
435 else if (tag.isEndTag()) {
441 else if (!strcmp(tag.getName(),
"divineName")) {
442 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
443 u->suspendTextPassThru = (++u->suspendLevel);
445 else if (tag.isEndTag()) {
446 SWBuf lastText = u->lastSuspendSegment.
c_str();
447 u->suspendTextPassThru = (--u->suspendLevel);
448 if (lastText.
size()) {
450 scratch.
setFormatted(
"%c<font size=\"-1\">%s</font>", lastText[0], lastText.
c_str()+1);
452 const unsigned char *tmpBuf = (
const unsigned char *)lastText.
c_str();
454 int char_length = (int)(tmpBuf - (
const unsigned char *)lastText.
c_str());
458 lastText.
c_str() + char_length
467 else if (!strcmp(tag.getName(),
"hi")) {
468 SWBuf type = tag.getAttribute(
"type");
470 if (!type.
length()) type = tag.getAttribute(
"rend");
471 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
472 if (type ==
"bold" || type ==
"b" || type ==
"x-b") {
475 else if (type ==
"ol" || type ==
"overline" || type ==
"x-overline") {
476 outText(
"<span style=\"text-decoration:overline\">", buf, u);
478 else if (type ==
"super") {
481 else if (type ==
"sub") {
487 u->tagStacks->hiStack.push(tag.toString());
489 else if (tag.isEndTag()) {
491 if (!u->tagStacks->hiStack.empty()) {
492 XMLTag tag(u->tagStacks->hiStack.top());
493 u->tagStacks->hiStack.pop();
494 type = tag.getAttribute(
"type");
495 if (!type.
length()) type = tag.getAttribute(
"rend");
497 if (type ==
"bold" || type ==
"b" || type ==
"x-b") {
500 else if (type ==
"ol") {
503 else if (type ==
"super") {
506 else if (type ==
"sub") {
523 else if (!strcmp(tag.getName(),
"q")) {
524 SWBuf type = tag.getAttribute(
"type");
525 SWBuf who = tag.getAttribute(
"who");
526 const char *tmp = tag.getAttribute(
"level");
527 int level = (tmp) ? atoi(tmp) : 1;
528 tmp = tag.getAttribute(
"marker");
533 if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute(
"sID"))) {
535 if (!tag.isEmpty()) {
536 u->tagStacks->quoteStack.push(tag.toString());
541 outText(u->wordsOfChristStart, buf, u);
547 else if (u->osisQToTick)
548 outText((level % 2) ?
'\"' :
'\'', buf, u);
551 else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute(
"eID"))) {
553 if (tag.isEndTag() && !u->tagStacks->quoteStack.empty()) {
554 XMLTag qTag(u->tagStacks->quoteStack.top());
555 u->tagStacks->quoteStack.pop();
557 type = qTag.getAttribute(
"type");
558 who = qTag.getAttribute(
"who");
559 tmp = qTag.getAttribute(
"level");
560 level = (tmp) ? atoi(tmp) : 1;
561 tmp = qTag.getAttribute(
"marker");
570 else if (u->osisQToTick)
571 outText((level % 2) ?
'\"' :
'\'', buf, u);
575 outText(u->wordsOfChristEnd, buf, u);
580 else if (!strcmp(tag.getName(),
"transChange")) {
581 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
582 SWBuf type = tag.getAttribute(
"type");
583 u->lastTransChange = type;
586 if ((type ==
"added") || (type ==
"supplied"))
588 else if (type ==
"tenseChange")
591 else if (tag.isEndTag()) {
592 SWBuf type = u->lastTransChange;
593 if ((type ==
"added") || (type ==
"supplied"))
601 else if (!strcmp(tag.getName(),
"figure")) {
602 const char *src = tag.getAttribute(
"src");
609 if ((filepath.
size()) && (filepath[filepath.
size()-1] !=
'/') && (src[0] !=
'/'))
615 outText(
"<a href=\"passagestudy.jsp?action=showImage&value=", buf, u);
621 outText(
"<img src=\"file:", buf, u);
623 outText(
"\" border=\"0\" />", buf, u);
SWBuf & appendFormatted(const char *format,...)
unsigned long length() const
virtual const char * getConfigEntry(const char *key) const
bool substituteToken(SWBuf &buf, const char *token)
void processLemma(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf)
const char * c_str() const
static void outText(const char *t, SWBuf &o, BasicFilterUserData *u)
void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf)
unsigned long size() const
bool supressAdjacentWhitespace
SWBuf & setFormatted(const char *format,...)
static const SWBuf encode(const char *urlText)
SW_u32 getUniCharFromUTF8(const unsigned char **buf, bool skipValidation=false)
void setSize(unsigned long len)