diff --git a/lib/utils.js b/lib/utils.js index f26a66a..27dcf2a 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -41,10 +41,12 @@ function parseAttrs(s, re, limit=65536) { function findOpenToken(tokens, i) { const tokenC = tokens[i]; if (!tokenC) return null; - const {level} = tokenC; + let dlevel = 0; for (i--; i>=0; i--) { const token = tokens[i]; - if (token.level === level) return token; + const {nesting} = token; + if (nesting === 1 && dlevel === 0) return token; + dlevel += nesting; } return null; } diff --git a/package.json b/package.json index 4d71442..00c27d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sup39/markdown-it-attr", - "version": "1.2.1", + "version": "1.2.2", "description": "A markdown-it plugin to write id, classes, and attributes", "keywords": [ "markdown",