aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-08-09 16:40:24 -0400
committerYour Name <you@example.com>2021-08-09 16:40:24 -0400
commitab2668a4b0e6eebd80668aea9110f6fb86aed5a4 (patch)
treebcffb10053a4080d87a2870ad23bc8bcc11cb4f1
parent41e9b6128ed8588c01d2aa2fb7d71af81709873e (diff)
downloadlibbible-ab2668a4b0e6eebd80668aea9110f6fb86aed5a4.tar.gz
libbible-ab2668a4b0e6eebd80668aea9110f6fb86aed5a4.tar.bz2
libbible-ab2668a4b0e6eebd80668aea9110f6fb86aed5a4.zip
Fixed processing of non-span xhtml formatting tags
-rw-r--r--bible.cc21
-rw-r--r--libbible.cc58
-rw-r--r--mods.cc1
3 files changed, 41 insertions, 39 deletions
diff --git a/bible.cc b/bible.cc
index d50d7e9..ef9c1e4 100644
--- a/bible.cc
+++ b/bible.cc
@@ -244,6 +244,9 @@ int main(int argc, char* argv[]) {
bool isIndent = false;
bool isDivineName = false;
bool isJesus = false;
+ bool isFootnote = false;
+ bool isTitle = false;
+ bool isParallel = false;
for(string modifier : tex.modifiers) {
if(modifier == "paragraph") {
isParagraph = true;
@@ -253,8 +256,26 @@ int main(int argc, char* argv[]) {
isDivineName = true;
} else if (modifier == "wordsOfJesus") {
isJesus = true;
+ } else if (modifier == "n") {
+ isFootnote = true;
+ } else if (modifier == "title") {
+ isTitle = true;
+ } else if (modifier == "parallel") {
+ isParallel = true;
}
}
+ if(isFootnote) {
+ // Someday maybe we add this, but for now, omit
+ tex.text = "";
+ }
+ if(isTitle) {
+ // Someday maybe we add this, but for now, omit
+ tex.text = "";
+ }
+ if(isParallel) {
+ // Someday maybe we add this, but for now, omit
+ tex.text = "";
+ }
if(isIndent) {
isParagraph = false;
if(isNewline) {
diff --git a/libbible.cc b/libbible.cc
index 901ff4e..12e45a0 100644
--- a/libbible.cc
+++ b/libbible.cc
@@ -167,33 +167,10 @@ vector<libbible::text> libbible::getText(libbible::passage pass) {
(*key)++) {
string text = string(target->renderText());
- //printf("Processing text \"%s\"", text.c_str());
-
- // Handle ¶ symbol if at beginning of line
- /*if(text.find("¶") == 0) {
- text.erase(0, 1);
- // Append \n to text in previous texts (if applicable)
- if(! texts.empty()) {
- texts.back().text += '\n';
- }
- endOfParagraph = true;
- }*/
+ //printf("Working with: %s\n", text.c_str());
texts.push_back(getEmptyText(key));
- /* Things to enforce:
- * 1. No whitespace at start of verse
- */
-
- // Find and replace everything in "subs" map
- /*const map<string, string> subs = {{"¶", "\n\t"}};
- for(auto const &repl : subs) {
- string::size_type location;
- while((location = text.find(repl.first)) != string::npos) {
- text.replace(location, repl.first.size(), repl.second);
- }
- }*/
-
if(key->getVerse() == 1 || endOfParagraph) {
if(find(texts.back().modifiers.begin(), texts.back().modifiers.end(), "paragraph") == texts.back().modifiers.end()) {
texts.back().modifiers.push_back("paragraph");
@@ -202,7 +179,7 @@ vector<libbible::text> libbible::getText(libbible::passage pass) {
}
// Variable to accumulate unterminated spans
- std::vector<string> spans;
+ std::vector<std::pair<std::string, std::string>> spans;
bool spansChanged = false;
bool hasAddedText = false;
// Iterate over text
@@ -213,7 +190,7 @@ vector<libbible::text> libbible::getText(libbible::passage pass) {
if(!texts.back().text.empty()) {
texts.push_back(getEmptyText(key));
}
- for(string modifier : spans) {
+ for(auto& [tag, modifier] : spans) {
if(find(texts.back().modifiers.begin(), texts.back().modifiers.end(), modifier) == texts.back().modifiers.end()) {
texts.back().modifiers.push_back(modifier);
}
@@ -243,21 +220,24 @@ vector<libbible::text> libbible::getText(libbible::passage pass) {
for(; i != text.end(); i++) {
span.push_back(*i);
if(*i == '>') {
- // The end of the span will be "</span>".
- if(span == "</span>") {
- if(! spans.empty()) {
- spans.pop_back();
- spansChanged = true;
+ // The end of the span will be "</tag>".
+ if(span[1] == '/') {
+ string tag = span.substr(2, span.size()-3);
+ for(auto rit = spans.rbegin(); rit != spans.rend(); rit++) {
+ if(rit->first == tag) {
+ spans.erase(rit.base()-1);
+ spansChanged = true;
+ break;
+ }
}
- } else {
- // The span will be formatted "<span class=\"NAME\">"
+ } else if(span.find("class=\"") != string::npos) {
+ // The span will be formatted "<tag class=\"NAME\">"
// We want just the NAME
- size_t start = span.find_first_of('"')+1;
- size_t end = span.find_last_of('"');
- if(start > 0) {
- spans.push_back(span.substr(start, end-start));
- spansChanged = true;
- }
+ string tag = span.substr(1, span.find(" ")-1);
+ size_t start = span.find("class=\"")+7;
+ size_t end = span.find("\"", start);
+ spans.push_back(std::pair<string, string>(tag, span.substr(start, end-start)));
+ spansChanged = true;
}
break;
}
diff --git a/mods.cc b/mods.cc
index 2c9cf22..30b24f8 100644
--- a/mods.cc
+++ b/mods.cc
@@ -110,6 +110,7 @@ bool libbible::installModFromInternet(string language, string name) {
if(p.first == name) {
sword::SWMgr mgr(basedir.c_str());
if(installMgr->installModule(&mgr, 0, name.c_str(), p.second) == 0) {
+ printf("Installed from %s\n", p.second->getConfEnt().c_str());
return true;
}
return false;