Skip to content

Commit 01bceae

Browse files
authored
fix: Account for BOM in the processor (#282)
* fix: Account for BOM in the processor * fix tests, add new test
1 parent e6ab87e commit 01bceae

File tree

2 files changed

+913
-776
lines changed

2 files changed

+913
-776
lines changed

src/processor.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const UNSATISFIABLE_RULES = new Set([
3333
]);
3434
const SUPPORTS_AUTOFIX = true;
3535

36+
const BOM = "\uFEFF";
37+
3638
/**
3739
* @type {Map<string, Block[]>}
3840
*/
@@ -248,11 +250,12 @@ const languageToFileExtension = {
248250

249251
/**
250252
* Extracts lintable code blocks from Markdown text.
251-
* @param {string} text The text of the file.
253+
* @param {string} sourceText The text of the file.
252254
* @param {string} filename The filename of the file
253255
* @returns {Array<{ filename: string, text: string }>} Source code blocks to lint.
254256
*/
255-
function preprocess(text, filename) {
257+
function preprocess(sourceText, filename) {
258+
const text = sourceText.startsWith(BOM) ? sourceText.slice(1) : sourceText;
256259
const ast = fromMarkdown(text);
257260
const blocks = [];
258261

0 commit comments

Comments
 (0)