From f36c6edd86e1c138ec6995e058748b7af532fa56 Mon Sep 17 00:00:00 2001 From: cgm616 Date: Sat, 24 Aug 2024 11:00:36 +0100 Subject: [PATCH] Fix attribute adding to not duplicate attributes Previously, the plugin would add a new attribute to the relevant markdown-it token for each that it encountered. However, if the attribute already existed, this duplicated the attribute. Because of the way that markdown-it reads attributes, the duplicate is essentially ignored. By using `Token.attrSet` instead of `Token.attrPush`, markdown-it will automatically de-duplicate attributes for us. See https://markdown-it.github.io/markdown-it/#Token.attrSet. --- utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.js b/utils.js index b577b81..d4ef67d 100644 --- a/utils.js +++ b/utils.js @@ -123,7 +123,7 @@ exports.addAttrs = function (attrs, token) { } else if (key === 'css-module') { token.attrJoin('css-module', attrs[j][1]); } else { - token.attrPush(attrs[j]); + token.attrSet(key, attrs[j][1]); } } return token;