74 MyUserData *u =
new MyUserData(module, key);
75 u->testament = (u->vkey) ? u->vkey->getTestament() : 2;
85 if ((
unsigned)from[0] == 0xC2 && (
unsigned)from[1] == 0xAD)
return true;
94 MyUserData *u = (MyUserData *)userData;
95 if (((*token ==
'w') && (token[1] ==
' ')) ||
96 ((*token ==
'/') && (token[1] ==
'w') && (!token[2]))) {
101 if (token[strlen(token)-1] !=
'/') {
107 u->tag = (start) ? token : u->w.c_str();
110 SWBuf lastText = (start) ?
"stuff" : u->lastTextNode.c_str();
114 if ((attrib = u->tag.getAttribute(
"xlit"))) {
115 val = strchr(attrib,
':');
116 val = (val) ? (val + 1) : attrib;
121 if ((attrib = u->tag.getAttribute(
"gloss"))) {
126 if ((attrib = u->tag.getAttribute(
"lemma"))) {
127 int count = u->tag.getAttributePartCount(
"lemma",
' ');
128 int i = (count > 1) ? 0 : -1;
131 attrib = u->tag.getAttribute(
"lemma", i,
' ');
133 val = strchr(attrib,
':');
134 val = (val) ? (val + 1) : attrib;
135 if ((strchr(
"GH", *val)) && (isdigit(val[1]))) {
140 gh = (u->testament>1) ?
'G' :
'H';
142 if ((!strcmp(val,
"3588")) && (lastText.
length() < 1))
150 }
while (++i < count);
152 if ((attrib = u->tag.getAttribute(
"morph")) && (show)) {
153 int count = u->tag.getAttributePartCount(
"morph",
' ');
154 int i = (count > 1) ? 0 : -1;
156 attrib = u->tag.getAttribute(
"morph", i,
' ');
158 val = strchr(attrib,
':');
159 val = (val) ? (val + 1) : attrib;
160 if ((*val ==
'T') && (strchr(
"GH", val[1])) && (isdigit(val[2])))
165 }
while (++i < count);
167 if ((attrib = u->tag.getAttribute(
"POS"))) {
168 val = strchr(attrib,
':');
169 val = (val) ? (val + 1) : attrib;
178 else if (!strncmp(token,
"note", 4)) {
179 if (!strstr(token,
"strongsMarkup")) {
182 else u->suspendTextPassThru =
true;
186 SWBuf footnoteBody = u->module->getEntryAttributes()[
"Footnote"][swordFootnote][
"body"];
187 buf.
append(u->module->renderText(footnoteBody));
190 else if (!strncmp(token,
"/note", 5)) {
191 if (!u->suspendTextPassThru)
193 else u->suspendTextPassThru =
false;
197 else if (((*token ==
'p') && ((token[1] ==
' ') || (!token[1]))) ||
198 ((*token ==
'/') && (token[1] ==
'p') && (!token[2]))) {
206 else if (!strcmp(u->tag.getName(),
"div") && u->tag.getAttribute(
"type") && (!strcmp(u->tag.getAttribute(
"type"),
"x-p") || !strcmp(u->tag.getAttribute(
"type"),
"paragraph")) &&
207 (u->tag.isEmpty() && (u->tag.getAttribute(
"sID") || u->tag.getAttribute(
"eID")))) {
213 else if (!strncmp(token,
"lb", 2)) {
217 else if (!strncmp(token,
"l", 1) && strstr(token,
"eID")) {
221 else if (!strncmp(token,
"/divineName", 11)) {
224 end += buf.
size() - u->lastTextNode.size();
227 else if (!strncmp(token,
"hi", 2)) {
235 if (strstr(token,
"rend=\"ol\"") || strstr(token,
"rend=\"x-overline\"") || strstr(token,
"rend=\"overline\"")
236 || strstr(token,
"type=\"ol\"") || strstr(token,
"type=\"x-overline\"") || strstr(token,
"type=\"overline\"")) {
237 u->hiType =
"overline";
240 u->suspendTextPassThru =
true;
242 else if (!strncmp(token,
"/hi", 3)) {
243 if (u->hiType ==
"overline") {
244 const unsigned char *b = (
const unsigned char *)u->lastTextNode.c_str();
246 const unsigned char *o = b;
248 while (o != b) buf.
append(*(o++));
249 buf.
append((
unsigned char)0xCC);
250 buf.
append((
unsigned char)0x85);
256 buf.
append(u->lastSuspendSegment);
259 u->suspendTextPassThru =
false;
262 else if ((!strncmp(token,
"q", 1) && (u->tag.getAttribute(
"marker")))) {
263 buf.
append(u->tag.getAttribute(
"marker"));
268 else if (!strncmp(token,
"milestone", 9)) {
269 const char* type = strstr(token+10,
"type=\"");
270 if (type && strncmp(type+6,
"line", 4)) {
274 if (u->tag.getAttribute(
"marker")) {
275 buf.
append(u->tag.getAttribute(
"marker"));
#define SWORD_NAMESPACE_START
static const char PRECHAR
void setTokenEnd(const char *tokenEnd)
unsigned long length() const
virtual bool processStage(char stage, SWBuf &text, char *&from, BasicFilterUserData *userData)
void setTokenCaseSensitive(bool val)
void setEscapeStart(const char *escStart)
bool substituteToken(SWBuf &buf, const char *token)
void addEscapeStringSubstitute(const char *findString, const char *replaceString)
void setTokenStart(const char *tokenStart)
MyUserData(const SWModule *module, const SWKey *key)
SWBuf & append(const char *str, long max=-1)
virtual bool handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData)
unsigned long size() const
const char * getAttribute(const char *attribName, int partNum=-1, char partSplit= '|') const
virtual void setStageProcessing(char stages)
bool supressAdjacentWhitespace
void setEscapeStringCaseSensitive(bool val)
void addTokenSubstitute(const char *findString, const char *replaceString)
char * toupperstr(char *t, unsigned int max=0)
void setEscapeEnd(const char *escEnd)
#define SWORD_NAMESPACE_END
virtual BasicFilterUserData * createUserData(const SWModule *module, const SWKey *key)
SW_u32 getUniCharFromUTF8(const unsigned char **buf, bool skipValidation=false)