diff options
author | pinkforest(she/her) <36498018+pinkforest@users.noreply.github.com> | 2023-02-10 22:29:28 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-10 12:29:28 +0100 |
commit | 72a8cf99fbd20ab29f4f3c1845c67898cdaff7de (patch) | |
tree | 5adc51e05d48bbf5785c4828a9aea8e91794f0f2 /src | |
parent | 4483d25511704a16756e09698854ef1648a0a77b (diff) | |
download | markdown-rs-72a8cf99fbd20ab29f4f3c1845c67898cdaff7de.tar.gz markdown-rs-72a8cf99fbd20ab29f4f3c1845c67898cdaff7de.tar.bz2 markdown-rs-72a8cf99fbd20ab29f4f3c1845c67898cdaff7de.zip |
Move `log` to optional dependencies
Closes GH-48.
Diffstat (limited to '')
-rw-r--r-- | src/tokenizer.rs | 21 | ||||
-rw-r--r-- | src/util/char.rs | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 346e04e..e463b4b 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -13,7 +13,11 @@ use crate::parser::ParseState; use crate::resolve::{call as call_resolve, Name as ResolveName}; use crate::state::{call, State}; use crate::subtokenize::Subresult; -use crate::util::{char::format_byte_opt, constant::TAB_SIZE, edit_map::EditMap}; + +#[cfg(feature = "log")] +use crate::util::char::format_byte_opt; + +use crate::util::{constant::TAB_SIZE, edit_map::EditMap}; use alloc::{boxed::Box, string::String, vec, vec::Vec}; /// Containers. @@ -405,7 +409,10 @@ impl<'a> Tokenizer<'a> { move_point_back(self, &mut point); let info = (point.index, point.vs); + + #[cfg(feature = "log")] log::debug!("position: define skip: {:?} -> ({:?})", point.line, info); + let at = point.line - self.first_line; if at >= self.column_start.len() { @@ -476,6 +483,8 @@ impl<'a> Tokenizer<'a> { self.line_start = self.point.clone(); self.account_for_potential_skip(); + + #[cfg(feature = "log")] log::debug!("position: after eol: `{:?}`", self.point); } else { self.point.column += 1; @@ -533,7 +542,9 @@ impl<'a> Tokenizer<'a> { move_point_back(self, &mut point); } + #[cfg(feature = "log")] log::debug!("exit: `{:?}`", name); + let event = Event { kind: Kind::Exit, name, @@ -663,7 +674,9 @@ fn enter_impl(tokenizer: &mut Tokenizer, name: Name, link: Option<Link>) { let mut point = tokenizer.point.clone(); move_point_back(tokenizer, &mut point); + #[cfg(feature = "log")] log::debug!("enter: `{:?}`", name); + tokenizer.stack.push(name.clone()); tokenizer.events.push(Event { kind: Kind::Enter, @@ -708,7 +721,9 @@ fn push_impl( attempt.nok }; + #[cfg(feature = "log")] log::debug!("attempt: `{:?}` -> `{:?}`", state, next); + state = next; } else { break; @@ -735,13 +750,17 @@ fn push_impl( None }; + #[cfg(feature = "log")] log::debug!("feed: {} to {:?}", format_byte_opt(byte), name); + tokenizer.expect(byte); state = call(tokenizer, name); }; } State::Retry(name) => { + #[cfg(feature = "log")] log::debug!("retry: `{:?}`", name); + state = call(tokenizer, name); } } diff --git a/src/util/char.rs b/src/util/char.rs index 79cd32e..3ea4500 100644 --- a/src/util/char.rs +++ b/src/util/char.rs @@ -115,6 +115,7 @@ pub fn format_opt(char: Option<char>) -> String { } /// Format an optional `byte` (`none` means eof). +#[cfg(feature = "log")] pub fn format_byte_opt(byte: Option<u8>) -> String { byte.map_or("end of file".into(), |byte| { format!("byte {}", format_byte(byte)) @@ -191,6 +192,7 @@ mod tests { } #[test] + #[cfg(feature = "log")] fn test_format_byte_opt() { assert_eq!( format_byte_opt(None), |