aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/construct/list.rs24
-rw-r--r--tests/heading_setext.rs11
-rw-r--r--tests/misc_tabs.rs24
-rw-r--r--tests/thematic_break.rs55
4 files changed, 59 insertions, 55 deletions
diff --git a/src/construct/list.rs b/src/construct/list.rs
index b4ae9b1..b81a5cc 100644
--- a/src/construct/list.rs
+++ b/src/construct/list.rs
@@ -3,6 +3,7 @@
use crate::constant::{LIST_ITEM_VALUE_SIZE_MAX, TAB_SIZE};
use crate::construct::{
blank_line::start as blank_line, partial_space_or_tab::space_or_tab_min_max,
+ thematic_break::start as thematic_break,
};
use crate::token::Token;
use crate::tokenizer::{Code, Event, EventType, State, StateFnResult, Tokenizer};
@@ -106,12 +107,10 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
fn before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
match code {
// Unordered.
- Code::Char('*' | '+' | '-') => {
- // To do: check if this is a thematic break?
- tokenizer.enter(Token::ListItem);
- tokenizer.enter(Token::ListItemPrefix);
- marker(tokenizer, code)
- }
+ Code::Char('*' | '+' | '-') => tokenizer.check(thematic_break, |ok| {
+ let func = if ok { nok } else { before_unordered };
+ Box::new(func)
+ })(tokenizer, code),
// Ordered.
Code::Char(char) if char.is_ascii_digit() => {
tokenizer.enter(Token::ListItem);
@@ -125,6 +124,19 @@ fn before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
}
/// To do.
+fn nok(_tokenizer: &mut Tokenizer, _code: Code) -> StateFnResult {
+ (State::Nok, None)
+}
+
+/// To do.
+fn before_unordered(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
+ // To do: check if this is a thematic break?
+ tokenizer.enter(Token::ListItem);
+ tokenizer.enter(Token::ListItemPrefix);
+ marker(tokenizer, code)
+}
+
+/// To do.
fn inside(tokenizer: &mut Tokenizer, code: Code, mut size: usize) -> StateFnResult {
size += 1;
match code {
diff --git a/tests/heading_setext.rs b/tests/heading_setext.rs
index 4e2a046..8d4a5b7 100644
--- a/tests/heading_setext.rs
+++ b/tests/heading_setext.rs
@@ -213,12 +213,11 @@ fn heading_setext() {
"paragraph and heading interplay (3)"
);
- // To do: list (prefer thematic break).
- // assert_eq!(
- // micromark("Foo\nbar\n* * *\nbaz"),
- // "<p>Foo\nbar</p>\n<hr />\n<p>baz</p>",
- // "paragraph and heading interplay (4)"
- // );
+ assert_eq!(
+ micromark("Foo\nbar\n* * *\nbaz"),
+ "<p>Foo\nbar</p>\n<hr />\n<p>baz</p>",
+ "paragraph and heading interplay (4)"
+ );
assert_eq!(
micromark("Foo\nbar\n\\---\nbaz"),
diff --git a/tests/misc_tabs.rs b/tests/misc_tabs.rs
index e7aad07..e82738d 100644
--- a/tests/misc_tabs.rs
+++ b/tests/misc_tabs.rs
@@ -123,19 +123,17 @@ fn tabs_flow() {
"should support tabs in HTML (if whitespace is allowed)"
);
- // To do: list (prefer thematic break).
- // assert_eq!(
- // micromark("*\t*\t*\t"),
- // "<hr />",
- // "should support tabs in thematic breaks"
- // );
-
- // To do: list (prefer thematic break).
- // assert_eq!(
- // micromark("*\t\t*\t\t*\t\t"),
- // "<hr />",
- // "should support arbitrary tabs in thematic breaks"
- // );
+ assert_eq!(
+ micromark("*\t*\t*\t"),
+ "<hr />",
+ "should support tabs in thematic breaks"
+ );
+
+ assert_eq!(
+ micromark("*\t\t*\t\t*\t\t"),
+ "<hr />",
+ "should support arbitrary tabs in thematic breaks"
+ );
}
#[test]
diff --git a/tests/thematic_break.rs b/tests/thematic_break.rs
index 02be90f..0cedada 100644
--- a/tests/thematic_break.rs
+++ b/tests/thematic_break.rs
@@ -75,12 +75,11 @@ fn thematic_break() {
"should support thematic breaks w/ many markers"
);
- // To do: list (should prefer thematic break).
- // assert_eq!(
- // micromark(" - - -"),
- // "<hr />",
- // "should support thematic breaks w/ spaces (1)"
- // );
+ assert_eq!(
+ micromark(" - - -"),
+ "<hr />",
+ "should support thematic breaks w/ spaces (1)"
+ );
assert_eq!(
micromark(" ** * ** * ** * **"),
@@ -88,19 +87,17 @@ fn thematic_break() {
"should support thematic breaks w/ spaces (2)"
);
- // To do: list (prefer thematic break).
- // assert_eq!(
- // micromark("- - - -"),
- // "<hr />",
- // "should support thematic breaks w/ spaces (3)"
- // );
+ assert_eq!(
+ micromark("- - - -"),
+ "<hr />",
+ "should support thematic breaks w/ spaces (3)"
+ );
- // To do: list (prefer thematic break).
- // assert_eq!(
- // micromark("- - - - "),
- // "<hr />",
- // "should support thematic breaks w/ trailing spaces"
- // );
+ assert_eq!(
+ micromark("- - - - "),
+ "<hr />",
+ "should support thematic breaks w/ trailing spaces"
+ );
assert_eq!(
micromark("_ _ _ _ a"),
@@ -132,12 +129,11 @@ fn thematic_break() {
"should support thematic breaks mixed w/ lists (1)"
);
- // To do: list (prefer thematic break).
- // assert_eq!(
- // micromark("* Foo\n* * *\n* Bar"),
- // "<ul>\n<li>Foo</li>\n</ul>\n<hr />\n<ul>\n<li>Bar</li>\n</ul>",
- // "should support thematic breaks mixed w/ lists (2)"
- // );
+ assert_eq!(
+ micromark("* Foo\n* * *\n* Bar"),
+ "<ul>\n<li>Foo</li>\n</ul>\n<hr />\n<ul>\n<li>Bar</li>\n</ul>",
+ "should support thematic breaks mixed w/ lists (2)"
+ );
assert_eq!(
micromark("Foo\n***\nbar"),
@@ -151,12 +147,11 @@ fn thematic_break() {
"should not support thematic breaks w/ dashes interrupting paragraphs (setext heading)"
);
- // To do: list (prefer thematic break).
- // assert_eq!(
- // micromark("- Foo\n- * * *"),
- // "<ul>\n<li>Foo</li>\n<li>\n<hr />\n</li>\n</ul>",
- // "should support thematic breaks in lists"
- // );
+ assert_eq!(
+ micromark("- Foo\n- * * *"),
+ "<ul>\n<li>Foo</li>\n<li>\n<hr />\n</li>\n</ul>",
+ "should support thematic breaks in lists"
+ );
assert_eq!(
micromark("> ---\na"),