fix(heading): fix unordered list mistakenly identified as level 2 heading

This commit is contained in:
dragonish 2025-05-16 21:55:53 +08:00
parent 026468cba8
commit e2ea114bcd
No known key found for this signature in database
GPG key ID: 6F42FA9E807A5177
2 changed files with 10 additions and 1 deletions

View file

@ -45,7 +45,7 @@ export class Heading {
return -1;
}
if (/^(?:>|[ ]{4,}|\t)/.test(lineText)) {
if (/^(?:>|[ ]{4,}|\t|\s*[-*]\s+)/.test(lineText)) {
return -1;
}

View file

@ -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);
});
});