From 5ab7c64e28305bbd8ad0eff7f429bd2f25748081 Mon Sep 17 00:00:00 2001
From: yuin
Date: Sun, 8 Mar 2020 17:55:02 +0900
Subject: [PATCH] Fixes #111
---
_test/extra.txt | 28 ++++++++++++++++++++++++++++
parser/list.go | 29 +++++++++++++++--------------
2 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/_test/extra.txt b/_test/extra.txt
index 5042ee4..2143933 100644
--- a/_test/extra.txt
+++ b/_test/extra.txt
@@ -105,3 +105,31 @@ correctly
//- - - - - - - - -//
daß is the old german spelling of dass
//= = = = = = = = = = = = = = = = = = = = = = = =//
+
+
+
+10
+//- - - - - - - - -//
+1. First step.
+
+ ~~~
+ aaa
+ ---
+ bbb
+ ~~~
+
+2. few other steps.
+//- - - - - - - - -//
+
+-
+
First step.
+aaa
+---
+bbb
+
+
+-
+
few other steps.
+
+
+//= = = = = = = = = = = = = = = = = = = = = = = =//
diff --git a/parser/list.go b/parser/list.go
index b1d53bd..df1607e 100644
--- a/parser/list.go
+++ b/parser/list.go
@@ -166,20 +166,6 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta
}
return Continue | HasChildren
}
- // Thematic Breaks take precedence over lists
- if isThematicBreak(line, reader.LineOffset()) {
- isHeading := false
- last := pc.LastOpenedBlock().Node
- if ast.IsParagraph(last) {
- c, ok := matchesSetextHeadingBar(line)
- if ok && c == '-' {
- isHeading = true
- }
- }
- if !isHeading {
- return Close
- }
- }
// "offset" means a width that bar indicates.
// - aaaaaaaa
@@ -200,6 +186,21 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta
if !list.CanContinue(marker, typ == orderedList) {
return Close
}
+ // Thematic Breaks take precedence over lists
+ if isThematicBreak(line[match[3]-1:], 0) {
+ isHeading := false
+ last := pc.LastOpenedBlock().Node
+ if ast.IsParagraph(last) {
+ c, ok := matchesSetextHeadingBar(line)
+ if ok && c == '-' {
+ isHeading = true
+ }
+ }
+ if !isHeading {
+ return Close
+ }
+ }
+
return Continue | HasChildren
}
}