From 41afec1ed898159e1df3bc1157768f2066dd85e5 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 1 Jul 2022 15:36:38 +0200 Subject: Make paragraphs really fast The approach that `micromark-js` takes is as follows: to parse a paragraph, check whether each line starts with something else. If it does, exit, otherwise continue. That is slow, because our actual flow parser does similar things: the work was being done twice. To fix this, this commit introduces parsing each line of a paragraph separately. And finally, when done with flow, combining adjacent paragraphs. This same mechanism is reused for setext headings. Additionally, this commit adds support for interrupting things (or not). E.g., HTML (flow, complete) cannot interrupt paragraphs. Definitions cannot interrupt paragraphs, and connect be interrupted either, but they can follow each other. --- tests/html_flow.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests/html_flow.rs') diff --git a/tests/html_flow.rs b/tests/html_flow.rs index 455c5b8..3b69671 100644 --- a/tests/html_flow.rs +++ b/tests/html_flow.rs @@ -21,7 +21,7 @@ fn html_flow() { "should support a heading w/ rank 1" ); - // To do: extensions. + // To do: turning things off. // assert_eq!( // micromark_with_options("", {extensions: [{disable: {null: ["htmlFlow"]}}]}), // "

<x>

", @@ -789,12 +789,11 @@ fn html_flow_7_complete() { "should support interleaving w/ whitespace-only blank lines" ); - // To do: disallow html (complete) from interrupting. - // assert_eq!( - // micromark_with_options("Foo\n\nbaz", DANGER), - // "

Foo\n\nbaz

", - // "should not support interrupting paragraphs w/ complete tags" - // ); + assert_eq!( + micromark_with_options("Foo\n\nbaz", DANGER), + "

Foo\n\nbaz

", + "should not support interrupting paragraphs w/ complete tags" + ); assert_eq!( micromark_with_options("