This function is called for every token encountered in the input text.
219 MyUserData *u = (MyUserData *)userData;
227 if (!strcmp(tag.getName(),
"w")) {
230 if ((!tag.isEmpty()) && (!tag.isEndTag())) {
236 bool endTag = tag.isEndTag();
242 lastText = u->lastTextNode.
c_str();
244 else lastText =
"stuff";
248 if ((attrib = tag.getAttribute(
"xlit"))) {
249 val = strchr(attrib,
':');
250 val = (val) ? (val + 1) : attrib;
254 if ((attrib = tag.getAttribute(
"gloss"))) {
261 outText(
"</rb><rp>(</rp><rt>", buf, u);
262 val = strchr(attrib,
':');
263 val = (val) ? (val + 1) : attrib;
265 outText(
"</rt><rp>)</rp></ruby>", buf, u);
275 if ((attrib = tag.getAttribute(
"POS"))) {
276 val = strchr(attrib,
':');
277 val = (val) ? (val + 1) : attrib;
288 else if (!strcmp(tag.getName(),
"note")) {
289 if (!tag.isEndTag()) {
290 SWBuf type = tag.getAttribute(
"type");
293 if (type ==
"strongsMarkup") type =
"x-strongsMarkup";
294 if (type ==
"x-cross-ref") type =
"crossReference";
296 SWBuf subType = tag.getAttribute(
"subType");
297 SWBuf classExtras =
"";
302 if (subType.
size()) {
306 bool strongsMarkup = type ==
"x-strongsMarkup";
311 if (!tag.isEmpty()) {
313 if (!strongsMarkup) {
314 SWBuf footnoteNumber = tag.getAttribute(
"swordFootnote");
315 SWBuf noteName = tag.getAttribute(
"n");
316 char ch = (type ==
"crossReference" ?
'x':
'n');
318 u->inXRefNote =
true;
323 buf.
appendFormatted(
"<a class=\"noteMarker%s\" href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
334 buf.
appendFormatted(
"<a class=\"noteMarker%s\" href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
346 u->suspendTextPassThru = (++u->suspendLevel);
348 if (tag.isEndTag()) {
349 u->suspendTextPassThru = (--u->suspendLevel);
350 u->inXRefNote =
false;
351 u->lastSuspendSegment =
"";
356 else if (!strcmp(tag.getName(),
"p") || !strcmp(tag.getName(),
"lg")) {
357 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
358 u->outputNewline(buf);
360 else if (tag.isEndTag()) {
361 u->outputNewline(buf);
364 u->outputNewline(buf);
371 else if (tag.isEmpty() && !strcmp(tag.getName(),
"div") && tag.getAttribute(
"type") && (!strcmp(tag.getAttribute(
"type"),
"x-p") || !strcmp(tag.getAttribute(
"type"),
"paragraph") || !strcmp(tag.getAttribute(
"type"),
"colophon"))) {
373 if (tag.getAttribute(
"sID")) {
374 u->outputNewline(buf);
376 if (!strcmp(tag.getAttribute(
"type"),
"colophon")) {
377 outText(
"<div class=\"colophon\">", buf, u);
382 else if (tag.getAttribute(
"eID")) {
383 u->outputNewline(buf);
385 if (!strcmp(tag.getAttribute(
"type"),
"colophon")) {
393 else if (!strcmp(tag.getName(),
"reference")) {
394 if (!u->inXRefNote) {
395 if (!tag.isEndTag()) {
402 bool is_scripRef =
false;
404 target = tag.getAttribute(
"osisRef");
405 const char* the_ref = strchr(target,
':');
406 type = tag.getAttribute(
"type");
426 if(!strncmp(work,
"Bible", 5))
432 buf.
appendFormatted(
"<a class=\"%s\" href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=\">",
449 outText(u->interModuleLinkEnd, buf, u);
455 else if (!strcmp(tag.getName(),
"l")) {
457 if (tag.getAttribute(
"sID") || (!tag.isEndTag() && !tag.isEmpty())) {
458 SWBuf type = tag.getAttribute(
"type");
459 if (type ==
"selah") {
460 outText(
"<p class=\"selah\">", buf, u);
463 outText(
SWBuf(
"<span class=\"line indent").appendFormatted(
"%d\">", u->lineStack->size() + (
SWBuf(
"x-indent") == tag.getAttribute(
"type")?1:0)).
c_str(), buf, u);
465 u->lineStack->push(tag.toString());
468 else if (tag.getAttribute(
"eID") || tag.isEndTag()) {
470 if (!u->lineStack->empty()) {
471 XMLTag startTag(u->lineStack->top());
472 type = startTag.getAttribute(
"type");
474 if (type ==
"selah") {
478 u->outputNewline(buf);
480 if (u->lineStack->size()) u->lineStack->pop();
484 else if (tag.isEmpty() && !tag.getAttribute(
"sID")) {
485 u->outputNewline(buf);
490 else if (!strcmp(tag.getName(),
"lb") && (!tag.getAttribute(
"type") || strcmp(tag.getAttribute(
"type"),
"x-optional"))) {
491 u->outputNewline(buf);
496 else if ((!strcmp(tag.getName(),
"milestone")) && (tag.getAttribute(
"type"))) {
498 const char *type = tag.getAttribute(
"type");
499 if (!strcmp(type,
"line")) {
500 u->outputNewline(buf);
501 if (tag.getAttribute(
"subType") && !strcmp(tag.getAttribute(
"subType"),
"x-PM")) {
502 u->outputNewline(buf);
505 else if (!strcmp(type,
"x-p")) {
506 if (tag.getAttribute(
"marker"))
507 outText(tag.getAttribute(
"marker"), buf, u);
510 else if (!strcmp(type,
"cQuote")) {
511 const char *tmp = tag.getAttribute(
"marker");
514 tmp = tag.getAttribute(
"level");
515 int level = (tmp) ? atoi(tmp) : 1;
521 else if (u->osisQToTick)
522 outText((level % 2) ?
'\"' :
'\'', buf, u);
524 else if (!strcmp(type,
"x-importer")) {
530 SWBuf attVal = tag.getAttribute(
"type");
531 outText(
SWBuf(
"<span class=\"") + attVal +
"\"", buf,u);
532 StringList attributes = tag.getAttributeNames();
533 for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); ++it) {
534 attVal = tag.getAttribute(*it);
535 outText(
SWBuf(
" data-") + *it +
"=\"" + attVal +
"\"", buf,u);
543 else if (!strcmp(tag.getName(),
"title")) {
544 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
545 SWBuf type = tag.getAttribute(
"type");
546 SWBuf canonical = tag.getAttribute(
"canonical");
548 SWBuf classExtras =
"";
553 if (canonical.
size() && !strcmp(canonical,
"true")) {
554 classExtras.
append(
" canonical");
556 if (u->vkey && !u->vkey->getVerse()) {
557 if (!u->vkey->getChapter()) {
558 if (!u->vkey->getBook()) {
559 if (!u->vkey->getTestament()) {
560 outText(
SWBuf(
"<h1 class=\"moduleHeader") + classExtras +
"\">", buf, u);
561 tag.setAttribute(
"pushed",
"h1");
564 outText(
SWBuf(
"<h1 class=\"testamentHeader") + classExtras +
"\">", buf, u);
565 tag.setAttribute(
"pushed",
"h1");
569 outText(
SWBuf(
"<h1 class=\"bookHeader") + classExtras +
"\">", buf, u);
570 tag.setAttribute(
"pushed",
"h1");
574 outText(
SWBuf(
"<h2 class=\"chapterHeader") + classExtras +
"\">", buf, u);
575 tag.setAttribute(
"pushed",
"h2");
579 outText(
SWBuf(
"<h3 class=\"title") + classExtras +
"\">", buf, u);
580 tag.setAttribute(
"pushed",
"h3");
582 u->titleStack->push(tag.toString());
584 else if (tag.isEndTag()) {
585 if (!u->titleStack->empty()) {
586 XMLTag tag(u->titleStack->top());
587 if (u->titleStack->size()) u->titleStack->pop();
588 SWBuf pushed = tag.getAttribute(
"pushed");
595 ++u->consecutiveNewlines;
596 u->supressAdjacentWhitespace =
true;
602 else if (!strcmp(tag.getName(),
"list")) {
603 if((!tag.isEndTag()) && (!tag.isEmpty())) {
606 else if (tag.isEndTag()) {
608 ++u->consecutiveNewlines;
609 u->supressAdjacentWhitespace =
true;
614 else if (!strcmp(tag.getName(),
"item")) {
615 if((!tag.isEndTag()) && (!tag.isEmpty())) {
618 else if (tag.isEndTag()) {
620 ++u->consecutiveNewlines;
621 u->supressAdjacentWhitespace =
true;
625 else if (!strcmp(tag.getName(),
"rdg") || !strcmp(tag.getName(),
"catchWord") || !strcmp(tag.getName(),
"inscription")) {
626 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
627 outText(
"<span class=\"", buf, u);
628 outText(tag.getName(), buf, u);
631 else if (tag.isEndTag()) {
636 else if (!strcmp(tag.getName(),
"seg")) {
637 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
638 SWBuf type = tag.getAttribute(
"type");
639 outText(
"<span class=\"", buf, u);
643 else if (tag.isEndTag()) {
649 else if (!strcmp(tag.getName(),
"divineName")) {
650 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
651 u->suspendTextPassThru = (++u->suspendLevel);
653 else if (tag.isEndTag()) {
654 SWBuf lastText = u->lastSuspendSegment.
c_str();
655 u->suspendTextPassThru = (--u->suspendLevel);
656 if (lastText.
size()) {
664 else if (!strcmp(tag.getName(),
"hi")) {
665 SWBuf type = tag.getAttribute(
"type");
668 if (!type.
length()) type = tag.getAttribute(
"rend");
670 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
671 if (type ==
"bold" || type ==
"b" || type ==
"x-b") {
680 else if (type ==
"ol" || type ==
"overline" || type ==
"x-overline") {
681 outText(
"<span class=\"overline\">", buf, u);
684 else if (type ==
"super") {
687 else if (type ==
"sub") {
690 else if (type ==
"i" || type ==
"italic") {
696 u->hiStack->push(tag.toString());
698 else if (tag.isEndTag()) {
700 if (!u->hiStack->empty()) {
701 XMLTag tag(u->hiStack->top());
702 if (u->hiStack->size()) u->hiStack->pop();
703 type = tag.getAttribute(
"type");
704 if (!type.
length()) type = tag.getAttribute(
"rend");
706 if (type ==
"bold" || type ==
"b" || type ==
"x-b") {
709 else if (type ==
"ol") {
712 else if (type ==
"super") {
715 else if (type ==
"sub") {
718 else if (type ==
"i" || type ==
"italic") {
734 else if (!strcmp(tag.getName(),
"q")) {
735 SWBuf type = tag.getAttribute(
"type");
736 SWBuf who = tag.getAttribute(
"who");
737 const char *tmp = tag.getAttribute(
"level");
738 int level = (tmp) ? atoi(tmp) : 1;
739 tmp = tag.getAttribute(
"marker");
744 if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute(
"sID"))) {
746 if (!tag.isEmpty()) {
747 u->quoteStack->push(tag.toString());
752 outText(u->wordsOfChristStart, buf, u);
758 else if (u->osisQToTick)
759 outText((level % 2) ?
'\"' :
'\'', buf, u);
762 else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute(
"eID"))) {
764 if (tag.isEndTag() && !u->quoteStack->empty()) {
765 XMLTag qTag(u->quoteStack->top());
766 if (u->quoteStack->size()) u->quoteStack->pop();
768 type = qTag.getAttribute(
"type");
769 who = qTag.getAttribute(
"who");
770 tmp = qTag.getAttribute(
"level");
771 level = (tmp) ? atoi(tmp) : 1;
772 tmp = qTag.getAttribute(
"marker");
781 else if (u->osisQToTick)
782 outText((level % 2) ?
'\"' :
'\'', buf, u);
786 outText(u->wordsOfChristEnd, buf, u);
791 else if (!strcmp(tag.getName(),
"transChange")) {
792 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
793 SWBuf type = tag.getAttribute(
"type");
794 u->lastTransChange = type;
796 outText(
"<span class=\"transChange", buf, u);
798 outText(
" transChange-", buf, u);
803 else if (tag.isEndTag()) {
811 else if (!strcmp(tag.getName(),
"figure")) {
812 const char *src = tag.getAttribute(
"src");
817 if ((filepath.
size()) && (filepath[filepath.
size()-1] !=
'/') && (src[0] !=
'/'))
823 outText(
"<a href=\"passagestudy.jsp?action=showImage&value=", buf, u);
829 outText(
"<img src=\"file:", buf, u);
831 outText(
"\" border=\"0\" />", buf, u);
838 else if (!strcmp(tag.getName(),
"div")) {
839 SWBuf type = tag.getAttribute(
"type");
840 if (type ==
"bookGroup") {
842 else if (type ==
"book") {
844 else if (type ==
"section") {
846 else if (type ==
"majorSection") {
848 else if ((!tag.isEndTag()) && (!tag.isEmpty())) {
849 SWBuf type = tag.getAttribute(
"type");
850 outText(
"<div class=\"", buf, u);
854 else if (tag.isEndTag()) {
857 else if (!(type ==
"colophon")) {
858 if (tag.getAttribute(
"sID")) tag.setEmpty(
false);
859 if (tag.getAttribute(
"eID")) tag.setEndTag(
true);
864 else if (!strcmp(tag.getName(),
"span")) {
867 else if (!strcmp(tag.getName(),
"abbr")) {
868 if (!tag.isEndTag()) {
869 SWBuf title = tag.getAttribute(
"expansion");
870 outText(
"<abbr title=\"", buf, u);
874 else if (tag.isEndTag()) {
879 else if (!strcmp(tag.getName(),
"br")) {
882 else if (!strcmp(tag.getName(),
"table")) {
883 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
884 outText(
"<table><tbody>\n", buf, u);
886 else if (tag.isEndTag()) {
887 outText(
"</tbody></table>\n", buf, u);
888 ++u->consecutiveNewlines;
889 u->supressAdjacentWhitespace =
true;
893 else if (!strcmp(tag.getName(),
"row")) {
894 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
897 else if (tag.isEndTag()) {
902 else if (!strcmp(tag.getName(),
"cell")) {
903 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
906 else if (tag.isEndTag()) {
911 if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
915 if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
SWBuf & appendFormatted(const char *format,...)
unsigned long length() const
virtual const char * getConfigEntry(const char *key) const
bool startsWith(const SWBuf &prefix) const
bool substituteToken(SWBuf &buf, const char *token)
void processLemma(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf)
const char * c_str() const
std::list< SWBuf > StringList
SWBuf & append(const char *str, long max=-1)
static SWORD_NAMESPACE_START const char * classes[]
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,...)
static const SWBuf encode(const char *urlText)
void setSize(unsigned long len)