diff --git a/lib/index.js b/lib/index.js index f9acbc9..69bdace 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,7 +64,7 @@ export default function rehypeHighlight(options = {}) { name = pos > -1 ? prefix.slice(0, pos) : prefix } - return (tree) => { + return (tree, file) => { // eslint-disable-next-line complexity visit(tree, 'element', (node, _, givenParent) => { const parent = /** @type {Node?} */ (givenParent) @@ -108,7 +108,7 @@ export default function rehypeHighlight(options = {}) { } catch (error) { const exception = /** @type {Error} */ (error) if (!ignoreMissing || !/Unknown language/.test(exception.message)) { - throw error + file.fail(exception, node, 'rehype-highlight:missing-language') } return