Fix text encoding issues in NKJV files by removing UTF-8 BOM in readMarkdownFile
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user