diff --git a/crates/xfdf/src/xfdf.rs b/crates/xfdf/src/xfdf.rs index 82fc27b565..720e5bb9be 100644 --- a/crates/xfdf/src/xfdf.rs +++ b/crates/xfdf/src/xfdf.rs @@ -316,9 +316,7 @@ fn walk_rich_plain(node: &craft_xml::El, out: &mut String) { for n in &node.children { match n { craft_xml::Node::El(el) => { - if el.local() == "br" { - out.push('\r'); - } else if matches!(el.local(), "p" | "div" | "li") && !out.is_empty() && !out.ends_with('\r') { + if el.local() == "br" || (matches!(el.local(), "p" | "div" | "li") && !out.is_empty() && !out.ends_with('\r')) { out.push('\r'); } walk_rich_plain(el, out); @@ -1023,45 +1021,6 @@ fn read_rich_text(rich: &craft_xml::El, ns: &[(String, String)], has_contents: b } } -/// Whether start tag `tag` (from `<` up to its closing `>`) declares attribute `name` (white -/// space may come before the `=`). Attribute values are skipped: `title=" xmlns:b='x'"` declares -/// nothing. -fn declares(tag: &str, name: &str) -> bool { - let mut quote = None; - let mut after_space = false; - for (i, c) in tag.char_indices() { - if let Some(q) = quote { - if c == q { - quote = None; - } - continue; - } - if c == '"' || c == '\'' { - quote = Some(c); - } else if after_space && tag.get(i..).and_then(|rest| rest.strip_prefix(name)).is_some_and(|a| a.trim_start().starts_with('=')) { - return true; - } - after_space = c.is_whitespace(); - } - false -} - -/// Where the start tag at the beginning of `markup` ends: its first `>` outside an attribute -/// value (the end of `markup` when there is none). -fn start_tag_end(markup: &str) -> usize { - let mut quote = None; - for (i, c) in markup.char_indices() { - match quote { - Some(q) if c == q => quote = None, - Some(_) => {} - None if c == '"' || c == '\'' => quote = Some(c), - None if c == '>' => return i, - None => {} - } - } - markup.len() -} - /// The one element `markup` (cut out of `rich`, a ``) as an XML /// document of its own: the namespaces it inherits from the XFDF around it are declared on it, /// the default one (XHTML declared on ``, say; not XFDF's own, which a