This function is called for every token encountered in the input text.
211 MyUserData *u = (MyUserData *)userData;
220 if (!strcmp(tag.getName(),
"w")) {
223 if ((!tag.isEmpty()) && (!tag.isEndTag())) {
229 bool endTag = tag.isEndTag();
235 lastText = u->lastTextNode.
c_str();
237 else lastText =
"stuff";
241 if ((attrib = tag.getAttribute(
"xlit"))) {
242 val = strchr(attrib,
':');
243 val = (val) ? (val + 1) : attrib;
247 if ((attrib = tag.getAttribute(
"gloss"))) {
266 if ((attrib = tag.getAttribute(
"POS"))) {
267 val = strchr(attrib,
':');
268 val = (val) ? (val + 1) : attrib;
279 else if (!strcmp(tag.getName(),
"note")) {
280 if (!tag.isEndTag()) {
281 SWBuf type = tag.getAttribute(
"type");
282 bool strongsMarkup = (type ==
"x-strongsMarkup" || type ==
"strongsMarkup");
287 if (!tag.isEmpty()) {
289 if (!strongsMarkup) {
290 SWBuf footnoteNumber = tag.getAttribute(
"swordFootnote");
291 SWBuf footnoteBody =
"";
293 footnoteBody += u->module->getEntryAttributes()[
"Footnote"][footnoteNumber][
"body"];
295 SWBuf noteName = tag.getAttribute(
"n");
297 u->inXRefNote =
true;
304 footnoteNumber.
c_str(),
307 tag.getAttribute(
"type"),
310 outText( u->module->renderText(footnoteBody).c_str(), buf, u);
315 footnoteNumber.
c_str(),
318 tag.getAttribute(
"type"),
321 outText( u->module->renderText(footnoteBody).c_str(), buf, u);
326 u->suspendTextPassThru = (++u->suspendLevel);
328 if (tag.isEndTag()) {
329 u->suspendTextPassThru = (--u->suspendLevel);
330 u->inXRefNote =
false;
331 u->lastSuspendSegment =
"";
337 else if (!strcmp(tag.getName(),
"p") || !strcmp(tag.getName(),
"lg")) {
338 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
339 u->outputNewline(buf);
341 else if (tag.isEndTag()) {
342 u->outputNewline(buf);
345 u->outputNewline(buf);
352 else if (tag.isEmpty() && !strcmp(tag.getName(),
"div") && tag.getAttribute(
"type") && (!strcmp(tag.getAttribute(
"type"),
"x-p") || !strcmp(tag.getAttribute(
"type"),
"paragraph"))) {
354 if (tag.getAttribute(
"sID")) {
355 u->outputNewline(buf);
358 else if (tag.getAttribute(
"eID")) {
359 u->outputNewline(buf);
364 else if (!strcmp(tag.getName(),
"reference")) {
365 if (!u->inXRefNote) {
366 if (!tag.isEndTag()) {
370 bool is_scripRef =
false;
372 target = tag.getAttribute(
"osisRef");
373 const char* the_ref = strchr(target,
':');
389 if(!strncmp(work,
"Bible", 5))
416 else if (!strcmp(tag.getName(),
"l")) {
418 if (tag.getAttribute(
"sID") || (!tag.isEndTag() && !tag.isEmpty())) {
420 outText(
"\\swordpoetryline{", buf, u);
421 u->lineStack->push(tag.toString());
424 else if (tag.getAttribute(
"eID") || tag.isEndTag()) {
426 u->outputNewline(buf);
427 if (u->lineStack->size()) u->lineStack->pop();
431 else if (tag.isEmpty() && !tag.getAttribute(
"sID")) {
432 u->outputNewline(buf);
437 else if (!strcmp(tag.getName(),
"lb") && (!tag.getAttribute(
"type") || strcmp(tag.getAttribute(
"type"),
"x-optional"))) {
438 u->outputNewline(buf);
443 else if ((!strcmp(tag.getName(),
"milestone")) && (tag.getAttribute(
"type"))) {
444 if (!strcmp(tag.getAttribute(
"type"),
"line")) {
445 u->outputNewline(buf);
446 if (tag.getAttribute(
"subType") && !strcmp(tag.getAttribute(
"subType"),
"x-PM")) {
447 u->outputNewline(buf);
450 else if (!strcmp(tag.getAttribute(
"type"),
"x-p")) {
451 if (tag.getAttribute(
"marker"))
452 outText(tag.getAttribute(
"marker"), buf, u);
455 else if (!strcmp(tag.getAttribute(
"type"),
"cQuote")) {
456 const char *tmp = tag.getAttribute(
"marker");
459 tmp = tag.getAttribute(
"level");
460 int level = (tmp) ? atoi(tmp) : 1;
466 else if (u->osisQToTick)
467 outText((level % 2) ?
'\"' :
'\'', buf, u);
473 else if (!strcmp(tag.getName(),
"title")) {
474 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
475 const char *tmp = tag.getAttribute(
"type");
479 outText(
"\n\\swordtitle{", buf, u);
483 if (hasType)
outText(type, buf, u);
488 else if (tag.isEndTag()) {
490 ++u->consecutiveNewlines;
491 u->supressAdjacentWhitespace =
true;
496 else if (!strcmp(tag.getName(),
"list")) {
497 if((!tag.isEndTag()) && (!tag.isEmpty())) {
498 outText(
"\n\\begin{itemize}", buf, u);
500 else if (tag.isEndTag()) {
501 outText(
"\n\\end{itemize}", buf, u);
502 ++u->consecutiveNewlines;
503 u->supressAdjacentWhitespace =
true;
508 else if (!strcmp(tag.getName(),
"item")) {
509 if((!tag.isEndTag()) && (!tag.isEmpty())) {
512 else if (tag.isEndTag()) {
513 ++u->consecutiveNewlines;
514 u->supressAdjacentWhitespace =
true;
518 else if (!strcmp(tag.getName(),
"rdg") || !strcmp(tag.getName(),
"catchWord")) {
519 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
522 else if (tag.isEndTag()) {
528 else if (!strcmp(tag.getName(),
"divineName")) {
529 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
530 outText(
"\\sworddivinename{", buf, u);
531 u->suspendTextPassThru = (++u->suspendLevel);
533 else if (tag.isEndTag()) {
534 SWBuf lastText = u->lastSuspendSegment.
c_str();
535 u->suspendTextPassThru = (--u->suspendLevel);
536 if (lastText.
size()) {
544 else if (!strcmp(tag.getName(),
"hi")) {
545 SWBuf type = tag.getAttribute(
"type");
548 if (!type.
length()) type = tag.getAttribute(
"rend");
550 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
551 if (type ==
"bold" || type ==
"b" || type ==
"x-b") {
552 outText(
"\\textbold{", buf, u);
560 else if (type ==
"ol" || type ==
"overline" || type ==
"x-overline") {
561 outText(
"\\textoverline{", buf, u);
564 else if (type ==
"super") {
565 outText(
"\\textsuperscript{", buf, u);
567 else if (type ==
"sub") {
568 outText(
"\\textsubscript{", buf, u);
573 u->hiStack->push(tag.toString());
575 else if (tag.isEndTag()) {
588 else if (!strcmp(tag.getName(),
"q")) {
589 SWBuf type = tag.getAttribute(
"type");
590 SWBuf who = tag.getAttribute(
"who");
591 const char *tmp = tag.getAttribute(
"level");
592 int level = (tmp) ? atoi(tmp) : 1;
593 tmp = tag.getAttribute(
"marker");
598 if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute(
"sID"))) {
600 if (!tag.isEmpty()) {
601 u->quoteStack->push(tag.toString());
606 outText(u->wordsOfChristStart, buf, u);
612 else if (u->osisQToTick)
613 outText((level % 2) ?
'\"' :
'\'', buf, u);
616 else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute(
"eID"))) {
618 if (tag.isEndTag() && !u->quoteStack->empty()) {
619 XMLTag qTag(u->quoteStack->top());
620 if (u->quoteStack->size()) u->quoteStack->pop();
622 type = qTag.getAttribute(
"type");
623 who = qTag.getAttribute(
"who");
624 tmp = qTag.getAttribute(
"level");
625 level = (tmp) ? atoi(tmp) : 1;
626 tmp = qTag.getAttribute(
"marker");
635 else if (u->osisQToTick)
636 outText((level % 2) ?
'\"' :
'\'', buf, u);
640 outText(u->wordsOfChristEnd, buf, u);
645 else if (!strcmp(tag.getName(),
"transChange")) {
646 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
647 SWBuf type = tag.getAttribute(
"type");
648 u->lastTransChange = type;
651 if ((type ==
"added") || (type ==
"supplied"))
652 outText(
"\\swordtranschange{supplied}{", buf, u);
653 else if (type ==
"tenseChange")
654 outText(
"\\swordtranschange{tense}{", buf, u);
656 else if (tag.isEndTag()) {
664 else if (!strcmp(tag.getName(),
"figure")) {
665 const char *src = tag.getAttribute(
"src");
670 if ((filepath.
size()) && (filepath[filepath.
size()-1] !=
'/') && (src[0] !=
'/'))
676 outText(
"\\includegraphics{", buf, u);
684 else if (!strcmp(tag.getName(),
"div")) {
685 SWBuf type = tag.getAttribute(
"type");
686 if (type ==
"module") {
690 else if (type ==
"testament") {
694 else if (type ==
"bookGroup") {
698 else if (type ==
"book") {
702 else if (type ==
"majorSection") {
706 else if (type ==
"section") {
710 else if (type ==
"paragraph") {
715 else if (!strcmp(tag.getName(),
"span")) {
718 else if (!strcmp(tag.getName(),
"br")) {
721 else if (!strcmp(tag.getName(),
"table")) {
722 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
723 outText(
"\n\\begin{tabular}", buf, u);
725 else if (tag.isEndTag()) {
726 outText(
"\n\\end{tabular}", buf, u);
727 ++u->consecutiveNewlines;
728 u->supressAdjacentWhitespace =
true;
732 else if (!strcmp(tag.getName(),
"row")) {
733 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
737 else if (tag.isEndTag()) {
739 u->firstCell =
false;
743 else if (!strcmp(tag.getName(),
"cell")) {
744 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
745 if (u->firstCell ==
false) {
749 u->firstCell =
false;
752 else if (tag.isEndTag()) {
757 if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
761 if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
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
SWBuf & setFormatted(const char *format,...)
void setSize(unsigned long len)