diff options
author | 2022-07-01 15:36:38 +0200 | |
---|---|---|
committer | 2022-07-01 15:39:01 +0200 | |
commit | 41afec1ed898159e1df3bc1157768f2066dd85e5 (patch) | |
tree | d497994301b93c49116993198ef8824f6ce68b85 /tests/definition.rs | |
parent | 09fd0321daae69d52532b4bef762a202efe9a12e (diff) | |
download | markdown-rs-41afec1ed898159e1df3bc1157768f2066dd85e5.tar.gz markdown-rs-41afec1ed898159e1df3bc1157768f2066dd85e5.tar.bz2 markdown-rs-41afec1ed898159e1df3bc1157768f2066dd85e5.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | tests/definition.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/definition.rs b/tests/definition.rs index ba4e384..df99f74 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -375,12 +375,11 @@ fn definition() { "should not support a final (unbalanced) right paren in a raw destination “before” a title" ); - // To do: do not let code (indented) interrupt definitions. - // assert_eq!( - // micromark(" [a]: b \"c\"\n [d]: e\n [f]: g \"h\"\n [i]: j\n\t[k]: l (m)\n\t n [k] o"), - // "<p>n <a href=\"l\" title=\"m\">k</a> o</p>", - // "should support subsequent indented definitions" - // ); + assert_eq!( + micromark(" [a]: b \"c\"\n [d]: e\n [f]: g \"h\"\n [i]: j\n\t[k]: l (m)\n\t n [k] o"), + "<p>n <a href=\"l\" title=\"m\">k</a> o</p>", + "should support subsequent indented definitions" + ); assert_eq!( micromark("[a\n b]: c\n\n[a\n b]"), @@ -406,7 +405,7 @@ fn definition() { "should not support definitions w/ text + a closing paren as a raw destination" ); - // To do: support turning off things. + // To do: turning things off. // assert_eq!( // micromark("[foo]: /url \"title\"", { // extensions: [{disable: {null: ["definition"]}}] |