From 9f74601ad889b330c5208a195f3d33954c5d80dc Mon Sep 17 00:00:00 2001 From: The-Best-Codes Date: Thu, 28 Nov 2024 12:29:00 -0600 Subject: [PATCH] Update version --- package.json | 2 +- scripts/processBible.js | 71 ----------------------------------------- 2 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 scripts/processBible.js diff --git a/package.json b/package.json index 1ebc70e..a575d29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "best-bible", - "version": "1.6.7", + "version": "1.6.9", "description": "Fetch, parse, and analyze the Bible easily with JavaScript", "scripts": { "prebuild": "rm -rf dist", diff --git a/scripts/processBible.js b/scripts/processBible.js deleted file mode 100644 index 5278617..0000000 --- a/scripts/processBible.js +++ /dev/null @@ -1,71 +0,0 @@ -const fs = require('fs').promises; -const path = require('path'); - -function cleanVerse(verse) { - return verse - .replace(/\[(.*?)\]/g, '$1') // Remove translation identifiers - .replace(/^#\s*/, '') // Remove '#' at the start - .trim() // Trim whitespace - .replace(/\s+/g, ' '); // Remove multiple spaces -} - -function parseVerse(verse) { - const parts = []; - let currentText = ''; - const words = verse.split(' '); - - words.forEach(word => { - if (word.startsWith('[') && word.endsWith(']')) { - if (currentText) { - parts.push({ text: currentText.trim(), type: 'normal' }); - currentText = ''; - } - parts.push({ text: word.slice(1, -1), type: 'added' }); - } else { - currentText += ' ' + word; - } - }); - - if (currentText) { - parts.push({ text: currentText.trim(), type: 'normal' }); - } - - return parts; -} - -async function processBible(inputFile, cleanedOutput, parsedOutput) { - try { - const data = await fs.readFile(inputFile, 'utf8'); - const bible = JSON.parse(data); - - const cleanedBible = {}; - const parsedBible = {}; - - for (const [book, chapters] of Object.entries(bible)) { - cleanedBible[book] = {}; - parsedBible[book] = {}; - for (const [chapter, verses] of Object.entries(chapters)) { - cleanedBible[book][chapter] = verses.map(cleanVerse); - parsedBible[book][chapter] = verses.map((verse, index) => ({ - [index + 1]: parseVerse(verse) - })); - } - } - - await fs.writeFile(cleanedOutput, JSON.stringify(cleanedBible, null, 2)); - await fs.writeFile(parsedOutput, JSON.stringify(parsedBible, null, 2)); - - console.log('Processing complete. Files created:'); - console.log(cleanedOutput); - console.log(parsedOutput); - } catch (error) { - console.error('An error occurred:', error); - } -} - -// Run the process -const inputFile = path.join(__dirname, 'bible.json'); -const cleanedOutput = path.join(__dirname, 'bible_cleaned.json'); -const parsedOutput = path.join(__dirname, 'bible_parsed.json'); - -processBible(inputFile, cleanedOutput, parsedOutput); \ No newline at end of file