From ab2668a4b0e6eebd80668aea9110f6fb86aed5a4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 9 Aug 2021 16:40:24 -0400 Subject: Fixed processing of non-span xhtml formatting tags --- bible.cc | 21 +++++++++++++++++++++ libbible.cc | 58 +++++++++++++++++++--------------------------------------- mods.cc | 1 + 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::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 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::getText(libbible::passage pass) { } // Variable to accumulate unterminated spans - std::vector spans; + std::vector> spans; bool spansChanged = false; bool hasAddedText = false; // Iterate over text @@ -213,7 +190,7 @@ vector 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::getText(libbible::passage pass) { for(; i != text.end(); i++) { span.push_back(*i); if(*i == '>') { - // The end of the span will be "". - if(span == "") { - if(! spans.empty()) { - spans.pop_back(); - spansChanged = true; + // The end of the span will be "". + 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 "" + } else if(span.find("class=\"") != string::npos) { + // The span will be formatted "" // 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(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; -- cgit v1.2.3