Skip to content

Commit

Permalink
generic error handling if transform fails
Browse files Browse the repository at this point in the history
  • Loading branch information
arve0 committed Dec 23, 2024
1 parent 3b7a6a4 commit 501eec1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ module.exports = function attributes(md, options_) {
return res.match;
});
if (match) {
pattern.transform(tokens, i, j);
if (pattern.name === 'inline attributes' || pattern.name === 'inline nesting 0') {
// retry, may be several inline attributes
p--;
try {
pattern.transform(tokens, i, j);
if (pattern.name === 'inline attributes' || pattern.name === 'inline nesting 0') {
// retry, may be several inline attributes
p--;
}
} catch (error) {
// eslint-disable-next-line no-console
console.error(`markdown-it-attrs: Error in pattern '${pattern.name}': ${error.message}`);
console.error(error.stack);
}
}
}
Expand Down

0 comments on commit 501eec1

Please sign in to comment.