diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-06-20 18:53:38 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-06-20 18:53:38 +0200 |
commit | 182467c1d393dee2081ff80f1c049cb145f23123 (patch) | |
tree | 9ce529c815faab2db1f96b0820a78049b7633a8a /src/tokenizer.rs | |
parent | ef5f9a97493fe4a616b49a744d5a571a99ead8e9 (diff) | |
download | markdown-rs-182467c1d393dee2081ff80f1c049cb145f23123.tar.gz markdown-rs-182467c1d393dee2081ff80f1c049cb145f23123.tar.bz2 markdown-rs-182467c1d393dee2081ff80f1c049cb145f23123.zip |
Add support for BOM
Diffstat (limited to '')
-rw-r--r-- | src/tokenizer.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs index d31c8c5..c0a7105 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -680,10 +680,20 @@ fn attempt_impl( // To do: handle BOM at start? pub fn as_codes(value: &str) -> Vec<Code> { let mut codes: Vec<Code> = vec![]; + let mut at_start = true; let mut at_carriage_return = false; let mut column = 1; for char in value.chars() { + if at_start { + if char == '\u{feff}' { + // Ignore. + continue; + } + + at_start = false; + } + // Send a CRLF. if at_carriage_return && '\n' == char { at_carriage_return = false; |