~repos /only-bible-app

#kotlin#android#ios

GIT_CONFIG_PARAMETERS="'http.version=HTTP/1.1'" git clone https://git.pyrossh.dev/only-bible-app.git
Discussions: https://groups.google.com/g/rust-embed-devs

The only bible app you will ever need. No ads. No in-app purchases. No distractions.



scripts/addRedLetters.js



import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const filesDir = path.join(__dirname, "files");
const kjvPath = path.join(filesDir, "en_kjv.txt");
// Step 1: Extract fully-red verse IDs from KJV
// A "fully red" verse is one where the entire verse text (after stripping ¶ and whitespace) is wrapped in <red>...</red>
const kjvLines = fs.readFileSync(kjvPath, "utf-8").split("\n").filter(Boolean);
const fullyRedIds = new Set();
for (const line of kjvLines) {
if (!line.includes("<red>")) continue;
const parts = line.split("|");
const text = parts.slice(6).join("|");
// Strip leading pilcrow and whitespace
const stripped = text.replace(/^[¶\s]+/, "").trim();
// Check if the entire text is wrapped in a single <red>...</red>
if (/^<red>.*<\/red>$/.test(stripped)) {
const book = parts[1];
const chapter = parts[2];
const verse = parts[3];
fullyRedIds.add(`${book}:${chapter}:${verse}`);
}
}
console.log(`Found ${fullyRedIds.size} fully-red verses in KJV`);
// Step 2: Apply <red> tags to all other bible files
const files = fs.readdirSync(filesDir).filter((f) => f.endsWith(".txt") && f !== "en_kjv.txt");
for (const file of files) {
const filePath = path.join(filesDir, file);
const lines = fs.readFileSync(filePath, "utf-8").split("\n");
let count = 0;
const newLines = lines.map((line) => {
if (!line) return line;
const parts = line.split("|");
if (parts.length < 6) return line;
const book = parts[1];
const chapter = parts[2];
const verse = parts[3];
const id = `${book}:${chapter}:${verse}`;
if (fullyRedIds.has(id)) {
// The text portion starts at index 6
const prefix = parts.slice(0, 6).join("|");
const text = parts.slice(6).join("|");
// Don't double-wrap if already has red tags
if (text.includes("<red>")) return line;
// Preserve leading ¶ and whitespace
const match = text.match(/^([¶\s]*)(.*)/);
const leading = match[1] || "";
const content = match[2] || "";
if (content.trim()) {
count++;
return `${prefix}|${leading}<red>${content}</red>`;
}
}
return line;
});
fs.writeFileSync(filePath, newLines.join("\n"), "utf-8");
console.log(`${file}: tagged ${count} verses`);
}