nanohtml2text

Lightweight html to text converter in Rust
git clone git://git.alexwennerberg.com/nanohtml2text
Log | Files | Refs | LICENSE

commit d3806f8c0d194395e6c9e53d95d280f2a1ff69f8
parent 4ebd7362e770676f37ba8eb65e04f99718b46b98
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Thu,  6 Jan 2022 10:46:10 -0800

Allow unicode URLs

Diffstat:
Msrc/lib.rs | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs @@ -23,12 +23,12 @@ fn parse_link(l: &str) -> Option<&str> { if s.len() > 1 { if s[1] != "" { if s[1].as_bytes()[0] == b'\'' { - let end = s[1][1..].chars().position(|c| c == '\''); + let end = s[1][1..].bytes().position(|c| c == b'\''); if let Some(p) = end { return Some(&s[1][1..=p]); } } else if s[1].as_bytes()[0] == b'"' { - let end = s[1][1..].chars().position(|c| c == '"'); + let end = s[1][1..].bytes().position(|c| c == b'"'); if let Some(p) = end { return Some(&s[1][1..=p]); } @@ -89,7 +89,7 @@ fn parse_html_entity(ent_name: &str) -> Option<char> { fn html_entitities_to_text(s: &str) -> String { let mut out = String::new(); let mut in_ent = false; - for (i, r) in s.chars().enumerate() { + for (i, r) in s.char_indices() { if r == ';' && in_ent { in_ent = false; continue;