diff --git a/src/index.js b/src/index.js index d70ed97..f4386e1 100644 --- a/src/index.js +++ b/src/index.js @@ -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 ''; @@ -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); @@ -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: '_', }); diff --git a/src/utils.js b/src/utils.js index 81c6c72..d3a8022 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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]) {