示例#1
0
bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
	if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
		MyUserData *u = (MyUserData *)userData;		
		XMLTag tag(token);
		if ((!tag.isEndTag()) && (!tag.isEmpty()))
			u->startTag = tag;
		if (tag.getName() && !strcmp(tag.getName(), "sync")) {
			SWBuf value = tag.getAttribute("value");
			if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //>
				buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str());
			}
			else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) {
				if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') {
					value<<1;
					buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str());
				}
				else if (value[0] == 'T') {
					value<<1;
					buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str());
				}
			}
			else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) {
				if (!tag.isEndTag())
					buf += "{\\b ";
				else	buf += "}";
			}
		}
		// <note> tag
		else if (!strcmp(tag.getName(), "note")) {
			if (!tag.isEndTag()) {
				if (!tag.isEmpty()) {
					SWBuf type = tag.getAttribute("type");
					SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
					VerseKey *vkey = NULL;
					// see if we have a VerseKey * or descendant
					SWTRY {
						vkey = SWDYNAMIC_CAST(VerseKey, u->key);
					}
					SWCATCH ( ... ) {	}
					if (vkey) {
						// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
						char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
						buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->Verse(), footnoteNumber.c_str());
					}
					u->suspendTextPassThru = true;
				}
			}
			if (tag.isEndTag()) {
				u->suspendTextPassThru = false;
			}
		}
示例#2
0
bool GBFWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
	const char *tok;
	char val[128];
	char *valto;
	const char *num;
	SWBuf url;

	if (!substituteToken(buf, token)) {
		if (!strncmp(token, "w", 1)) {
			// OSIS Word (temporary until OSISRTF is done)
			valto = val;
			num = strstr(token, "lemma=\"x-Strongs:");
			if (num) {
				for (num+=17; ((*num) && (*num != '\"')); num++)
					*valto++ = *num;
				*valto = 0;

				if (atoi((!isdigit(*val))?val+1:val) < 5627) {
					buf += " <small><em>&lt;";
					url = "";
					for (tok = val; *tok; tok++) {
						url += *tok;
					}
					if ((url.length() > 1) && strchr("GH", url[0])) {
						if (isdigit(url[1]))
							url = url.c_str()+1;
					}
					buf.appendFormatted("<a href=\"%s?showStrong=%s#cv\">", passageStudyURL.c_str(), URL::encode(url).c_str());

					for (tok = (!isdigit(*val))?val+1:val; *tok; tok++) {
						buf += *tok;
					}
					buf += "</a>&gt;</em></small> ";
				}
			}
			else {
				num = strstr(token, "lemma=\"strong:");
				if (num) {
					for (num+=14; ((*num) && (*num != '\"')); num++)
						*valto++ = *num;
					*valto = 0;

					if (atoi((!isdigit(*val))?val+1:val) < 5627) {
						buf += " <small><em>&lt;";
						url = "";
						for (tok = val; *tok; tok++) {
							url += *tok;
						}
						if ((url.length() > 1) && strchr("GH", url[0])) {
							if (isdigit(url[1]))
								url = url.c_str()+1;
						}
						buf.appendFormatted("<a href=\"%s?showStrong=%s#cv\">", passageStudyURL.c_str(), URL::encode(url).c_str());

						for (tok = (!isdigit(*val))?val+1:val; *tok; tok++) {
							buf += *tok;
						}
						buf += "</a>&gt;</em></small> ";
					}
				}
			}
			valto = val;
			num = strstr(token, "morph=\"x-Robinson:");
			if (num) {
				for (num+=18; ((*num) && (*num != '\"')); num++)
					*valto++ = *num;
				*valto = 0;
				buf += " <small><em>(";
				url = "";
				for (tok = val; *tok; tok++) {
				// normal robinsons tense
					buf += *tok;
				}
				buf.appendFormatted("<a href=\"%s?showMorph=%s#cv\">", passageStudyURL.c_str(), URL::encode(url).c_str());

				for (tok = val; *tok; tok++) {
					buf += *tok;
				}
				buf += "</a>)</em></small> ";
			}
		}

		else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
			buf += " <small><em>&lt;";
			url = "";

			for (tok = token+1; *tok; tok++) {
				url += *tok;
			}
			if ((url.length() > 1) && strchr("GH", url[0])) {
				if (isdigit(url[1]))
					url = url.c_str()+1;
			}
			buf.appendFormatted("<a href=\"%s?showStrong=%s#cv\">", passageStudyURL.c_str(), URL::encode(url).c_str());

			for (tok = token + 2; *tok; tok++) {
				buf += *tok;
			}
			buf += "</a>&gt;</em></small>";
		}

		else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
			buf += " <small><em>(";
			url = "";
			for (tok = token + 2; *tok; tok++) {
				if(*tok != '\"')
					url += *tok;
			}
			if ((url.length() > 1) && strchr("GH", url[0])) {
				if (isdigit(url[1]))
					url = url.c_str()+1;
			}
			buf.appendFormatted("<a href=\"%s?showStrong=%s#cv\">", passageStudyURL.c_str(), URL::encode(url).c_str());

			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "</a>)</em></small>";
		}

		else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
			buf += " <small><em>(";
			for (tok = token + 2; *tok; tok++) {
				if(*tok != '\"')
					buf += *tok;
			}
			buf.appendFormatted("<a href=\"%s?showMorph=%s#cv\">", passageStudyURL.c_str(), URL::encode(url).c_str());

			for (tok = token + 2; *tok; tok++) {
				if(*tok != '\"')
					buf += *tok;
			}
			buf += "</a>)</em></small>";
		}

		else if (!strncmp(token, "RX", 2)) {
			buf += "<a href=\"";
			for (tok = token + 3; *tok; tok++) {
			  if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
			    buf += *tok;
			  }
			  else {
			    break;
			  }
			}

			buf.appendFormatted("a href=\"%s?key=%s#cv\">", passageStudyURL.c_str(), URL::encode(url).c_str());
		}
		// ok to leave these in
		else if ((!strncmp(token, "span", 4))
				|| (!strncmp(token, "/span", 5))) {
			buf.appendFormatted("<%s>", token);
		}

		else {
			return GBFXHTML::handleToken(buf, token, userData);
		}
	}
	return true;
}
示例#3
0
bool TEILaTeX::handleToken(std::string &buf, const char *token, BasicFilterUserData *userData) {
  // manually process if it wasn't a simple substitution
    if (!substituteToken(buf, token)) {
        MyUserData *u = (MyUserData *)userData;
        XMLTag tag(token);

        if (!strcmp(tag.getName(), "p")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {    // non-empty start tag
                buf += "";
            }
            else if (tag.isEndTag()) {    // end tag
                buf += "//\n";
                //userData->supressAdjacentWhitespace = true;
            }
            else {                    // empty paragraph break marker
                buf += "//\n";
                //userData->supressAdjacentWhitespace = true;
            }
        }

        // <hi>
        else if (!strcmp(tag.getName(), "hi")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                std::string rend = tag.getAttribute("rend");

                u->lastHi = rend;
                if (rend == "italic" || rend == "ital")
                    buf += "\\it{";
                else if (rend == "bold")
                    buf += "\\bd{";
                else if (rend == "super" || rend == "sup")
                    buf += "^{";
                else if (rend == "sub")
                    buf += "_{";
                else if (rend == "overline")
                    buf += "\\overline{";

            }
            else if (tag.isEndTag()) {
                buf += "}";
            }
        }

        // <entryFree>
        else if (!strcmp(tag.getName(), "entryFree")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                std::string n = tag.getAttribute("n");
                if (n != "") {
                    buf += "\\teiEntryFree{";
                    buf += n;
                    buf += "}";
                }
            }
        }

        // <sense>
        else if (!strcmp(tag.getName(), "sense")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                std::string n = tag.getAttribute("n");
                if (n != "") {
                    buf += "\n\\teiSense{";
                    buf += n;
                    buf += "}";
                }
            }
        }

        // <div>
        else if (!strcmp(tag.getName(), "div")) {

            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "";
            }
            else if (tag.isEndTag()) {
            }
        }

        // <lb.../>
        else if (!strcmp(tag.getName(), "lb")) {
            buf += "//\n";
        }

        // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def>
        else if (!strcmp(tag.getName(), "pos") ||
                 !strcmp(tag.getName(), "gen") ||
                 !strcmp(tag.getName(), "case") ||
                 !strcmp(tag.getName(), "gram") ||
                 !strcmp(tag.getName(), "number") ||
                 !strcmp(tag.getName(), "pron") ||
                 !strcmp(tag.getName(), "tr") ||
                 !strcmp(tag.getName(), "orth") ||
                 !strcmp(tag.getName(), "etym") ||
                 !strcmp(tag.getName(), "usg") ||


                 !strcmp(tag.getName(), "def")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "\\tei";
                buf += tag.getName();
                buf += "{";
            }
            else if (tag.isEndTag()) {
                buf += "}";
            }
        }

        else if (!strcmp(tag.getName(), "ref")) {
            if (!tag.isEndTag()) {
                u->suspendTextPassThru = true;
                std::string target;
                std::string work;
                std::string ref;

                int was_osisref = false;
                if(!tag.getAttribute("osisRef").empty())
                {
                    target += tag.getAttribute("osisRef");
                    was_osisref=true;
                }
                else if(!tag.getAttribute("target").empty())
                    target += tag.getAttribute("target");

                if(target.size())
                {
                    const char* the_ref = std::strchr(target.c_str(), ':');

                    if(!the_ref) {
                        // No work
                        ref = target;
                    }
                    else {
                        // Compensate for starting :
                        ref = the_ref + 1;

                        int size = target.size() - ref.size() - 1;
                        work.resize(size, '\0');
                        strncpy(&work[0u], target.c_str(), size);
                    }

                    if(was_osisref)
                    {
                        buf += formatted("\\swordref{%s}{%s}{",
                            ref.c_str(),
                            work.c_str());
                    }
                    else
                    {
                        // Dictionary link, or something
                        buf += formatted("\\sworddictref{%s}{%s}{",
                            (!work.empty()) ? work.c_str() : u->version.c_str(),
                            ref.c_str()
                            );
                    }
                }
                else
                {
                    //std::cout << "TARGET WASN'T\n";
                }

            }
            else {
                buf += u->lastTextNode.c_str();
                buf += "}";

                u->suspendTextPassThru = false;
            }
        }

           // <note> tag
        else if (!strcmp(tag.getName(), "note")) {
            if (!tag.isEndTag()) {
                if (!tag.isEmpty()) {
                    u->suspendTextPassThru = true;
                }
            }
            if (tag.isEndTag()) {
                std::string footnoteNumber = tag.getAttribute("swordFootnote");
                std::string noteName = tag.getAttribute("n");
                std::string footnoteBody = "";
                if (u->module){
                    footnoteBody += u->module->getEntryAttributes()["Footnote"][footnoteNumber]["body"];
                }

                buf += formatted("\\swordfootnote{%s}{%s}{%s}{%s}{",
                    footnoteNumber.c_str(),
                    u->version.c_str(),
                    u->key->getText(),
                    renderNoteNumbers ? noteName.c_str() : "");
                    if (u->module) {
                        buf += u->module->renderText(footnoteBody.c_str()).c_str();
                    }
                u->suspendTextPassThru = false;
            }
        }

        // <graphic> image tag
        else if (!strcmp(tag.getName(), "graphic")) {
            auto url(tag.getAttribute("url"));
            if (!url.empty()) {        // assert we have a url attribute
                std::string filepath;
                if (userData->module) {
                    filepath = userData->module->getConfigEntry("AbsoluteDataPath");
                    if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (url[0] != '/'))
                        filepath += '/';
                }
                filepath += url;

                buf += formatted("\\figure{\\includegraphics{%s}}",
                            filepath.c_str());
                u->suspendTextPassThru = false;

            }
        }

        // <table> <row> <cell>
        else if (!strcmp(tag.getName(), "table")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "\n\\begin{tabular}";
            }
            else if (tag.isEndTag()) {
                buf += "\n\\end{tabular}";
                ++u->consecutiveNewlines;
                u->supressAdjacentWhitespace = true;
            }

        }
        else if (!strcmp(tag.getName(), "row")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "\n";
                u->firstCell = true;
            }
            else if (tag.isEndTag()) {
                buf += "//";
                u->firstCell = false;
            }

        }
        else if (!strcmp(tag.getName(), "cell")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                if (u->firstCell == false) {
                    buf += " & ";
                }
                else {
                    u->firstCell = false;
                }
            }
            else if (tag.isEndTag()) {
                buf += "";
            }
        }


        else {
            return false;  // we still didn't handle token
        }

    }
    return true;
}
示例#4
0
bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
	MyUserData *u = (MyUserData *)userData;
	SWBuf scratch;
	bool sub = (u->suspendTextPassThru) ? substituteToken(scratch, token) : substituteToken(buf, token);
	if (!sub) {
  // manually process if it wasn't a simple substitution
		XMLTag tag(token);
		
		// <w> tag
		if (!strcmp(tag.getName(), "w")) {
 
			// start <w> tag
			if ((!tag.isEmpty()) && (!tag.isEndTag())) {
				u->w = token;
			}

			// end or empty <w> tag
			else {
				bool endTag = tag.isEndTag();
				SWBuf lastText;
				//bool show = true;	// to handle unplaced article in kjv2003-- temporary till combined

				if (endTag) {
					tag = u->w.c_str();
					lastText = u->lastTextNode.c_str();
				}
				else lastText = "stuff";

				const char *attrib;
				const char *val;
				if ((attrib = tag.getAttribute("xlit"))) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					outText(" ", buf, u);
					outText(val, buf, u);
				}
				if ((attrib = tag.getAttribute("gloss"))) {
					// I'm sure this is not the cleanest way to do it, but it gets the job done
					// for rendering ruby chars properly ^_^
					buf -= lastText.length();
					
					outText("<ruby><rb>", buf, u);
					outText(lastText, buf, u);
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					outText("</rb><rp>(</rp><rt>", buf, u);
					outText(val, buf, u);
					outText("</rt><rp>)</rp></ruby>", buf, u);
				}
				if (!morphFirst) {
					processLemma(u->suspendTextPassThru, tag, buf);
					processMorph(u->suspendTextPassThru, tag, buf);
				}
				else {
					processMorph(u->suspendTextPassThru, tag, buf);
					processLemma(u->suspendTextPassThru, tag, buf);
				}
				if ((attrib = tag.getAttribute("POS"))) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					outText(" ", buf, u);
					outText(val, buf, u);
				}

				/*if (endTag)
					buf += "}";*/
			}
		}

		// <note> tag
		else if (!strcmp(tag.getName(), "note")) {
			if (!tag.isEndTag()) {
				SWBuf type = tag.getAttribute("type");
				bool strongsMarkup = (type == "x-strongsMarkup" || type == "strongsMarkup");	// the latter is deprecated
				if (strongsMarkup) {
					tag.setEmpty(false);	// handle bug in KJV2003 module where some note open tags were <note ... />
				}

				if (!tag.isEmpty()) {

					if (!strongsMarkup) {	// leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
						SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
						SWBuf noteName = tag.getAttribute("n");
						VerseKey *vkey = NULL;
						char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');

						u->inXRefNote = true; // Why this change? Ben Morgan: Any note can have references in, so we need to set this to true for all notes
//						u->inXRefNote = (ch == 'x');

						// see if we have a VerseKey * or descendant
						SWTRY {
							vkey = SWDYNAMIC_CAST(VerseKey, u->key);
						}
						SWCATCH ( ... ) {	}
						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>",
						        ch, 
							URL::encode(footnoteNumber.c_str()).c_str(), 
							URL::encode(u->version.c_str()).c_str(), 
							URL::encode(vkey ? vkey->getText() : u->key->getText()).c_str(), 
							ch,
							ch, 
							(renderNoteNumbers ? noteName.c_str() : ""));
					}
				}
				u->suspendTextPassThru = (++u->suspendLevel);
			}
示例#5
0
bool GBFXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
	const char *tok;
	MyUserData *u = (MyUserData *)userData;

	if (!substituteToken(buf, token)) {
		XMLTag tag(token);
		
		if (!strncmp(token, "WG", 2)) { // strong's numbers
			//buf += " <small><em>&lt;<a href=\"type=Strongs value=";
			buf += " <small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=Greek&value=";
			for (tok = token+2; *tok; tok++)
				//if(token[i] != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">";
			for (tok = token + 2; *tok; tok++)
				//if(token[i] != '\"')
					buf += *tok;
			buf += "</a>&gt;</em></small>";
		}
		else if (!strncmp(token, "WH", 2)) { // strong's numbers
			//buf += " <small><em>&lt;<a href=\"type=Strongs value=";
			buf += " <small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=Hebrew&value=";
			for (tok = token+2; *tok; tok++)
				//if(token[i] != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">";
			for (tok = token + 2; *tok; tok++)
				//if(token[i] != '\"')
					buf += *tok;
			buf += "</a>&gt;</em></small>";
		}
		else if (!strncmp(token, "WTG", 3)) { // strong's numbers tense
			//buf += " <small><em>(<a href=\"type=Strongs value=";
			buf += " <small><em class=\"strongs\">(<a href=\"passagestudy.jsp?action=showStrongs&type=Greek&value=";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "</a>)</em></small>";
		}
		else if (!strncmp(token, "WTH", 3)) { // strong's numbers tense
			//buf += " <small><em>(<a href=\"type=Strongs value=";
			buf += " <small><em class=\"strongs\">(<a href=\"passagestudy.jsp?action=showStrongs&type=Hebrew&value=";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "</a>)</em></small>";
		}

		else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
			//buf += " <small><em>(<a href=\"type=morph class=none value=";
			buf += " <small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=Greek&value=";
			
			for (tok = token + 2; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "\" class=\"morph\">";
			for (tok = token + 2; *tok; tok++)				
				if(*tok != '\"') 			
					buf += *tok;		
			buf += "</a>)</em></small>";
		}

		else if (!strcmp(tag.getName(), "RX")) {
			buf += "<a href=\"";
			for (tok = token + 3; *tok; tok++) {
			  if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
			    buf += *tok;
			  }
			  else {
			    break;
			  }
			}
			buf += "\">";
		}
		else if (!strcmp(tag.getName(), "RF")) {
			SWBuf type = tag.getAttribute("type");
			SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
			SWBuf noteName = tag.getAttribute("n");
			VerseKey *vkey = NULL;
			// see if we have a VerseKey * or descendant
			SWTRY {
				vkey = SWDYNAMIC_CAST(VerseKey, u->key);
			}
			SWCATCH ( ... ) {	}
			if (vkey) {
				// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
				//char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
				buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ", 
					URL::encode(footnoteNumber.c_str()).c_str(),
					URL::encode(u->version.c_str()).c_str(), 
					URL::encode(vkey->getText()).c_str(), 
					(renderNoteNumbers ? URL::encode(noteName.c_str()).c_str(): ""));
			}
			u->suspendTextPassThru = true;
		}
示例#6
0
文件: thmlcgi.cpp 项目: raphink/sword
bool ThMLCGI::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *baseUserData) {
	MyUserData *userData = (MyUserData *) baseUserData;
	unsigned long i;
	if (!substituteToken(buf, token)) {
	// manually process if it wasn't a simple substitution
		if (!strncmp(token, "sync ", 5)) {
			buf += "<a href=\"!DIATHEKE_URL!";
			char* pbuf;
			char typ[32]; typ[0] = 0;
			char val[32]; val[0] = 0;
			char cls[32]; cls[0] = 0;
			for (unsigned int j = 5; j < strlen(token); j++) {
                                if (!strncmp(token+j, "type=\"", 6)) {
				        pbuf = typ;
                                        j += 6;
                                        for (;token[j] != '\"'; j++)
                				*(pbuf)++ = token[j];
					*(pbuf) = 0;
                                }
                                else if (!strncmp(token+j, "value=\"", 7)) {
				        pbuf = val;
                                        j += 7;
                                        for (;token[j] != '\"'; j++)
                				*(pbuf)++ = token[j];
					*(pbuf) = 0;
                                }
                                else if (!strncmp(token+j, "class=\"", 7)) {
				        pbuf = cls;
                                        j += 7;
                                        for (;token[j] != '\"'; j++)
                				*(pbuf)++ = token[j];
					*(pbuf) = 0;					
                                }
                        }
			if (*cls && *val) {
			        buf.appendFormatted("%s=on&verse=%s", cls, val);
			}
			else if (*typ && *val) {
			  if (!strnicmp(typ, "Strongs", 7)) {
			    if (*val == 'G') {
			      buf.appendFormatted("StrongsGreek=on&verse=%s", val + 1);
			    }
			    else if (*val == 'H') {
			      buf.appendFormatted("StrongsHebrew=on&verse=%s", val + 1);
			    }
			  }

			  else if (!strnicmp(typ, "Morph", 5)) {
			    if (*val == 'G') {
			      buf.appendFormatted("StrongsGreek=on&verse=%s", val + 1);
			    }
			    else if (*val == 'H') {
			      buf.appendFormatted("StrongsHebrew=on&verse=%s", val + 1);
			    }
			    else {
			      buf.appendFormatted("Packard=on&verse=%s", val);
			    }
			  }
			  else {
			    buf.appendFormatted("%s=on&verse=%s", typ, val);
			  }
			}
			buf += "\">";
			
			if (*val) {
			        buf += val;
			}
			buf += "</a>";
		}

		else if (!strncmp(token, "scripRef p", 10) || !strncmp(token, "scripRef v", 10)) {
        		userData->properties["inscriptRef"] = "true";
			buf += "<a href=\"!DIATHEKE_URL!";
			for (i = 9; i < strlen(token); i++) {
			  if (!strncmp(token+i, "version=\"", 9)) {
			    i += 9;
			    for (;token[i] != '\"'; i++)
			      buf += token[i];
			    buf += "=on&";
			  }
			  if (!strncmp(token+i, "passage=\"", 9)) {
			    i += 9;
			    buf += "verse=";
			    for (;token[i] != '\"'; i++) {
			      if (token[i] == ' ') buf += '+';
			      else buf += token[i];
			    }
			    buf += '&';
			  }
			}
			buf += "\">";
		} 

		// we're starting a scripRef like "<scripRef>John 3:16</scripRef>"
		else if (!strcmp(token, "scripRef")) {
			userData->properties["inscriptRef"] = "false";
			// let's stop text from going to output
			userData->properties["suspendTextPassThru"] = "true";
		}

		// we've ended a scripRef 
		else if (!strcmp(token, "/scripRef")) {
			if (userData->properties["inscriptRef"] == "true") { // like  "<scripRef passage="John 3:16">John 3:16</scripRef>"
				userData->properties["inscriptRef"] = "false";
				buf += "</a>";
			}
			
			else { // like "<scripRef>John 3:16</scripRef>"
				buf += "<a href=\"!DIATHEKE_URL!verse=";

				char* vref = (char*)userData->properties["lastTextNode"].c_str();
				while (*vref) {
				  if (*vref == ' ') buf += '+';
				  else buf += *vref;
				  vref++;
				}
				buf += "\">";
				buf += userData->properties["lastTextNode"].c_str();
				// let's let text resume to output again
				userData->properties["suspendTextPassThru"] = "false";	
				buf += "</a>";
			}
		}

		else if (!strncmp(token, "div class=\"sechead\"", 19)) {
		        userData->properties["SecHead"] = "true";
			buf += "<br /><b><i>";
		}
		else if (!strncmp(token, "div class=\"title\"", 19)) {
		        userData->properties["SecHead"] = "true";
			buf += "<br /><b><i>";
		}
		else if (!strncmp(token, "/div", 4)) {
		        if (userData->properties["SecHead"] == "true") {
			        buf += "</i></b><br />";
				userData->properties["SecHead"] = "false";
			}
		}

                else if(!strncmp(token, "note", 4)) {
                        buf += " <small><font color=\"#008000\">{";
                }                

		else {
			buf += '<';
			for (i = 0; i < strlen(token); i++)
				buf += token[i];
				buf += '>';
			//return false;  // we still didn't handle token
		}
	}
	return true;
}
示例#7
0
bool GBFCGI::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
	unsigned long i;
	if (!substituteToken(buf, token)) {
		if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
			buf += " <small><em>&lt;<a href=\"!DIATHEKE_URL!";
			if (token[1] == 'H') {
			  buf += "StrongsHebrew";
			}
			else if (token[1] == 'G') {
			  buf += "StrongsGreek";
			}
			buf += "=on&verse=";
			for (i = 2; i < strlen(token); i++)
			  buf += token[i];
			buf += "\">";
			for (i = 2; i < strlen(token); i++)
			  buf += token[i];
			buf += "</a>&gt;</em></small>";
		}

		else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
			buf += " <small><em>&lt;<a href=\"!DIATHEKE_URL!";
			if (token[2] == 'H') {
			  buf += "StrongsHebrew";
			}
			else if (token[2] == 'G') {
			  buf += "StrongsGreek";
			}
			buf += "=on&verse=";
			for (i = 3; i < strlen(token); i++)
			  buf += token[i];
			buf += "\">";
			for (i = 3; i < strlen(token); i++)
			  buf += token[i];
			buf += "</a>&gt;</em></small>";
		}

		else if (!strncmp(token, "WT", 2)) { // morph tags
			buf += " <small><em>(<a href=\"!DIATHEKE_URL!Packard=on&verse=";
			for (i = 1; i < strlen(token); i++)
			  buf += token[i];
			buf += "\">";
			for (i = 1; i < strlen(token); i++)
			  buf += token[i];		
			buf += "</a>)</em></small>";
		}

		else if (!strncmp(token, "RB", 2)) {
			buf += "<i>";
			userData["hasFootnotePreTag"] = "true";
		}

		else if (!strncmp(token, "RF", 2)) {
			if(userData["hasFootnotePreTag"] == "true") {
				userData["hasFootnotePreTag"] = "false";
				buf += "</i> ";
			}
			buf += "<font color=\"#800000\"><small> (";
		}

		else if (!strncmp(token, "FN", 2)) {
			buf += "<font face=\"";
			for (i = 2; i < strlen(token); i++)		       
			  buf += token[i];
			buf += "\">";
		}

		else if (!strncmp(token, "CA", 2)) {	// ASCII value
			buf += (char)atoi(&token[2]);
		}
		
		else {
			return false;
		}
	}
	return true;
}
示例#8
0
bool OSISWEBIF::handleToken(std::string &buf, const char *token, BasicFilterUserData *userData) {
    MyUserData *u = (MyUserData *)userData;
    std::string scratch;
    bool sub = (u->suspendTextPassThru) ? substituteToken(scratch, token) : substituteToken(buf, token);
    if (!sub) {

        // manually process if it wasn't a simple substitution
        XMLTag tag(token);

        // <w> tag
        if (!strcmp(tag.getName(), "w")) {

            // start <w> tag
            if ((!tag.isEmpty()) && (!tag.isEndTag())) {
                u->w = token;
            }

            // end or empty <w> tag
            else {
                bool endTag = tag.isEndTag();
                std::string lastText;
                bool show = true;    // to handle unplaced article in kjv2003-- temporary till combined

                if (endTag) {
                    tag = u->w.c_str();
                    lastText = u->lastTextNode.c_str();
                }
                else lastText = "stuff";

                std::string attrib;
                const char *val;
                if (!(attrib = tag.getAttribute("xlit")).empty()) {
                    val = strchr(attrib.c_str(), ':');
                    val = (val) ? (val + 1) : attrib.c_str();
//                    buf += formatted(" %s", val);
                }
                if (!(attrib = tag.getAttribute("gloss")).empty()) {
                    val = strchr(attrib.c_str(), ':');
                    val = (val) ? (val + 1) : attrib.c_str();
//                    buf += formatted(" %s", val);
                }
                if (!(attrib = tag.getAttribute("lemma")).empty()) {
                    int count = tag.getAttributePartCount("lemma", ' ');
                    int i = (count > 1) ? 0 : -1;        // -1 for whole value cuz it's faster, but does the same thing as 0
                    do {
                        attrib = tag.getAttribute("lemma", i, ' ');
                        if (i < 0) i = 0;    // to handle our -1 condition
                        val = strchr(attrib.c_str(), ':');
                        val = (val) ? (val + 1) : attrib.c_str();
                        const char *val2 = val;
                        if ((strchr("GH", *val)) && (isdigit(val[1])))
                            val2++;
                        if ((!strcmp(val2, "3588")) && (lastText.length() < 1))
                            show = false;
                        else
                            buf += formatted(" <small><em>&lt;<a href=\"%s?showStrong=%s#cv\">%s</a>&gt;</em></small> ", passageStudyURL.c_str(), URL::encode(val2).c_str(), val2);
                    } while (++i < count);
                }
                if (!(attrib = tag.getAttribute("morph")).empty() && (show)) {
                    std::string savelemma = tag.getAttribute("savlm");
                    if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
                        show = false;
                    if (show) {
                        int count = tag.getAttributePartCount("morph", ' ');
                        int i = (count > 1) ? 0 : -1;        // -1 for whole value cuz it's faster, but does the same thing as 0
                        do {
                            attrib = tag.getAttribute("morph", i, ' ');
                            if (i < 0) i = 0;    // to handle our -1 condition
                            val = strchr(attrib.c_str(), ':');
                            val = (val) ? (val + 1) : attrib.c_str();
                            const char *val2 = val;
                            if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
                                val2+=2;
                            buf += formatted(" <small><em>(<a href=\"%s?showMorph=%s#cv\">%s</a>)</em></small> ", passageStudyURL.c_str(), URL::encode(val2).c_str(), val2);
                        } while (++i < count);
                    }
                }
                if (!(attrib = tag.getAttribute("POS")).empty()) {
                    val = strchr(attrib.c_str(), ':');
                    val = (val) ? (val + 1) : attrib.c_str();
                    buf += formatted(" %s", val);
                }

                /*if (endTag)
                    buf += "}";*/
            }
        }

        // <note> tag
        else if (!strcmp(tag.getName(), "note")) {
            if (!tag.isEndTag()) {
                                std::string type = tag.getAttribute("type");
                                bool strongsMarkup = (type == "x-strongsMarkup" || type == "strongsMarkup");    // the latter is deprecated
                                if (strongsMarkup) {
                                        tag.setEmpty(false);    // handle bug in KJV2003 module where some note open tags were <note ... />
                                }

                if (!tag.isEmpty()) {
                    if (!strongsMarkup) {    // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
                        std::string footnoteNumber = tag.getAttribute("swordFootnote");
                        std::string modName = (u->module) ? u->module->getName() : "";
                        if (dynamic_cast<VerseKey const *>(u->key)) {
                            char ch = ((!tag.getAttribute("type").empty() && ((!strcmp(tag.getAttribute("type").c_str(), "crossReference")) || (!strcmp(tag.getAttribute("type").c_str(), "x-cross-ref")))) ? 'x':'n');
//                            buf += formatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), ch, footnoteNumber.c_str(), ch);
                            buf += formatted("<span class=\"fn\" onclick=\"f(\'%s\',\'%s\',\'%s\');\" >%c</span>", modName.c_str(), u->key->getText(), footnoteNumber.c_str(), ch);
                        }
                    }
                    u->suspendTextPassThru = (++u->suspendLevel);
                }
            }
            if (tag.isEndTag()) {
                u->suspendTextPassThru = (--u->suspendLevel);

            }
        }


        // handled appropriately in base class
        else {
            return OSISXHTML::handleToken(buf, token, userData);
        }
    }
    return true;
}
bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
	// manually process if it wasn't a simple substitution

	if (!substituteToken(buf, token)) {
		BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
		sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack

		sword::XMLTag tag(token);
		//     qWarning("found %s", token);
		const bool osisQToTick = ((!userData->module->getConfigEntry("OSISqToTick")) || (strcmp(userData->module->getConfigEntry("OSISqToTick"), "false")));

		if (!tag.getName()) {
			return false;
		}

		// <div> tag
		if (!strcmp(tag.getName(), "div")) {
			//handle intro

			if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
				sword::SWBuf type( tag.getAttribute("type") );

				if (type == "introduction") {
					buf.append("<div class=\"introduction\">");
				}
				else if (type == "chapter") {
					buf.append("<div class=\"chapter\" />"); //don't open a div here, that would lead to a broken XML structure
				}
				else {
					buf.append("<div>");
				}
			}
			else if (tag.isEndTag()) { //end tag
				buf.append("</div>");
			}
		}
		else if (!strcmp(tag.getName(), "w")) {
			if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
				const char *attrib;
				const char *val;

				sword::XMLTag outTag("span");
				sword::SWBuf attrValue;

				if ((attrib = tag.getAttribute("xlit"))) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					outTag.setAttribute("xlit", val);
				}

				if ((attrib = tag.getAttribute("gloss"))) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					outTag.setAttribute("gloss", val);
				}

				if ((attrib = tag.getAttribute("lemma"))) {
 					char splitChar = '|';
					const int countSplit1 = tag.getAttributePartCount("lemma", '|');
					const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
					int count = 0;
					
					if (countSplit1 > countSplit2) { //| split char
						splitChar = '|'; //TODO: not allowed, remove soon
						count = countSplit1;
					}
					else {
						splitChar = ' ';
						count = countSplit2;
					}
					
					int i = (count > 1) ? 0 : -1;  // -1 for whole value cuz it's faster, but does the same thing as 0
					attrValue = "";

					do {
						if (attrValue.length()) {
							attrValue.append( '|' );
						}

						attrib = tag.getAttribute("lemma", i, splitChar);

						if (i < 0) { // to handle our -1 condition
							i = 0;
						}

						val = strchr(attrib, ':');
						val = (val) ? (val + 1) : attrib;

						attrValue.append(val);
					}
					while (++i < count);

					if (attrValue.length()) {
						outTag.setAttribute("lemma", attrValue.c_str());
					}
				}

				if ((attrib = tag.getAttribute("morph"))) {
					char splitChar = '|';
					const int countSplit1 = tag.getAttributePartCount("morph", '|');
					const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
					int count = 0;
					
					if (countSplit1 > countSplit2) { //| split char
						splitChar = '|';
						count = countSplit1;
					}
					else {
						splitChar = ' ';
						count = countSplit2;
					}

					int i = (count > 1) ? 0 : -1;  // -1 for whole value cuz it's faster, but does the same thing as 0

					attrValue = "";

					do {
						if (attrValue.length()) {
							attrValue.append('|');
						}

						attrib = tag.getAttribute("morph", i, splitChar);

						if (i < 0) {
							i = 0; // to handle our -1 condition
						}

						val = strchr(attrib, ':');

						if (val) { //the prefix gives the modulename
							//check the prefix
							if (!strncmp("robinson:", attrib, 9)) { //robinson
								attrValue.append( "Robinson:" ); //work is not the same as Sword's module name
								attrValue.append( val+1 );
							}
							//strongs is handled by BibleTime
							/*else if (!strncmp("strongs", attrib, val-atrrib)) {
								attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
							}*/
							else {
								attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
							}
						}
						else { //no prefix given
							val = attrib;
							const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'H')));
							attrValue.append( skipFirst ? val+1 : val );
						}
					}
					while (++i < count);

					if (attrValue.length()) {
						outTag.setAttribute("morph", attrValue.c_str());
					}
				}

				if ((attrib = tag.getAttribute("POS"))) {
					val = strchr(attrib, ':');
					val = (val) ? (val + 1) : attrib;
					outTag.setAttribute("pos", val);
				}

				buf.append( outTag.toString() );
			}
			else if (tag.isEndTag()) { // end or empty <w> tag
				buf.append("</span>");
			}
		}

		// <note> tag
		else if (!strcmp(tag.getName(), "note")) {
			if (!tag.isEndTag()) { //start tag
				const sword::SWBuf type( tag.getAttribute("type") );

				if (type == "crossReference") { //note containing cross references
					myUserData->inCrossrefNote = true;
					myUserData->noteType = BT_UserData::CrossReference;
					myUserData->swordFootnote++; // cross refs count as notes, too

					/*     //get the refList value of the right entry attribute
					     AttributeList notes = myModule->getEntryAttributes()["Footnote"];
					     bool foundNote = false;

					     SWBuf id( tag.getAttribute("osisID") );
					     SWBuf refList;

					     for (AttributeList::iterator list_it = notes.begin(); (list_it != notes.end()) && !foundNote; ++list_it ) {
					      for (AttributeValue::iterator val_it = list_it->second.begin(); (val_it != list_it->second.end()) && !foundNote; ++val_it ) {
					       if ((val_it->first == "osisID") && (val_it->second == id)) {
					        foundNote = true; //this break the loop
					        refList = list_it->second["refList"];
					       }
					      }
					     }

					     if (refList.length()) {
					      buf.append(" <span class=\"crossreference\" crossrefs=\"");
					      buf.append(refList.c_str());
					      buf.append("\"> ");

					           myUserData->noteType = BT_UserData::CrossReference;
					     }
					     else {
					      myUserData->noteType = BT_UserData::Unknown;
					     }*/

					buf.append("<span class=\"crossreference\">");
#ifdef SWORD_SIMPLERENDER
					sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
					sword::SWBuf footnoteBody = myModule->getEntryAttributes()["Footnote"][footnoteNumber]["body"];
					buf += myModule->RenderText(footnoteBody);
#endif
				}

				/* else if (type == "explanation") {
				     }
				     */
				else if ((type == "strongsMarkup") || (type == "x-strongsMarkup")) {
					/**
					* leave strong's markup notes out, in the future we'll probably have
					* different option filters to turn different note types on or off
					*/

					myUserData->suspendTextPassThru = true;
					myUserData->noteType = BT_UserData::StrongsMarkup;
				}

				else {
					//           qWarning("found note in %s", myUserData->key->getShortText());
					buf.append(" <span class=\"footnote\" note=\"");
					buf.append(myModule->Name());
					buf.append('/');
					buf.append(myUserData->key->getShortText());
					buf.append('/');
					buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() ); //inefficient

					const sword::SWBuf n = tag.getAttribute("n");
					
					buf.append("\">");
					buf.append( (n.length() > 0) ? n.c_str() : "*" );
					buf.append("</span> ");

					myUserData->noteType = BT_UserData::Footnote;
					myUserData->suspendTextPassThru = true;
				}
			}
			else { //if (tag.isEndTag()) {
				Q_ASSERT(myUserData->noteType != BT_UserData::Unknown);

				if (myUserData->noteType == BT_UserData::CrossReference) {
					buf.append("</span> ");
// 					myUserData->suspendTextPassThru = false;
					myUserData->inCrossrefNote = false;
				}

				myUserData->noteType = BT_UserData::Unknown;
				myUserData->suspendTextPassThru = false;
			}
		}
		// The <p> paragraph tag is handled by OSISHTMLHref
		else if (!strcmp(tag.getName(), "reference")) { // <reference> tag
			if (!tag.isEndTag() && !tag.isEmpty()) {

				renderReference(tag.getAttribute("osisRef"), buf, myModule, myUserData);

			}
			else if (tag.isEndTag()) {
				buf.append("</a>");
			}
			else { // empty reference marker
				// -- what should we do?  nothing for now.
			}
		}

		// <l> is handled by OSISHTMLHref
		// <title>
		else if (!strcmp(tag.getName(), "title")) {
			if (!tag.isEndTag() && !tag.isEmpty()) {
				buf.append("<div class=\"sectiontitle\">");
			}
			else if (tag.isEndTag()) {
				buf.append("</div>");
			}
			else { // empty title marker
				// what to do?  is this even valid?
				buf.append("<br/>");
			}
		}

		// <hi> highlighted text
		else if (!strcmp(tag.getName(), "hi")) {
			const sword::SWBuf type = tag.getAttribute("type");

			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				if (type == "bold") {
					buf.append("<span class=\"bold\">");
				}
				else if (type == "illuminated") {
					buf.append("<span class=\"illuminated\">");
				}
				else if (type == "italic") {
					buf.append("<span class=\"italic\">");
				}
				else if (type == "line-through") {
					buf.append("<span class=\"line-through\">");
				}
				else if (type == "normal") {
					buf.append("<span class=\"normal\">");
				}
				else if (type == "small-caps") {
					buf.append("<span class=\"small-caps\">");
				}
				else if (type == "underline") {
					buf.append("<span class=\"underline\">");
				}
				else {
					buf.append("<span>"); //don't break markup, </span> is inserted later
				}
			}
			else if (tag.isEndTag()) { //all hi replacements are html spans
				buf.append("</span>");
			}
		}

		//name
		else if (!strcmp(tag.getName(), "name")) {
			const sword::SWBuf type = tag.getAttribute("type");

			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				if (type == "geographic") {
					buf.append("<span class=\"name\"><span class=\"geographic\">");
				}
				else if (type == "holiday") {
					buf.append("<span class=\"name\"><span class=\"holiday\">");
				}
				else if (type == "nonhuman") {
					buf.append("<span class=\"name\"><span class=\"nonhuman\">");
				}
				else if (type == "person") {
					buf.append("<span class=\"name\"><span class=\"person\">");
				}
				else if (type == "ritual") {
					buf.append("<span class=\"name\"><span class=\"ritual\">");
				}
				else {
					buf.append("<span class=\"name\"><span>");
				}
			}
			else if (tag.isEndTag()) { //all hi replacements are html spans
				buf.append("</span></span> ");
			}
		}
		else if (!strcmp(tag.getName(), "transChange")) {
			sword::SWBuf type( tag.getAttribute("type") );

			if ( !type.length() ) {
				type = tag.getAttribute("changeType");
			}

			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				if (type == "added") {
					buf.append("<span class=\"transchange\" title=\"");
					buf.append(QObject::tr("Added text").toUtf8().constData());
					buf.append("\"><span class=\"added\">");
				}
				else if (type == "amplified") {
					buf.append("<span class=\"transchange\"><span class=\"amplified\">");
				}
				else if (type == "changed") {
					buf.append("<span class=\"transchange\"><span class=\"changed\">");
				}
				else if (type == "deleted") {
					buf.append("<span class=\"transchange\"><span class=\"deleted\">");
				}
				else if (type == "moved") {
					buf.append("<span class=\"transchange\"><span class=\"moved\">");
				}
				else if (type == "tenseChange") {
					buf.append("<span class=\"transchange\" title=\"");
					buf.append(QObject::tr("Verb tense changed").toUtf8().constData());
					buf.append("\"><span class=\"tenseChange\">");
				}
				else {
					buf.append("<span class=\"transchange\"><span>");
				}
			}
			else if (tag.isEndTag()) { //all hi replacements are html spans
				buf.append("</span></span>");
			}
		}
		else if (!strcmp(tag.getName(), "p")) {
			if (tag.isEmpty()) {
				buf.append("<p/>");
			}
		}

		// <q> quote
		else if (!strcmp(tag.getName(), "q")) {
			sword::SWBuf type = tag.getAttribute("type");
			sword::SWBuf who = tag.getAttribute("who");
			const char *lev = tag.getAttribute("level");
			int level = (lev) ? atoi(lev) : 1;
			const char* quoteMarker = tag.getAttribute("marker");

			if ((!tag.isEndTag())) {
				myUserData->quote.who = who;
				if (quoteMarker) {
					buf.append(quoteMarker);
				}
				else if(osisQToTick) //alternate " and '
					buf.append((level % 2) ? '\"' : '\'');

				if (who == "Jesus") {
					buf.append("<span class=\"jesuswords\">");
				}
			}
			else if (tag.isEndTag()) {
				if (myUserData->quote.who == "Jesus") {
					buf.append("</span>");
				}
				if (quoteMarker) {
					buf.append(quoteMarker);
				}
				else if (osisQToTick) { //alternate " and '
					buf.append((level % 2) ? '\"' : '\'');
				}

				myUserData->quote.who = "";
			}
		}

		// abbr tag
		else if (!strcmp(tag.getName(), "abbr")) {
			if (!tag.isEndTag() && !tag.isEmpty()) {
				const sword::SWBuf expansion = tag.getAttribute("expansion");

				buf.append("<span class=\"abbreviation\" expansion=\"");
				buf.append(expansion);
				buf.append("\">");
			}
			else if (tag.isEndTag()) {
				buf.append("</span>");
			}
		}

		// <milestone> tag
		else if (!strcmp(tag.getName(), "milestone")) {
			const sword::SWBuf type = tag.getAttribute("type");

			if ((type == "screen") || (type == "line")) {//line break
				buf.append("<br/>");
				userData->supressAdjacentWhitespace = true;
			}
			else if (type == "x-p") { //e.g. occurs in the KJV2006 module
				//buf.append("<br/>");
				const sword::SWBuf marker = tag.getAttribute("marker");
				if (marker.length() > 0) {
					buf.append(marker);
				}
			}
		}
		//seg tag
		else if (!strcmp(tag.getName(), "seg")) {
			if (!tag.isEndTag() && !tag.isEmpty()) {

				const sword::SWBuf type = tag.getAttribute("type");

				if (type == "morph") {//line break
					//This code is for WLC and MORPH (WHI)
					sword::XMLTag outTag("span");
					outTag.setAttribute("class", "morphSegmentation");
					const char* attrValue;
					//Transfer the values to the span
					//Problem: the data is in hebrew/aramaic, how to encode in HTML/BibleTime?
					if ((attrValue = tag.getAttribute("lemma"))) outTag.setAttribute("lemma", attrValue);
					if ((attrValue = tag.getAttribute("morph"))) outTag.setAttribute("morph", attrValue);
					if ((attrValue = tag.getAttribute("homonym"))) outTag.setAttribute("homonym", attrValue);

					buf.append(outTag.toString());
					//buf.append("<span class=\"morphSegmentation\">");
				}
				else{
					buf.append("<span>");
				}
			}
			else { // seg end tag
				buf.append("</span>");
			}
			//qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1());
		}
		
		//divine name, don't use simple tag replacing because it may have attributes
		else if (!strcmp(tag.getName(), "divineName")) {
			if (!tag.isEndTag()) {
				buf.append("<span class=\"name\"><span class=\"divine\">");
			}
			else { //all hi replacements are html spans
				buf.append("</span></span>");
			}
		}
		
		else { //all tokens handled by OSISHTMLHref will run through the filter now
			return sword::OSISHTMLHREF::handleToken(buf, token, userData);
		}
	}

	return false;
}
示例#10
0
bool OSISXHTMLXS::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
	MyUserDataXS *u = (MyUserDataXS *)userData;
	SWBuf scratch;
	bool sub = (u->suspendTextPassThru) ? substituteToken(scratch, token) : substituteToken(buf, token);
	if (!sub) {
  // manually process if it wasn't a simple substitution
		XMLTag tag(token);
		
		// <w> tag
    if (!strcmp(tag.getName(), "w")) {
		  VerseKey *vkey;
			// see if we have a VerseKey * or descendant
			SWTRY {
        vkey = SWDYNAMIC_CAST(VerseKey, u->key);
      }
      SWCATCH ( ... ) {	}
      if (vkey) {
			 // start <w> tag
        if (!tag.isEndTag()) {
          u->w = "skip";
          SWBuf snumbers;
          const char *attrib;
          const char *val;
          bool sep = false;
          if (attrib = tag.getAttribute("lemma")) {
            int count = tag.getAttributePartCount("lemma", ' ');
            int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
            do {
              attrib = tag.getAttribute("lemma", i, ' ');
              if (i < 0) i = 0;	// to handle our -1 condition
              val = strchr(attrib, ':');
              val = (val) ? (val + 1) : attrib;
              if (sep) {snumbers += ".";}
              snumbers += "S";
              snumbers += "_";
							if (!strncmp(attrib, "DSS", 3)) {
								snumbers += "DSS_";
							}
							else if (!strncmp(attrib, "MT", 2)) {
								snumbers += "MT_";
							}
						  snumbers += val;
						  sep = true;
            } while (++i < count);
          }
          if (attrib = tag.getAttribute("morph")) {
            int count = tag.getAttributePartCount("morph", ' ');
            int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
            do {
              attrib = tag.getAttribute("morph", i, ' ');
              if (i < 0) i = 0;	// to handle our -1 condition
              val = strchr(attrib, ':');
              val = (val) ? (val + 1) : attrib;
              if (*val > 0 && *val < 127) { // some mods (like SP) have Hebrew Unicode chars as morph attribute- so skip them
								if (sep) {snumbers += ".";}
								if (!strncmp(attrib, "robinson", 8)) {snumbers += "RM";}
								else {snumbers += "SM";}
								snumbers += "_";
								snumbers += val;
								sep = true;
							}
            } while (++i < count);
          }
          snumbers.replaceBytes(".", ' '); // Changed in xulsword 3+
          if (!tag.isEmpty() && (tag.getAttribute("lemma") || tag.getAttribute("morph"))) {
						SWBuf tmp;
						tmp.appendFormatted("<span class=\"sn %s\">", snumbers.c_str());
            outHtmlTag(tmp, buf, u);
						u->w = "keep";
					}
        }
        // end <w> tag
        else if (u->w == "keep") {outHtmlTag("</span>", buf, u);}
      }
    }
示例#11
0
bool ThMLXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
	if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
		MyUserData *u = (MyUserData *)userData;		

		XMLTag tag(token);
		if ((!tag.isEndTag()) && (!tag.isEmpty()))
			u->startTag = tag;

		if (tag.getName() && !strcmp(tag.getName(), "sync")) {
			SWBuf value = tag.getAttribute("value");
			if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt;
				if(value.length())
					buf.appendFormatted("<small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=Greek&value=%s\" class=\"morph\">%s</a>)</em></small>", 
						URL::encode(value.c_str()).c_str(),
						value.c_str());
			}
			else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "lemma")) { //&gt;
				if(value.length())
					// empty "type=" is deliberate.
					buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=&value=%s\" class=\"strongs\">%s</a>&gt;</em></small>", 
						URL::encode(value.c_str()).c_str(),
						value.c_str());
			}
			else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) {
				char ch = *value;
				value<<1;
				buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\" class=\"strongs\">",
						    ((ch == 'H') ? "Hebrew" : "Greek"),
						    URL::encode(value.c_str()).c_str());
				buf += (value.length()) ? value.c_str() : "";
				buf += "</a>&gt;</em></small>";
			}
			else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) {
				buf += (tag.isEndTag() ? "</b>" : "<b>");
			}
				
		}
		// <note> tag
		else if (!strcmp(tag.getName(), "note")) {
			if (!tag.isEndTag()) {
				if (!tag.isEmpty()) {
					SWBuf type = tag.getAttribute("type");
					SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
					SWBuf noteName = tag.getAttribute("n");
					VerseKey *vkey = NULL;
					// see if we have a VerseKey * or descendant
					SWTRY {
						vkey = SWDYNAMIC_CAST(VerseKey, u->key);
					}
					SWCATCH ( ... ) {	}
					if (vkey) {
						// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
						char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
						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>", 
							ch, 
							URL::encode(footnoteNumber.c_str()).c_str(), 
							URL::encode(u->version.c_str()).c_str(), 
							URL::encode(vkey->getText()).c_str(), 
							ch,
							ch, 
							(renderNoteNumbers ? noteName.c_str() : ""));
					}
					else {
						char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
						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>", 
							ch, 
							URL::encode(footnoteNumber.c_str()).c_str(), 
							URL::encode(u->version.c_str()).c_str(), 
							URL::encode(u->key->getText()).c_str(),  
							ch,
							ch, 
							(renderNoteNumbers ? noteName.c_str() : ""));
					}
					u->suspendTextPassThru = true;
				}
			}
			if (tag.isEndTag()) {
				u->suspendTextPassThru = false;
			}
		}
示例#12
0
文件: mce.c 项目: a2k2/xen-unstable
void x86_mce_callback_register(x86_mce_callback_t cbfunc)
{
	mc_callback_bank_extended = cbfunc;
}

/* Machine check recoverable judgement callback handler 
 * It is used to judge whether an UC error is recoverable by software
 */
static mce_recoverable_t mc_recoverable_scan = NULL;

void mce_recoverable_register(mce_recoverable_t cbfunc)
{
    mc_recoverable_scan = cbfunc;
}

/* Judging whether to Clear Machine Check error bank callback handler
 * According to Intel latest MCA OS Recovery Writer's Guide, 
 * whether the error MCA bank needs to be cleared is decided by the mca_source
 * and MCi_status bit value. 
 */
static mce_need_clearbank_t mc_need_clearbank_scan = NULL;

void mce_need_clearbank_register(mce_need_clearbank_t cbfunc)
{
    mc_need_clearbank_scan = cbfunc;
}

/* Utility function to perform MCA bank telemetry readout and to push that
 * telemetry towards an interested dom0 for logging and diagnosis.
 * The caller - #MC handler or MCA poll function - must arrange that we
 * do not migrate cpus. */

/* XXFM Could add overflow counting? */

/* Add out_param clear_bank for Machine Check Handler Caller.
 * For Intel latest CPU, whether to clear the error bank status needs to
 * be judged by the callback function defined above.
 */
mctelem_cookie_t mcheck_mca_logout(enum mca_source who, cpu_banks_t bankmask,
    struct mca_summary *sp, cpu_banks_t* clear_bank)
{
	struct vcpu *v = current;
	struct domain *d;
	uint64_t gstatus, status, addr, misc;
	struct mcinfo_global mcg;	/* on stack */
	struct mcinfo_common *mic;
	struct mcinfo_global *mig;	/* on stack */
	mctelem_cookie_t mctc = NULL;
	uint32_t uc = 0, pcc = 0, recover, need_clear = 1 ;
	struct mc_info *mci = NULL;
	mctelem_class_t which = MC_URGENT;	/* XXXgcc */
	unsigned int cpu_nr;
	int errcnt = 0;
	int i;
	enum mca_extinfo cbret = MCA_EXTINFO_IGNORED;

	cpu_nr = smp_processor_id();
	BUG_ON(cpu_nr != v->processor);

	mca_rdmsrl(MSR_IA32_MCG_STATUS, gstatus);

	memset(&mcg, 0, sizeof (mcg));
	mcg.common.type = MC_TYPE_GLOBAL;
	mcg.common.size = sizeof (mcg);
	if (v != NULL && ((d = v->domain) != NULL)) {
		mcg.mc_domid = d->domain_id;
		mcg.mc_vcpuid = v->vcpu_id;
	} else {
		mcg.mc_domid = -1;
		mcg.mc_vcpuid = -1;
	}
	mcg.mc_gstatus = gstatus;	/* MCG_STATUS */

	switch (who) {
	case MCA_MCE_HANDLER:
	case MCA_MCE_SCAN:
		mcg.mc_flags = MC_FLAG_MCE;
		which = MC_URGENT;
		break;

	case MCA_POLLER:
	case MCA_RESET:
		mcg.mc_flags = MC_FLAG_POLLED;
		which = MC_NONURGENT;
		break;

	case MCA_CMCI_HANDLER:
		mcg.mc_flags = MC_FLAG_CMCI;
		which = MC_NONURGENT;
		break;

	default:
		BUG();
	}

	/* Retrieve detector information */
	x86_mc_get_cpu_info(cpu_nr, &mcg.mc_socketid,
	    &mcg.mc_coreid, &mcg.mc_core_threadid,
	    &mcg.mc_apicid, NULL, NULL, NULL);

	/* If no mc_recovery_scan callback handler registered,
	 * this error is not recoverable
	 */
	recover = (mc_recoverable_scan)? 1: 0;

	for (i = 0; i < 32 && i < nr_mce_banks; i++) {
		struct mcinfo_bank mcb;		/* on stack */

		/* Skip bank if corresponding bit in bankmask is clear */
		if (!test_bit(i, bankmask))
			continue;

		mca_rdmsrl(MSR_IA32_MC0_STATUS + i * 4, status);
		if (!(status & MCi_STATUS_VAL))
			continue;	/* this bank has no valid telemetry */

		/* For Intel Latest CPU CMCI/MCE Handler caller, we need to
		 * decide whether to clear bank by MCi_STATUS bit value such as
		 * OVER/UC/EN/PCC/S/AR
		 */
		if ( mc_need_clearbank_scan )
			need_clear = mc_need_clearbank_scan(who, status);

		/* If this is the first bank with valid MCA DATA, then
		 * try to reserve an entry from the urgent/nonurgent queue
		 * depending on whethere we are called from an exception or
		 * a poller;  this can fail (for example dom0 may not
		 * yet have consumed past telemetry). */
		if (errcnt == 0) {
			if ((mctc = mctelem_reserve(which)) != NULL) {
				mci = mctelem_dataptr(mctc);
				mcinfo_clear(mci);
			}
		}

		memset(&mcb, 0, sizeof (mcb));
		mcb.common.type = MC_TYPE_BANK;
		mcb.common.size = sizeof (mcb);
		mcb.mc_bank = i;
		mcb.mc_status = status;

		/* form a mask of which banks have logged uncorrected errors */
		if ((status & MCi_STATUS_UC) != 0)
			uc |= (1 << i);

		/* likewise for those with processor context corrupt */
		if ((status & MCi_STATUS_PCC) != 0)
			pcc |= (1 << i);

		if (recover && uc)
		 /* uc = 1, recover = 1, we need not panic.
		  */
			recover = mc_recoverable_scan(status);

		addr = misc = 0;

		if (status & MCi_STATUS_ADDRV) {
			mca_rdmsrl(MSR_IA32_MC0_ADDR + 4 * i, addr);
			d = maddr_get_owner(addr);
			if (d != NULL && (who == MCA_POLLER ||
			    who == MCA_CMCI_HANDLER))
				mcb.mc_domid = d->domain_id;
		}

		if (status & MCi_STATUS_MISCV)
			mca_rdmsrl(MSR_IA32_MC0_MISC + 4 * i, misc);

		mcb.mc_addr = addr;
		mcb.mc_misc = misc;

		if (who == MCA_CMCI_HANDLER) {
			mca_rdmsrl(MSR_IA32_MC0_CTL2 + i, mcb.mc_ctrl2);
			rdtscll(mcb.mc_tsc);
		}

		/* Increment the error count;  if this is the first bank
		 * with a valid error then add the global info to the mcinfo. */
		if (errcnt++ == 0 && mci != NULL)
			x86_mcinfo_add(mci, &mcg);

		/* Add the bank data */
		if (mci != NULL)
			x86_mcinfo_add(mci, &mcb);

		if (mc_callback_bank_extended && cbret != MCA_EXTINFO_GLOBAL) {
			cbret = mc_callback_bank_extended(mci, i, status);
示例#13
0
bool SWBasicFilter::handleToken(std::string &buf, const char *token, BasicFilterUserData *userData) {
    return substituteToken(buf, token);
}
bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
	if (!substituteToken(buf, token) && !substituteEscapeString(buf, token)) {
		sword::XMLTag tag(token);
		BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
		sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()

		if ( tag.getName() && !sword::stricmp(tag.getName(), "foreign") ) { // a text part in another language, we have to set the right font

			if (tag.getAttribute("lang")) {
				const char* abbrev = tag.getAttribute("lang");
				//const CLanguageMgr::Language* const language = CPointers::languageMgr()->languageForAbbrev( QString::fromLatin1(abbrev) );

				buf.append("<span class=\"foreign\" lang=\"");
				buf.append(abbrev);
				buf.append("\">");
			}
		}
		else if (tag.getName() && !sword::stricmp(tag.getName(), "sync")) { //lemmas, morph codes or strongs

			if (tag.getAttribute("type") && (!sword::stricmp(tag.getAttribute("type"), "morph") || !sword::stricmp(tag.getAttribute("type"), "Strongs") || !sword::stricmp(tag.getAttribute("type"), "lemma"))) { // Morph or Strong
				buf.append('<');
				buf.append(token);
				buf.append('>');
			}
		}
		else if (tag.getName() && !sword::stricmp(tag.getName(), "note")) { // <note> tag

			if (!tag.isEndTag() && !tag.isEmpty()) {
				//appending is faster than appendFormatted
				buf.append(" <span class=\"footnote\" note=\"");
				buf.append(myModule->Name());
				buf.append('/');
				buf.append(myUserData->key->getShortText());
				buf.append('/');
				buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
				buf.append("\">*</span> ");

				myUserData->suspendTextPassThru = true;
				myUserData->inFootnoteTag = true;
			}
			else if (tag.isEndTag() && !tag.isEmpty()) { //end tag
				//buf += ")</span>";
				myUserData->suspendTextPassThru = false;
				myUserData->inFootnoteTag = false;
			}
		}
		else if (tag.getName() && !sword::stricmp(tag.getName(), "scripRef")) { // a scripRef
			//scrip refs which are embeded in footnotes may not be displayed!

			if (!myUserData->inFootnoteTag) {
				if (tag.isEndTag()) {
					if (myUserData->inscriptRef) { // like "<scripRef passage="John 3:16">See John 3:16</scripRef>"
						buf.append("</a></span>");

						myUserData->inscriptRef = false;
						myUserData->suspendTextPassThru = false;
					}
					else { // like "<scripRef>John 3:16</scripRef>"

						CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
						//Q_ASSERT(mod); tested later
						if (mod) {
							CReferenceManager::ParseOptions options;
							options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
							options.refDestinationModule = QString(mod->name());
							options.sourceLanguage = QString(myModule->Lang());
 							options.destinationLanguage = QString("en");

							//it's ok to split the reference, because to descriptive text is given
							bool insertSemicolon = false;
							buf.append("<span class=\"crossreference\">");
							QStringList refs = QString::fromUtf8(myUserData->lastTextNode.c_str()).split(";");
							QString oldRef; //the previous reference to use as a base for the next refs
							for (QStringList::iterator it(refs.begin()); it != refs.end(); ++it) {

								if (! oldRef.isEmpty() ){
									options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10
								}
								const QString completeRef( CReferenceManager::parseVerseReference((*it), options) );

								oldRef = completeRef; //use the parsed result as the base for the next ref.

 								if (insertSemicolon) { //prepend a ref divider if we're after the first one
									buf.append("; ");
 								}

								buf.append("<a href=\"");
								buf.append(
									CReferenceManager::encodeHyperlink(
										mod->name(),
										completeRef,
										CReferenceManager::typeFromModule(mod->type())
									).toUtf8().constData()
								);

								buf.append("\" crossrefs=\"");
								buf.append((const char*)completeRef.toUtf8());
								buf.append("\">");

								buf.append((const char*)(*it).toUtf8());

								buf.append("</a>");

								insertSemicolon = true;
							}
							buf.append("</span>"); //crossref end
						}

						myUserData->suspendTextPassThru = false;
					}
				}
				else if (tag.getAttribute("passage") ) { //the passage was given as a parameter value
					myUserData->inscriptRef = true;
					myUserData->suspendTextPassThru = false;

					const char* ref = tag.getAttribute("passage");
					Q_ASSERT(ref);

					CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
					//Q_ASSERT(mod); tested later

					CReferenceManager::ParseOptions options;
					options.refBase = QString::fromUtf8(myUserData->key->getText());
					options.refDestinationModule = QString(mod->name());
					options.sourceLanguage = myModule->Lang();
					options.destinationLanguage = QString("en");

					const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);

					if (mod) {
						buf.append("<span class=\"crossreference\">");
						buf.append("<a href=\"");
						buf.append(
 							CReferenceManager::encodeHyperlink(
 								mod->name(),
 								completeRef,
 								CReferenceManager::typeFromModule(mod->type())
							).toUtf8().constData()
						);
						buf.append("\" crossrefs=\"");
						buf.append((const char*)completeRef.toUtf8());
						buf.append("\">");
					}
					else {
						buf.append("<span><a>");
					}
				}
				else if ( !tag.getAttribute("passage") ) { // we're starting a scripRef like "<scripRef>John 3:16</scripRef>"
					myUserData->inscriptRef = false;

					// let's stop text from going to output, the text get's added in the -tag handler
					myUserData->suspendTextPassThru = true;
				}
			}
		}
		else if (tag.getName() && !sword::stricmp(tag.getName(), "div")) {
			if (tag.isEndTag()) {
				buf.append("</div>");
			}
			else if ( tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"),"sechead") ) {
				buf.append("<div class=\"sectiontitle\">");
			}
			else if (tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"), "title")) {
				buf.append("<div class=\"booktitle\">");
			}
		}
		else if (tag.getName() && !sword::stricmp(tag.getName(), "img") && tag.getAttribute("src")) {
			const char* value = tag.getAttribute("src");

			if (value[0] == '/') {
				value++; //strip the first /
			}

			buf.append("<img src=\"file:");
			buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath"));
			buf.append('/');
			buf.append(value);
			buf.append("\" />");
		}
		else { // let unknown token pass thru
			return sword::ThMLHTML::handleToken(buf, token, userData);
		}
	}

	return true;
}
示例#15
0
bool TEIPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
  // manually process if it wasn't a simple substitution
	if (!substituteToken(buf, token)) {
		//MyUserData *u = (MyUserData *)userData;
		XMLTag tag(token);

		// <p> paragraph tag
		if (!strcmp(tag.getName(), "p")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {	// non-empty start tag
				buf += "\n";
			}
			else if (tag.isEndTag()) {	// end tag
				buf += "\n";
				userData->supressAdjacentWhitespace = true;
			}
			else {					// empty paragraph break marker
				buf += "\n\n";
				userData->supressAdjacentWhitespace = true;
			}
		}

		// <entryFree>
		else if (!strcmp(tag.getName(), "entryFree")) {
			SWBuf n = tag.getAttribute("n");
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
			        if (n != "") {
					buf += n;
					buf += ". ";
				}
			}
		}

		// <sense>
		else if (!strcmp(tag.getName(), "sense")) {
			SWBuf n = tag.getAttribute("n");
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
			        if (n != "") {
					buf += n;
					buf += ". ";
				}
			}
			else if (tag.isEndTag()) {
			                buf += "\n";
			}
		}

		// <div>
		else if (!strcmp(tag.getName(), "div")) {

			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf.append("\n\n\n");
			}
			else if (tag.isEndTag()) {
			}
		}

		// <etym>
		else if (!strcmp(tag.getName(), "etym")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "[";
			}
			else if (tag.isEndTag()) {
			        buf += "]";
			}
		}

		else {
			return false;  // we still didn't handle token
		}
	}
	return true;
}
示例#16
0
bool TEIRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
  // manually process if it wasn't a simple substitution
	if (!substituteToken(buf, token)) {
		MyUserData *u = (MyUserData *)userData;
		XMLTag tag(token);

		// <p> paragraph tag
		if (!strcmp(tag.getName(), "p")) {
			if (!tag.isEndTag()) {	// non-empty start tag
				buf += "{\\sb100\\fi200\\par}";
			}
		}

		// <hi>
		else if (!strcmp(tag.getName(), "hi") || !strcmp(tag.getName(), "emph")) {
			SWBuf rend = tag.getAttribute("rend");
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				if (rend == "italic" || rend == "ital")
					buf += "{\\i1 ";
				else if (rend == "bold")
					buf += "{\\b1 ";
				else if (rend == "super" || rend == "sup")
				        buf += "{\\super ";
				else if (rend == "sub")
					buf += "{\\sub ";
			}
			else if (tag.isEndTag()) {
				buf += "}";
			}
		}

		// <entryFree>
		else if (!strcmp(tag.getName(), "entryFree")) {
			SWBuf n = tag.getAttribute("n");
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
			        if (n != "") {
                                	buf += "{\\b1 ";
					buf += n;
					buf += ". }";				}
			}
		}

		// <sense>
		else if (!strcmp(tag.getName(), "sense")) {
			SWBuf n = tag.getAttribute("n");
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
			        if (n != "") {
                                	buf += "{\\sb100\\par\\b1 ";
					buf += n;
					buf += ". }";
				}
			}
		}

 		// <orth>
 		else if (!strcmp(tag.getName(), "orth")) {
 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
 				buf += "{\\b1 ";
 			}
 			else if (tag.isEndTag()) {
 			        buf += "}";
 			}
 		}

		// <div>
		else if (!strcmp(tag.getName(), "div")) {

			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf.append("{\\pard\\sa300}");
			}
			else if (tag.isEndTag()) {
			}
		}

		// <pos>, <gen>, <case>, <gram>, <number>, <mood>
		else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || !strcmp(tag.getName(), "mood")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "{\\i1 ";
			}
			else if (tag.isEndTag()) {
			        buf += "}";
			}
		}

		// <tr>
		else if (!strcmp(tag.getName(), "tr")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "{\\i1 ";
			}
			else if (tag.isEndTag()) {
			        buf += "}";
			}
		}

		// <etym>
		else if (!strcmp(tag.getName(), "etym")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "[";
			}
			else if (tag.isEndTag()) {
			        buf += "]";
			}
		}

       		// <note> tag
		else if (!strcmp(tag.getName(), "note")) {
			if (!tag.isEndTag()) {
				if (!tag.isEmpty()) {
					SWBuf type = tag.getAttribute("type");

					SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
					VerseKey *vkey = 0;
					// see if we have a VerseKey * or descendant
					SWTRY {
						vkey = SWDYNAMIC_CAST(VerseKey, u->key);
					}
					SWCATCH ( ... ) {	}
					if (vkey) {
						buf.appendFormatted("{\\super <a href=\"\">*%s</a>} ", footnoteNumber.c_str());
					}
					u->suspendTextPassThru = true;
				}
			}
			if (tag.isEndTag()) {
				u->suspendTextPassThru = false;
			}
		}
示例#17
0
bool TEIHTMLHREF::handleToken(std::string &buf, const char *token, BasicFilterUserData *userData) {
  // manually process if it wasn't a simple substitution
    if (!substituteToken(buf, token)) {
        MyUserData *u = (MyUserData *)userData;
        XMLTag tag(token);

        if (!strcmp(tag.getName(), "p")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {    // non-empty start tag
                buf += "<!P><br />";
            }
            else if (tag.isEndTag()) {    // end tag
                buf += "<!/P><br />";
                //userData->supressAdjacentWhitespace = true;
            }
            else {                    // empty paragraph break marker
                buf += "<!P><br />";
                //userData->supressAdjacentWhitespace = true;
            }
        }

        // <hi>
        else if (!strcmp(tag.getName(), "hi")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                std::string rend = tag.getAttribute("rend");

                u->lastHi = rend;
                if (rend == "italic" || rend == "ital")
                    buf += "<i>";
                else if (rend == "bold")
                    buf += "<b>";
                else if (rend == "super" || rend == "sup")
                    buf += "<sup>";
                else if (rend == "sub")
                    buf += "<sub>";
                else if (rend == "overline")
                    buf += "<span style=\"text-decoration:overline\">";
            }
            else if (tag.isEndTag()) {
                std::string rend = u->lastHi;
                if (rend == "italic" || rend == "ital")
                    buf += "</i>";
                else if (rend == "bold")
                    buf += "</b>";
                else if (rend == "super" || rend == "sup")
                    buf += "</sup>";
                else if (rend == "sub")
                    buf += "</sub>";
                else if (rend == "overline")
                    buf += "</span>";
            }
        }

        // <entryFree>
        else if (!strcmp(tag.getName(), "entryFree")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                std::string n = tag.getAttribute("n");
                if (n != "") {
                    buf += "<b>";
                    buf += n;
                    buf += "</b>";
                }
            }
        }

        // <sense>
        else if (!strcmp(tag.getName(), "sense")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                std::string n = tag.getAttribute("n");
                if (n != "") {
                    buf += "<br /><b>";
                    buf += n;
                    buf += "</b>";
                }
            }
        }

        // <div>
        else if (!strcmp(tag.getName(), "div")) {

            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "<!P>";
            }
            else if (tag.isEndTag()) {
            }
        }

        // <lb.../>
        else if (!strcmp(tag.getName(), "lb")) {
            buf += "<br />";
        }

        // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def>
        else if (!strcmp(tag.getName(), "pos") ||
                 !strcmp(tag.getName(), "gen") ||
                 !strcmp(tag.getName(), "case") ||
                 !strcmp(tag.getName(), "gram") ||
                 !strcmp(tag.getName(), "number") ||
                 !strcmp(tag.getName(), "pron") /*||
                 !strcmp(tag.getName(), "def")*/) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "<i>";
            }
            else if (tag.isEndTag()) {
                buf += "</i>";
            }
        }

        // <tr>
        else if (!strcmp(tag.getName(), "tr")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "<i>";
            }
            else if (tag.isEndTag()) {
                buf += "</i>";
            }
        }

        // orth
        else if (!strcmp(tag.getName(), "orth")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "<b>";
            }
            else if (tag.isEndTag()) {
                buf += "</b>";
            }
        }

        // <etym>, <usg>
        else if (!strcmp(tag.getName(), "etym") ||
                 !strcmp(tag.getName(), "usg")) {
            // do nothing here
        }
        else if (!strcmp(tag.getName(), "ref")) {
            if (!tag.isEndTag()) {
                u->suspendTextPassThru = true;
                std::string target;
                std::string work;
                std::string ref;

                int was_osisref = false;
                if(!tag.getAttribute("osisRef").empty())
                {
                    target += tag.getAttribute("osisRef");
                    was_osisref=true;
                }
                else if(!tag.getAttribute("target").empty())
                    target += tag.getAttribute("target");

                if(target.size())
                {
                    const char* the_ref = std::strchr(target.c_str(), ':');

                    if(!the_ref) {
                        // No work
                        ref = target;
                    }
                    else {
                        // Compensate for starting :
                        ref = the_ref + 1;

                        int size = target.size() - ref.size() - 1;
                        work.resize(size, '\0');
                        std::strncpy(&work[0u], target.c_str(), size);
                    }

                    if(was_osisref)
                    {
                        buf += formatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
                            (!ref.empty()) ? URL::encode(ref.c_str()).c_str() : "",
                            (!work.empty()) ? URL::encode(work.c_str()).c_str() : "");
                    }
                    else
                    {
                        // Dictionary link, or something
                        buf += formatted("<a href=\"sword://%s/%s\">",
                            (!work.empty()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(),
                            (!ref.empty()) ? URL::encode(ref.c_str()).c_str() : ""
                            );
                    }
                }
                else
                {
                    //std::cout << "TARGET WASN'T\n";
                }

            }
            else {
                buf += u->lastTextNode.c_str();
                buf += "</a>";

                u->suspendTextPassThru = false;
            }
        }

           // <note> tag
        else if (!strcmp(tag.getName(), "note")) {
            if (!tag.isEndTag()) {
                if (!tag.isEmpty()) {
                    u->suspendTextPassThru = true;
                }
            }
            if (tag.isEndTag()) {
                std::string footnoteNumber = tag.getAttribute("swordFootnote");
                std::string noteName = tag.getAttribute("n");

                buf += formatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a>",
                    URL::encode(footnoteNumber.c_str()).c_str(),
                    URL::encode(u->version.c_str()).c_str(),
                    URL::encode(u->key->getText()).c_str(),
                    (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));

                u->suspendTextPassThru = false;
            }
        }
        // <graphic> image tag
        else if (!strcmp(tag.getName(), "graphic")) {
            auto url(tag.getAttribute("url"));
            if (!url.empty()) {        // assert we have a url attribute
                std::string filepath;
                if (userData->module) {
                    filepath = userData->module->getConfigEntry("AbsoluteDataPath");
                    if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (url[0] != '/'))
                        filepath += '/';
                }
                filepath += url;
                // images become clickable, if the UI supports showImage.
                buf += formatted("<a href=\"passagestudy.jsp?action=showImage&value=%s&module=%s\"><img src=\"file:%s\" border=\"0\" /></a>",
                            URL::encode(filepath.c_str()).c_str(),
                            URL::encode(u->version.c_str()).c_str(),
                            filepath.c_str());
                u->suspendTextPassThru = true;
            }
        }
        // <table> <row> <cell>
        else if (!strcmp(tag.getName(), "table")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "<table><tbody>\n";
            }
            else if (tag.isEndTag()) {
                buf += "</tbody></table>\n";
                u->supressAdjacentWhitespace = true;
            }

        }
        else if (!strcmp(tag.getName(), "row")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "\t<tr>";
            }
            else if (tag.isEndTag()) {
                buf += "</tr>\n";
            }
        }
        else if (!strcmp(tag.getName(), "cell")) {
            if ((!tag.isEndTag()) && (!tag.isEmpty())) {
                buf += "<td>";
            }
            else if (tag.isEndTag()) {
                buf += "</td>";
            }
        }

        else {
            return false;  // we still didn't handle token
        }

    }
    return true;
}
示例#18
0
bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
  // manually process if it wasn't a simple substitution
	if (!substituteToken(buf, token)) {
		MyUserData *u = (MyUserData *)userData;
		XMLTag tag(token);

		if (!strcmp(tag.getName(), "p")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {	// non-empty start tag
				buf += "<!P><br />";
			}
			else if (tag.isEndTag()) {	// end tag
				buf += "<!/P><br />";
				//userData->supressAdjacentWhitespace = true;
			}
			else {					// empty paragraph break marker
				buf += "<!P><br />";
				//userData->supressAdjacentWhitespace = true;
			}
		}
		
		// <hi>
		else if (!strcmp(tag.getName(), "hi")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				SWBuf rend = tag.getAttribute("rend");
				
				u->lastHi = rend;
				if (rend == "ital")
					buf += "<i>";
				else if (rend == "bold")
					buf += "<b>";
				else if (rend == "sup")
					buf += "<small><sup>";

			}
			else if (tag.isEndTag()) {
				SWBuf rend = u->lastHi;
				if (rend == "ital")
					buf += "</i>";
				else if (rend == "bold")
					buf += "</b>";
				else if (rend == "sup")
					buf += "</sup></small>";
			}
		}

		// <entryFree>
		else if (!strcmp(tag.getName(), "entryFree")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				SWBuf n = tag.getAttribute("n");				
				if (n != "") {
					buf += "<b>";
					buf += n;
					buf += "</b>";
				}
			}
		}

		// <sense>
		else if (!strcmp(tag.getName(), "sense")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				SWBuf n = tag.getAttribute("n");
				if (n != "") {
					buf += "<br /><b>";
					buf += n;
					buf += "</b>";
				}
			}
		}

		// <div>
		else if (!strcmp(tag.getName(), "div")) {

			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "<!P>";
			}
			else if (tag.isEndTag()) {
			}
		}

		// <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def>
		else if (!strcmp(tag.getName(), "pos") || 
				 !strcmp(tag.getName(), "gen") || 
				 !strcmp(tag.getName(), "case") || 
				 !strcmp(tag.getName(), "gram") || 
				 !strcmp(tag.getName(), "number") || 
				 !strcmp(tag.getName(), "pron") /*||
				 !strcmp(tag.getName(), "def")*/) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "<i>";
			}
			else if (tag.isEndTag()) {
				buf += "</i>";
			}
		}

		// <tr>
		else if (!strcmp(tag.getName(), "tr")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "<i>";
			}
			else if (tag.isEndTag()) {
				buf += "</i>";
			}
		}
		
		// orth
		else if (!strcmp(tag.getName(), "orth")) {
			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
				buf += "<b>";
			}
			else if (tag.isEndTag()) {
				buf += "</b>";
			}
		}

		// <etym>, <usg>
		else if (!strcmp(tag.getName(), "etym") || 
				 !strcmp(tag.getName(), "usg")) {
			// do nothing here
		}
		else if (!strcmp(tag.getName(), "ref")) {
			if (!tag.isEndTag()) {
				u->suspendTextPassThru = true;
				SWBuf target;
				SWBuf work;
				SWBuf ref;

				int was_osisref = false;
				if(tag.getAttribute("osisRef"))
				{
					target += tag.getAttribute("osisRef");
					was_osisref=true;
				}
				else if(tag.getAttribute("target"))
					target += tag.getAttribute("target");

				if(target.size())
				{
					const char* the_ref = strchr(target, ':');
					
					if(!the_ref) {
						// No work
						ref = target;
					}
					else {
						// Compensate for starting :
						ref = the_ref + 1;

						int size = target.size() - ref.size() - 1;
						work.setSize(size);
						strncpy(work.getRawData(), target, size);
					}

					if(was_osisref)
					{
						buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
							(ref) ? URL::encode(ref.c_str()).c_str() : "", 
							(work.size()) ? URL::encode(work.c_str()).c_str() : "");
					}
					else
					{
						// Dictionary link, or something
						buf.appendFormatted("<a href=\"sword://%s/%s\">",
							(work.size()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(),
							(ref) ? URL::encode(ref.c_str()).c_str() : ""							
							);
					}
				}
				else
				{
					//std::cout << "TARGET WASN'T\n";
				}
				
			}
			else {
				buf += u->lastTextNode.c_str();
				buf += "</a>";
				
				u->suspendTextPassThru = false;
			}
		}

	   	// <note> tag
		else if (!strcmp(tag.getName(), "note")) {
			if (!tag.isEndTag()) {
				if (!tag.isEmpty()) {
					u->suspendTextPassThru = true;
				}
			}
			if (tag.isEndTag()) {
				SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
				
				buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup>*n</sup></small></a>",
					URL::encode(footnoteNumber.c_str()).c_str(), 
					URL::encode(u->version.c_str()).c_str(),
					URL::encode(u->key->getText()).c_str());
				
				u->suspendTextPassThru = false;
			}
		}

		else {
			return false;  // we still didn't handle token
		}

	}
	return true;
}
示例#19
0
bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
	const char *tok;
	MyUserData *u = (MyUserData *)userData;

	if (!substituteToken(buf, token)) {
		XMLTag tag(token);
		/*if (!strncmp(token, "w", 1)) {
			// OSIS Word (temporary until OSISRTF is done)
			valto = val;
			num = strstr(token, "lemma=\"x-Strongs:");
			if (num) {
				for (num+=17; ((*num) && (*num != '\"')); num++)
					*valto++ = *num;
				*valto = 0;
				if (atoi((!isdigit(*val))?val+1:val) < 5627) {
					buf += " <small><em>&lt;<a href=\"type=Strongs value=";
					for (tok = val; *tok; tok++)
							buf += *tok;
					buf += "\">";
					for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
							buf += *tok;
					buf += "</a>&gt;</em></small> ";
					//cout << buf;
					
				}
				//	forget these for now
				//else {
					// verb morph
					//sprintf(wordstr, "%03d", word-1);
					//module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
				//}
			}
			else {
				num = strstr(token, "lemma=\"strong:");
				if (num) {
					for (num+=14; ((*num) && (*num != '\"')); num++)
						*valto++ = *num;
					*valto = 0;
					if (atoi((!isdigit(*val))?val+1:val) < 5627) {
						buf += " <small><em>&lt;<a href=\"type=Strongs value=";
						for (tok = val; *tok; tok++)
								buf += *tok;
						buf += "\">";
						for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
								buf += *tok;
						buf += "</a>&gt;</em></small> ";
						//cout << buf;
						
					}
					//	forget these for now
					//else {
						// verb morph
						//sprintf(wordstr, "%03d", word-1);
						//module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
					//}
				}
			}
			valto = val;
			num = strstr(token, "morph=\"x-Robinson:");
			if (num) {
				for (num+=18; ((*num) && (*num != '\"')); num++)
					*valto++ = *num;
				*valto = 0;
				buf += " <small><em>(<a href=\"type=morph class=Robinson value=";
				for (tok = val; *tok; tok++)
				// normal robinsons tense
						buf += *tok;
				buf += "\">";
				for (tok = val; *tok; tok++)				
					//if(*tok != '\"') 			
						buf += *tok;		
				buf += "</a>)</em></small> ";					
			}
		}*/
		
		// else 
		if (!strncmp(token, "WG", 2)) { // strong's numbers
			//buf += " <small><em>&lt;<a href=\"type=Strongs value=";
			buf += " <a href=\"passagestudy.jsp?action=showStrongs&amp;type=Greek&amp;value=";
			for (tok = token+2; *tok; tok++)
				//if(token[i] != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">&lt;";
			for (tok = token + 2; *tok; tok++)
				//if(token[i] != '\"')
				buf += *tok;
			buf += "&gt;</a>";
		}
		else if (!strncmp(token, "WH", 2)) { // strong's numbers
			//buf += " <small><em>&lt;<a href=\"type=Strongs value=";
			buf += " <a href=\"passagestudy.jsp?action=showStrongs&amp;type=Hebrew&amp;value=";
			for (tok = token+2; *tok; tok++)
				//if(token[i] != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">&lt;";
			for (tok = token + 2; *tok; tok++)
				//if(token[i] != '\"')
				buf += *tok;
			buf += "&gt;</a>";
		}
		else if (!strncmp(token, "WTG", 3)) { // strong's numbers tense
			//buf += " <small><em>(<a href=\"type=Strongs value=";
			buf += " <a href=\"passagestudy.jsp?action=showStrongs&amp;type=Greek&amp;value=";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">(";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += ")</a>";
		}
		else if (!strncmp(token, "WTH", 3)) { // strong's numbers tense
			//buf += " <small><em>(<a href=\"type=Strongs value=";
			buf += " <a href=\"passagestudy.jsp?action=showStrongs&amp;type=Hebrew&amp;value=";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "\" class=\"strongs\">(";
			for (tok = token + 3; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += ")</a>";
		}

		else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
			//buf += " <small><em>(<a href=\"type=morph class=none value=";
			buf += " <a href=\"passagestudy.jsp?action=showMorph&amp;type=Greek&amp;value=";
			
			for (tok = token + 2; *tok; tok++)
				if(*tok != '\"')
					buf += *tok;
			buf += "\" class=\"morph\">(";
			for (tok = token + 2; *tok; tok++)				
				if(*tok != '\"') 			
					buf += *tok;		
			buf += ")</a>";
		}

		else if (!strcmp(tag.getName(), "RX")) {
			buf += "<a href=\"";
			for (tok = token + 3; *tok; tok++) {
			  if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
			    buf += *tok;
			  }
			  else {
			    break;
			  }
			}
			buf += "\">";
		}
		else if (!strcmp(tag.getName(), "RF")) {
			SWBuf type = tag.getAttribute("type");
			SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
			SWBuf noteName = tag.getAttribute("n");
			VerseKey *vkey = NULL;
			// see if we have a VerseKey * or descendant
			SWTRY {
				vkey = SWDYNAMIC_CAST(VerseKey, u->key);
			}
			SWCATCH ( ... ) {	}
			if (vkey) {
				// leave this special osis type in for crossReference notes types?  Might thml use this some day? Doesn't hurt.
				//char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
				buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&amp;type=n&amp;value=%s&amp;module=%s&amp;passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ", 
					URL::encode(footnoteNumber.c_str()).c_str(),
					URL::encode(u->version.c_str()).c_str(), 
					URL::encode(vkey->getText()).c_str(), 
					(renderNoteNumbers ? URL::encode(noteName.c_str()).c_str(): ""));
			}
			u->suspendTextPassThru = true;
		}