diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-15 18:22:57 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-15 18:22:57 +0200 |
commit | b0a2ce50ecb1a1531b2f7dc4591c9809bb23ed55 (patch) | |
tree | 6ee61075a1d0700fc694d257ed1c7fd4c63db5d2 /src/construct/character_reference.rs | |
parent | 437d3f8bd5633194406fb70b3567bfeb76f18ea5 (diff) | |
download | markdown-rs-b0a2ce50ecb1a1531b2f7dc4591c9809bb23ed55.tar.gz markdown-rs-b0a2ce50ecb1a1531b2f7dc4591c9809bb23ed55.tar.bz2 markdown-rs-b0a2ce50ecb1a1531b2f7dc4591c9809bb23ed55.zip |
Fix to use single array for character references
Diffstat (limited to 'src/construct/character_reference.rs')
-rw-r--r-- | src/construct/character_reference.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/construct/character_reference.rs b/src/construct/character_reference.rs index 04e89d2..4f2505d 100644 --- a/src/construct/character_reference.rs +++ b/src/construct/character_reference.rs @@ -62,8 +62,8 @@ //! [html]: https://html.spec.whatwg.org/multipage/parsing.html#character-reference-state use crate::constant::{ - CHARACTER_REFERENCE_DECIMAL_SIZE_MAX, CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX, - CHARACTER_REFERENCE_NAMED_SIZE_MAX, CHARACTER_REFERENCE_NAMES, + CHARACTER_REFERENCES, CHARACTER_REFERENCE_DECIMAL_SIZE_MAX, + CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX, CHARACTER_REFERENCE_NAMED_SIZE_MAX, }; use crate::token::Token; use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; @@ -189,10 +189,12 @@ fn numeric(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResu fn value(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult { match code { Code::Char(';') if !info.buffer.is_empty() => { - if Kind::Named == info.kind - && !CHARACTER_REFERENCE_NAMES - .contains(&info.buffer.iter().collect::<String>().as_str()) - { + let unknown_named = Kind::Named == info.kind && { + let value = info.buffer.iter().collect::<String>(); + !CHARACTER_REFERENCES.iter().any(|d| d.0 == value) + }; + + if unknown_named { (State::Nok, None) } else { tokenizer.exit(Token::CharacterReferenceValue); |