mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-17 00:04:18 +00:00
fix: remove remaining XFDF migration lint failures
This commit is contained in:
1 file changed
+1
-42
+1
-42
@@ -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 `<contents-richtext>`) 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 `<contents-richtext>`, say; not XFDF's own, which a
|
||||
|
||||
Reference in new issue
Block a user