[sword-svn] r3342 - in trunk: include src/modules/filters
refdoc at crosswire.org
refdoc at crosswire.org
Sat Mar 14 08:00:03 MST 2015
Author: refdoc
Date: 2015-03-14 08:00:03 -0700 (Sat, 14 Mar 2015)
New Revision: 3342
Modified:
trunk/include/osislatex.h
trunk/src/modules/filters/osislatex.cpp
Log:
improved title handling, some whitespace improvements
Modified: trunk/include/osislatex.h
===================================================================
--- trunk/include/osislatex.h 2015-03-14 14:50:15 UTC (rev 3341)
+++ trunk/include/osislatex.h 2015-03-14 15:00:03 UTC (rev 3342)
@@ -47,9 +47,11 @@
bool inXRefNote;
bool BiblicalText;
int suspendLevel;
- bool firstCell;
+ bool firstCell; // for tables, indicates whether a cell is the first one in a row
SWBuf wordsOfChristStart;
SWBuf wordsOfChristEnd;
+ SWBuf divLevel; // divLevel "module", "testament, "bookgroup", "book", "majorsection", "section", "paragraph" , ignore others.
+
TagStack *quoteStack;
TagStack *hiStack;
TagStack *titleStack;
Modified: trunk/src/modules/filters/osislatex.cpp
===================================================================
--- trunk/src/modules/filters/osislatex.cpp 2015-03-14 14:50:15 UTC (rev 3341)
+++ trunk/src/modules/filters/osislatex.cpp 2015-03-14 15:00:03 UTC (rev 3342)
@@ -150,6 +150,7 @@
OSISLaTeX::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key), quoteStack(new TagStack()), hiStack(new TagStack()), titleStack(new TagStack()), lineStack(new TagStack()) {
inXRefNote = false;
suspendLevel = 0;
+ divLevel = "module";
wordsOfChristStart = "\\swordwoj{";
wordsOfChristEnd = "}";
consecutiveNewlines = 0;
@@ -165,7 +166,7 @@
void OSISLaTeX::MyUserData::outputNewline(SWBuf &buf) {
if (++consecutiveNewlines <= 2) {
- outText("////", buf, this);
+ outText("//\n", buf, this);
supressAdjacentWhitespace = true;
}
}
@@ -386,7 +387,7 @@
// start line marker
if (tag.getAttribute("sID") || (!tag.isEndTag() && !tag.isEmpty())) {
// nested lines plus if the line itself has an x-indent type attribute value
- outText(SWBuf("\\swordindent{").appendFormatted("%d}", u->lineStack->size() + (SWBuf("x-indent") == tag.getAttribute("type")?1:0)).c_str(), buf, u);
+ outText("\\swordpoetryline{", buf, u);
u->lineStack->push(tag.toString());
}
// end line marker
@@ -438,33 +439,24 @@
}
// <title>
+
else if (!strcmp(tag.getName(), "title")) {
if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, u->key);
- if (vkey && !vkey->getVerse()) {
- if (!vkey->getChapter()) {
- if (!vkey->getBook()) {
- if (!vkey->getTestament()) {
- buf += "\\swordmodule*{";
- }
- else {
- buf += "\\swordtestament*{";
- }
- }
- else {
- buf += "\\swordbook*{";
- }
- }
- else {
- buf += "\\swordchapter*{";
- }
- }
- else {
- buf += "\\swordsection*{";
- }
+ const char *tmp = tag.getAttribute("type");
+ bool hasType = tmp;
+ SWBuf type = tmp;
+
+ outText("\n\\swordtitle{", buf, u);
+ outText(u->divLevel, buf, u);
+ outText("}{", buf, u);
+
+ if (hasType) outText(type, buf, u);
+ else outText("", buf, u);
+
+ outText("}{", buf, u);
}
else if (tag.isEndTag()) {
- buf += "}\n\n";
+ buf += "}";
++u->consecutiveNewlines;
u->supressAdjacentWhitespace = true;
}
@@ -473,10 +465,10 @@
// <list>
else if (!strcmp(tag.getName(), "list")) {
if((!tag.isEndTag()) && (!tag.isEmpty())) {
- outText("\\begin{itemize}", buf, u);
+ outText("\n\\begin{itemize}", buf, u);
}
else if (tag.isEndTag()) {
- outText("\\end{itemize}", buf, u);
+ outText("\n\\end{itemize}", buf, u);
++u->consecutiveNewlines;
u->supressAdjacentWhitespace = true;
}
@@ -485,10 +477,9 @@
// <item>
else if (!strcmp(tag.getName(), "item")) {
if((!tag.isEndTag()) && (!tag.isEmpty())) {
- outText("\\item ", buf, u);
+ outText("\n\\item ", buf, u);
}
else if (tag.isEndTag()) {
- outText("\n", buf, u);
++u->consecutiveNewlines;
u->supressAdjacentWhitespace = true;
}
@@ -651,35 +642,45 @@
}
filepath += src;
- // images become clickable, if the UI supports showImage.
outText("\\figure{", buf, u);
- outText(URL::encode(filepath.c_str()).c_str(), buf, u);
- outText("&module=", buf, u);
- outText(URL::encode(u->version.c_str()).c_str(), buf, u);
- outText("\">", buf, u);
-
- outText("<img src=\"file:", buf, u);
- outText(filepath, buf, u);
- outText("\" border=\"0\" />", buf, u);
-
- outText("</a>", buf, u);
+ outText("\\includegraphics{", buf, u);
+ outText(filepath.c_str(), buf, u);
+ outText("}}", buf, u);
+
}
}
// ok to leave these in
else if (!strcmp(tag.getName(), "div")) {
SWBuf type = tag.getAttribute("type");
- if (type == "bookGroup") {
+ if (type == "module") {
+ u->divLevel = type;
+ buf +="\n";
+ }
+ else if (type == "testament") {
+ u->divLevel = type;
+ buf +="\n";
}
+ else if (type == "bookGroup") {
+ u->divLevel = type;
+ buf +="\n";
+ }
else if (type == "book") {
+ u->divLevel = type;
+ buf +="\n";
}
+ else if (type == "majorSection") {
+ u->divLevel = type;
+ buf +="\n";
+ }
else if (type == "section") {
+ u->divLevel = type;
+ buf +="\n";
}
- else if (type == "majorSection") {
+ else if (type == "paragraph") {
+ u->divLevel = type;
+ buf +="\n";
}
- else {
- buf += "\\\\";;
- }
}
else if (!strcmp(tag.getName(), "span")) {
buf += "";
@@ -689,10 +690,10 @@
}
else if (!strcmp(tag.getName(), "table")) {
if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "\n\\begin{tabular}\n";
+ buf += "\n\\begin{tabular}";
}
else if (tag.isEndTag()) {
- buf += "\n\\end{tabular}\n";
+ buf += "\n\\end{tabular}";
++u->consecutiveNewlines;
u->supressAdjacentWhitespace = true;
}
@@ -700,11 +701,11 @@
}
else if (!strcmp(tag.getName(), "row")) {
if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "";
+ buf += "\n";
u->firstCell = true;
}
else if (tag.isEndTag()) {
- buf += "//\n";
+ buf += "//";
u->firstCell = false;
}
More information about the sword-cvs
mailing list