Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dzencot committed Apr 20, 2024
1 parent 39c6773 commit f2ab7a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ const checkContent = async (content, rules) => {

const checkResults = await check(content, rules);

const results = checkResults.matches; //$(echo "$body" | jq '.matches[] | "\(.message) => \(.sentence)"')
// const fileName = fullpath.split('/').slice(2).join('/');
const results = checkResults.matches;

if (!results) {
return '';
Expand All @@ -138,15 +137,17 @@ const checkContent = async (content, rules) => {
const checkTree = (source, rules) => {
const iter = async (tree) => {
if (filterBlocks.includes(tree.type)) {
return Promise.resolve();
return tree;
}

tree.value = await checkContent(tree.value, rules);
const newValue = await checkContent(tree.value, rules);

tree.value = newValue;

if (tree.children) {
return Promise.all(tree.children.map(iter));
tree.children = await Promise.all(tree.children.map(iter));
}
return Promise.resolve();
return tree;
};

return iter(source);
Expand All @@ -160,9 +161,9 @@ const fix = async (rules = []) => {

const parsedContent = fromMarkdown(content);

checkTree(parsedContent, rules);
const fixedContent = await checkTree(parsedContent, rules);

const finalResult = toMarkdown(parsedContent, {
const finalResult = toMarkdown(fixedContent, {
emphasis: '_',
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'fs/promises';
import path from 'path';
import _ from 'lodash';

const extensions = ['.md', '.adoc'];
const extensions = ['.md'];

export const formatMessage = (msg, color = 'dark') => {
if (!clc[color]) {
Expand Down

0 comments on commit f2ab7a0

Please sign in to comment.