Fix text encoding issues in NKJV files by removing UTF-8 BOM in readMarkdownFile

This commit is contained in:
Ryderjj89
2025-09-28 12:53:28 -04:00
parent 9e16b10222
commit 4721e8b5a5
1191 changed files with 6 additions and 4 deletions

View File

@@ -61,11 +61,12 @@ function getDataDir(version) {
return esvSearchEngine ? ESV_DATA_DIR : NKJV_DATA_DIR; // default to available version
}
// Helper function to read markdown files
// Helper function to read markdown files with encoding normalization
async function readMarkdownFile(filePath) {
try {
const content = await fs.readFile(filePath, 'utf-8');
return content;
// Remove BOM if present and normalize encoding issues
return content.replace(/^\uFEFF/, ''); // Remove UTF-8 BOM
} catch (error) {
throw new Error(`Failed to read file: ${filePath}`);
}