aboutsummaryrefslogtreecommitdiff
path: root/libbible.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-11-10 08:29:20 -0500
committerYour Name <you@example.com>2020-11-10 08:29:20 -0500
commit41cdb2d5e3f8e5f08b4933cbb9693ee4a6908580 (patch)
treeab3e84c50fbe6ec6887e642edc87d867731c6a85 /libbible.cc
parenta308af1cd84185989f1262ba66b01f6a9ceafa6a (diff)
downloadlibbible-41cdb2d5e3f8e5f08b4933cbb9693ee4a6908580.tar.gz
libbible-41cdb2d5e3f8e5f08b4933cbb9693ee4a6908580.tar.bz2
libbible-41cdb2d5e3f8e5f08b4933cbb9693ee4a6908580.zip
Fixed handling of paragraph symbol
Diffstat (limited to 'libbible.cc')
-rw-r--r--libbible.cc42
1 files changed, 33 insertions, 9 deletions
diff --git a/libbible.cc b/libbible.cc
index c7f3f4c..92d6ee8 100644
--- a/libbible.cc
+++ b/libbible.cc
@@ -157,28 +157,34 @@ vector<libbible::text> libbible::getText(libbible::passage pass) {
for(; key->getChapter() < pass.chapterEnd ||
(key->getChapter() == pass.chapterEnd && key->getVerse() <= pass.verseEnd);
(*key)++) {
- texts.push_back(getEmptyText(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.replace(0, 1, "\n");
+ /*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;
- }
+ }*/
+
+ texts.push_back(getEmptyText(key));
- while(text[0] == ' ' || text[0] == '\t') {
- text.erase(0, 1);
- }
+ /* Things to enforce:
+ * 1. No whitespace at start of verse
+ */
// Find and replace everything in "subs" map
- const map<string, string> subs = {{"¶", "\n\t"}};
+ /*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()) {
@@ -190,6 +196,7 @@ vector<libbible::text> libbible::getText(libbible::passage pass) {
// Variable to accumulate unterminated spans
std::vector<string> spans;
bool spansChanged = false;
+ bool hasAddedText = false;
// Iterate over text
for(auto i = text.begin(); i != text.end(); i++) {
if(*i != '<') {
@@ -204,7 +211,24 @@ vector<libbible::text> libbible::getText(libbible::passage pass) {
}
}
}
+ if(! hasAddedText && (*i == ' ' || *i == '\t')) {
+ continue;
+ }
+ if(*i == "¶"[0] && *(i+1) == "¶"[1]) {
+ i++;
+ if(hasAddedText) {
+ texts.back().text += '\n';
+ } else {
+ // Append \n to text in previous texts (if applicable)
+ if(texts.size() > 1) {
+ texts[texts.size()-2].text += '\n';
+ }
+ texts.back().modifiers.push_back("paragraph");
+ continue;
+ }
+ }
texts.back().text += *i;
+ hasAddedText = true;
}
else {
string span;