Describe the bug
Most likely an issue with the source data, but there are extraneous line breaks in the middle of many verses in the KJV causing terrible formatting
To Reproduce
Steps to reproduce the behavior:
Insert any of the very many affected verses from the KJV
Expected behavior
Extraneous line breaks should be removed when inserting text, and then, if necessary, add a line break at the end of each verse (depending on Paragraph or Single Line option).
What Device Do You Use(please complete the following information):
Device: Desktop PC
OS: Windows 11
Bible Ref ver 2.4.4
Solution:
/**
* To get the content of the bible verses
*/
get allFormattedContent() {
var _a;
if (!((_a = this.verses) == null ? void 0 : _a.length)) {
console.error("No verses found");
}
return [this.head, this.bodyContent, this.bottom].join("\n");
}
get bodyContent() {
var _a, _b;
if (!((_a = this.verses) == null ? void 0 : _a.length)) {
return "";
}
let text = "";
if (((_b = this.settings) == null ? void 0 : _b.verseFormatting) === "Paragraph" /* Paragraph */) {
text = "> ";
} else {
text = "";
}
this.verses.forEach((verse) => {
var _a2;
const verseNumberFormatted = this.formatVerseNumber(verse.verse);
if (((_a2 = this.settings) == null ? void 0 : _a2.verseFormatting) === "Paragraph" /* Paragraph */) {
text += " " + verseNumberFormatted + verse.text.trim().replaceAll("\n", " ");
} else {
text += "> " + verseNumberFormatted + verse.text.trim() + "\n";
}
});
Change text += "> " + verseNumberFormatted + verse.text.trim() + "\n"; under the final else to text += "> " + verseNumberFormatted + verse.text.replace(/\r\n|\n|\r/g, " ") + "\n";
Since the line breaks are not at the beginning or end of the string, the .trim() method will not catch and remove them. Use the .replace() method instead.
Describe the bug Most likely an issue with the source data, but there are extraneous line breaks in the middle of many verses in the KJV causing terrible formatting
To Reproduce Steps to reproduce the behavior:
Expected behavior Extraneous line breaks should be removed when inserting text, and then, if necessary, add a line break at the end of each verse (depending on Paragraph or Single Line option).
What Device Do You Use(please complete the following information):
Solution:
Change
text += "> " + verseNumberFormatted + verse.text.trim() + "\n";
under the finalelse
totext += "> " + verseNumberFormatted + verse.text.replace(/\r\n|\n|\r/g, " ") + "\n";
Since the line breaks are not at the beginning or end of the string, the.trim()
method will not catch and remove them. Use the.replace()
method instead.