aboutsummaryrefslogtreecommitdiffstats
path: root/src/tokenizer.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-11 14:53:45 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-11 15:04:32 +0200
commitb7bd2b734fae09c40d738fcd57d5ee6876f0f504 (patch)
treeea3b7dc9b6e668823323187dbe2f2030d6965905 /src/tokenizer.rs
parent8e78fc8f209d20e8f9a76321fcbebf77fa4c57fc (diff)
downloadmarkdown-rs-b7bd2b734fae09c40d738fcd57d5ee6876f0f504.tar.gz
markdown-rs-b7bd2b734fae09c40d738fcd57d5ee6876f0f504.tar.bz2
markdown-rs-b7bd2b734fae09c40d738fcd57d5ee6876f0f504.zip
Fix block quote bugs
Diffstat (limited to 'src/tokenizer.rs')
-rw-r--r--src/tokenizer.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index c984a75..80786ea 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -247,8 +247,10 @@ impl<'a> Tokenizer<'a> {
}
/// Prepare for a next code to get consumed.
- fn expect(&mut self, code: Code) {
- assert!(self.consumed, "expected previous character to be consumed");
+ pub fn expect(&mut self, code: Code, force: bool) {
+ if !force {
+ assert!(self.consumed, "expected previous character to be consumed");
+ }
self.consumed = false;
self.current = code;
}
@@ -609,7 +611,6 @@ fn attempt_impl(
// Should it be before?
// How to match `eof`?
if !codes.is_empty() && pause(tokenizer.previous) {
- tokenizer.consumed = true;
println!("pause!: {:?}", (codes.clone(), vec![code]));
return done(
(codes, vec![code]),
@@ -674,7 +675,7 @@ fn feed_impl(
}
State::Fn(func) => {
log::debug!("main: passing `{:?}`", code);
- tokenizer.expect(code);
+ tokenizer.expect(code, false);
let (next, remainder) = check_statefn_result(func(tokenizer, code));
state = next;
index = index + 1
@@ -706,7 +707,7 @@ fn flush_impl(
State::Fn(func) => {
let code = Code::None;
log::debug!("main: passing eof");
- tokenizer.expect(code);
+ tokenizer.expect(code, false);
let (next, remainder) = check_statefn_result(func(tokenizer, code));
assert!(remainder.is_none(), "expected no remainder");
state = next;