From e2ea114bcdfe2ded0e29b76becc2590aee294fbe Mon Sep 17 00:00:00 2001 From: dragonish Date: Fri, 16 May 2025 21:55:53 +0800 Subject: [PATCH] fix(heading): fix unordered list mistakenly identified as level 2 heading --- common/heading.ts | 2 +- test/common/heading.spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/heading.ts b/common/heading.ts index c2089c8..184be4e 100644 --- a/common/heading.ts +++ b/common/heading.ts @@ -45,7 +45,7 @@ export class Heading { return -1; } - if (/^(?:>|[ ]{4,}|\t)/.test(lineText)) { + if (/^(?:>|[ ]{4,}|\t|\s*[-*]\s+)/.test(lineText)) { return -1; } diff --git a/test/common/heading.spec.ts b/test/common/heading.spec.ts index dc4ccc9..d7665d5 100644 --- a/test/common/heading.spec.ts +++ b/test/common/heading.spec.ts @@ -127,5 +127,14 @@ describe("common/heading", function () { expect(heading5.handler(4, "==")).to.equal(-1); expect(heading5.handler(5, " This is a heading 1", "==")).to.equal(-1); expect(heading5.handler(6, "==")).to.equal(-1); + + const heading6 = new Heading(); + expect(heading6.handler(1, "- item a", "\t- item b")).to.equal(-1); + expect(heading6.handler(2, "\t- item b", "- item c")).to.equal(-1); + expect(heading6.handler(3, "- item c", "-")).to.equal(-1); + expect(heading6.handler(4, "-", "")).to.equal(-1); + expect(heading6.handler(5, "", "Heading 2")).to.equal(-1); + expect(heading6.handler(6, "Heading 2", "-")).to.equal(2); + expect(heading6.handler(7, "-", "")).to.equal(-1); }); });