Skip to content

Commit c46f2c0

Browse files
committed
fix: horizontal line lexed as table header
1 parent 6c7bdb1 commit c46f2c0

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

quarkdown-core/src/main/kotlin/com/quarkdown/core/lexer/patterns/BaseMarkdownBlockTokenRegexPatterns.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ open class BaseMarkdownBlockTokenRegexPatterns {
244244
// Header
245245
"^ *([^\\n ].*)\\n" +
246246
// Align
247-
" {0,3}((?:\\|?\\s*:?-+:?\\s*)+\\|?)\\n" +
247+
" {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)" +
248248
// Cells
249-
"((?:[^\\n]*\\S[^\\n]*\\n?)*)",
249+
"(?:\\n((?:(?! *\\n|interruption).*(?:\\n|$))*)\\n*|$)",
250250
).withReference("interruption", interruptionRule(includeTable = false).pattern)
251251
.withReference("|table", "")
252252
.build(),

quarkdown-core/src/test/kotlin/com/quarkdown/core/BlockParserTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class BlockParserTest {
245245
@Test
246246
fun horizontalRule() {
247247
val nodes = blocksIterator<HorizontalRule>(readSource("/parsing/hr.md"), assertType = false)
248-
assertEquals(6, nodes.asSequence().count())
248+
assertEquals(7, nodes.asSequence().count())
249249
}
250250

251251
@Test

quarkdown-core/src/test/resources/parsing/hr.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ _
2020

2121
===
2222

23-
--- A
23+
--- A
24+
25+
X
26+
27+
---
28+
29+
Y

0 commit comments

Comments
 (0)