Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dzencot committed Jul 3, 2024
1 parent 97cef04 commit 0876a1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ const checkTree = (source, language, rules) => {
return iter(source);
}

/* TODO: Функция парсит маркдаун-файл и проверяет текст в узлах, пропуская ненужные узлы из списка filterBlocks.
Возможно стоит использовать Checker вместо этого (как в getErrors) */
const fix = async (dirPath, language, rules = []) => {
const filePaths = await getFilePaths(dirPath);
const promises = filePaths.map(async (fullpath) => {
Expand Down Expand Up @@ -146,7 +148,7 @@ const getErrors = async (dirPath, language, rules = []) => {

const parser = new Checker(rules);

const content = parser.filterContent(sourceContent);
const content = parser.filterContent(sourceContent, filterBlocks);

const checkResult = await check(content, language, rules);

Expand Down
8 changes: 2 additions & 6 deletions src/markdownParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import fs from 'fs';

class Parser {
// https://github.com/syntax-tree/mdast#nodes
filterBlocks = [
'code',
'inlineCode',
];
filteredData = [];

constructor(rules) {
Expand All @@ -32,10 +28,10 @@ class Parser {
}


filterContent(content) {
filterContent(content, filterBlocks) {
const mkTree = fromMarkdown(content);
const iter = (tree) => {
if (this.filterBlocks.includes(tree.type)) {
if (filterBlocks.includes(tree.type)) {
const currentNode = _.cloneDeep(tree);
this.filteredData.push(currentNode);
if (tree.children) {
Expand Down

0 comments on commit 0876a1c

Please sign in to comment.