Skip to content

Commit

Permalink
fix: Account for BOM in the processor (#282)
Browse files Browse the repository at this point in the history
* fix: Account for BOM in the processor

* fix tests, add new test
  • Loading branch information
mdjermanovic committed Sep 16, 2024
1 parent e6ab87e commit 01bceae
Show file tree
Hide file tree
Showing 2 changed files with 913 additions and 776 deletions.
7 changes: 5 additions & 2 deletions src/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const UNSATISFIABLE_RULES = new Set([
]);
const SUPPORTS_AUTOFIX = true;

const BOM = "\uFEFF";

/**
* @type {Map<string, Block[]>}
*/
Expand Down Expand Up @@ -248,11 +250,12 @@ const languageToFileExtension = {

/**
* Extracts lintable code blocks from Markdown text.
* @param {string} text The text of the file.
* @param {string} sourceText The text of the file.
* @param {string} filename The filename of the file
* @returns {Array<{ filename: string, text: string }>} Source code blocks to lint.
*/
function preprocess(text, filename) {
function preprocess(sourceText, filename) {
const text = sourceText.startsWith(BOM) ? sourceText.slice(1) : sourceText;
const ast = fromMarkdown(text);
const blocks = [];

Expand Down
Loading

0 comments on commit 01bceae

Please sign in to comment.