diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-01 15:36:38 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-01 15:39:01 +0200 |
commit | 41afec1ed898159e1df3bc1157768f2066dd85e5 (patch) | |
tree | d497994301b93c49116993198ef8824f6ce68b85 /src/tokenizer.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-- | src/tokenizer.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 817c1de..b70e706 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -1760,6 +1760,8 @@ pub struct Tokenizer<'a> { /// To do. pub label_start_list_loose: Vec<LabelStart>, /// To do. + pub interrupt: bool, + /// To do. pub media_list: Vec<Media>, /// To do. resolvers: Vec<Box<Resolver>>, @@ -1783,6 +1785,7 @@ impl<'a> Tokenizer<'a> { label_start_stack: vec![], label_start_list_loose: vec![], media_list: vec![], + interrupt: false, resolvers: vec![], resolver_ids: vec![], } |