Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

## [Unreleased]
- Decode character references above U+FFFF, such as `😀` or `𝔄`, to the right character instead of a truncated one, and replace `�`, surrogates and out of range numeric references with U+FFFD as required by CommonMark
- Parse an ATX heading followed by `---` or `===` as a heading, not as setext content (IJPL-94630)

## [0.7.18]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class SetextHeaderProvider : MarkerBlockProvider<MarkerProcessor.StateInfo> {
if (stateInfo.nextConstraints != currentConstaints) {
return emptyList()
}
// An ATX heading can't be the content of a setext heading
if (ATX_HEADER_PROVIDER.interruptsParagraph(pos, currentConstaints)) {
return emptyList()
}
if (MarkerBlockProvider.isStartOfLineWithConstraints(pos, currentConstaints)
&& getNextLineFromConstraints(pos, currentConstaints)?.let { REGEX.matches(it) } == true) {
return listOf(SetextHeaderMarkerBlock(currentConstaints, productionHolder))
Expand Down Expand Up @@ -50,5 +54,7 @@ class SetextHeaderProvider : MarkerBlockProvider<MarkerProcessor.StateInfo> {

companion object {
val REGEX: Regex = Regex("^ {0,3}(-+|=+) *$")

private val ATX_HEADER_PROVIDER = AtxHeaderProvider()
}
}
4 changes: 4 additions & 0 deletions src/fileBasedTest/resources/data/parser/hruleAndSetext.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
***
---
___
# atx
---
# atx
===
17 changes: 17 additions & 0 deletions src/fileBasedTest/resources/data/parser/hruleAndSetext.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ Markdown:MARKDOWN_FILE
Markdown:HORIZONTAL_RULE('---')
Markdown:EOL('\n')
Markdown:HORIZONTAL_RULE('___')
Markdown:EOL('\n')
Markdown:ATX_1
Markdown:ATX_HEADER('#')
Markdown:ATX_CONTENT
WHITE_SPACE(' ')
Markdown:TEXT('atx')
Markdown:EOL('\n')
Markdown:HORIZONTAL_RULE('---')
Markdown:EOL('\n')
Markdown:ATX_1
Markdown:ATX_HEADER('#')
Markdown:ATX_CONTENT
WHITE_SPACE(' ')
Markdown:TEXT('atx')
Markdown:EOL('\n')
Markdown:PARAGRAPH
Markdown:TEXT('===')
Markdown:EOL('\n')
Loading