From 25254cb8f7021cbffff3c67cd5aaf98a66c107ab Mon Sep 17 00:00:00 2001 From: sup39 Date: Mon, 7 Feb 2022 00:59:11 +0900 Subject: [PATCH] [v1.2.2] fix inline attr fix utils/findOpenToken() --- lib/utils.js | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) 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",