From 7a00574163029c0c2b649878c95d5acbd083564a Mon Sep 17 00:00:00 2001 From: "Roberto C. Sanchez" Date: Mon, 12 May 2014 08:21:30 -0400 Subject: Imported Upstream version 1.7.2+dfsg --- src/modules/filters/osisplain.cpp | 64 +++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 13 deletions(-) (limited to 'src/modules/filters/osisplain.cpp') diff --git a/src/modules/filters/osisplain.cpp b/src/modules/filters/osisplain.cpp index 57105f0..6e583a4 100644 --- a/src/modules/filters/osisplain.cpp +++ b/src/modules/filters/osisplain.cpp @@ -1,10 +1,10 @@ /****************************************************************************** - * osisplain.cpp - An SWFilter - * impl that provides stripping of OSIS tags * - * $Id: osisplain.cpp 2334 2009-04-24 00:14:12Z scribe $ + * osisplain.cpp - An SWFilter that provides stripping of OSIS tags * - * Copyright 2001 CrossWire Bible Society (http://www.crosswire.org) + * $Id: osisplain.cpp 2984 2013-09-20 12:18:45Z scribe $ + * + * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 @@ -28,17 +28,21 @@ SWORD_NAMESPACE_START + namespace { -class MyUserData : public BasicFilterUserData { -public: - SWBuf w; - XMLTag tag; - VerseKey *vk; - char testament; - MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {} -}; + + class MyUserData : public BasicFilterUserData { + public: + SWBuf w; + XMLTag tag; + VerseKey *vk; + char testament; + SWBuf hiType; + MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {} + }; } + OSISPlain::OSISPlain() { setTokenStart("<"); setTokenEnd(">"); @@ -65,7 +69,7 @@ OSISPlain::OSISPlain() { BasicFilterUserData *OSISPlain::createUserData(const SWModule *module, const SWKey *key) { MyUserData *u = new MyUserData(module, key); u->vk = SWDYNAMIC_CAST(VerseKey, u->key); - u->testament = (u->vk) ? u->vk->Testament() : 2; // default to NT + u->testament = (u->vk) ? u->vk->getTestament() : 2; // default to NT return u; } @@ -202,6 +206,40 @@ bool OSISPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData * end += buf.size() - u->lastTextNode.size(); toupperstr(end); } + else if (!strncmp(token, "hi", 2)) { + + // handle both OSIS 'type' and TEI 'rend' attributes + // there is no officially supported OSIS overline attribute, + // thus either TEI overline or OSIS x-overline would be best, + // but we have used "ol" in the past, as well. Once a valid + // OSIS overline attribute is made available, these should all + // eventually be deprecated and never documented that they are supported. + if (strstr(token, "rend=\"ol\"") || strstr(token, "rend=\"x-overline\"") || strstr(token, "rend=\"overline\"") + || strstr(token, "type=\"ol\"") || strstr(token, "type=\"x-overline\"") || strstr(token, "type=\"overline\"")) { + u->hiType = "overline"; + } + else u->hiType = ""; + u->suspendTextPassThru = true; + } + else if (!strncmp(token, "/hi", 3)) { + if (u->hiType == "overline") { + const unsigned char *b = (const unsigned char *)u->lastTextNode.c_str(); + while (*b) { + const unsigned char *o = b; + if (getUniCharFromUTF8(&b)) { + while (o != b) buf.append(*(o++)); + buf.append((unsigned char)0xCC); + buf.append((unsigned char)0x85); + } + } + } + else { + buf.append("*"); + buf.append(u->lastTextNode); + buf.append("*"); + } + u->suspendTextPassThru = false; + } // else if (!strncmp(token, "milestone", 9)) { -- cgit v1.2.3