From ff59ef43d6bd0d0daba9335d80bde1c9f2dcb44f Mon Sep 17 00:00:00 2001 From: Rodney Lab Date: Fri, 9 Aug 2024 04:16:04 +0100 Subject: [PATCH 1/2] =?UTF-8?q?build(dependencies):=20=F0=9F=A7=B1=20updat?= =?UTF-8?q?e=20crates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps serde from 1.0.204 to 1.0.205. Bumps html5ever from 0.27.0 to 0.28.0. --- Cargo.lock | 16 +++++++-------- Cargo.toml | 4 ++-- src/html_process/dom.rs | 45 ++++++++++++++++++----------------------- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7696b37..af0b98d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,9 +126,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "html5ever" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4" +checksum = "0ff6858c1f7e2a470c5403091866fa95b36fe0dbac5d771f932c15e5ff1ee501" dependencies = [ "log", "mac", @@ -212,9 +212,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "markup5ever" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45" +checksum = "d581ff8be69d08a2efa23a959d81aa22b739073f749f067348bd4f4ba4b69195" dependencies = [ "log", "phf", @@ -482,9 +482,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" dependencies = [ "serde_derive", ] @@ -502,9 +502,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 70848b2..8112f26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,12 +22,12 @@ opt-level = "z" aho-corasick = "1.1.2" deunicode = "1.6.0" getrandom = { version = "0.2.15", features = ["js"] } -html5ever = "0.27.0" +html5ever = "0.28.0" js-sys = "0.3.69" mrml = { version = "4.0.1", features = ["parse", "render"], default-features = false } nom = { version = "7.1.3", features = ["alloc"] } pulldown-cmark = "0.9.2" -serde = { version = "1.0", features = ["derive"] } +serde = { version = "1.0.205", features = ["derive"] } serde-wasm-bindgen = "0.6.5" textwrap = "0.16.1" thiserror = "1.0.63" diff --git a/src/html_process/dom.rs b/src/html_process/dom.rs index a803b98..1c163c0 100644 --- a/src/html_process/dom.rs +++ b/src/html_process/dom.rs @@ -149,8 +149,8 @@ fn remove_from_parent(target: &Handle) { #[allow(clippy::module_name_repetitions)] pub struct RcDom { pub document: Handle, - pub errors: Vec>, - pub quirks_mode: QuirksMode, + pub errors: RefCell>>, + pub quirks_mode: Cell, } impl TreeSink for RcDom { @@ -160,15 +160,15 @@ impl TreeSink for RcDom { } type Handle = Handle; - fn parse_error(&mut self, msg: Cow<'static, str>) { - self.errors.push(msg); + fn parse_error(&self, msg: Cow<'static, str>) { + self.errors.borrow_mut().push(msg); } - fn get_document(&mut self) -> Handle { + fn get_document(&self) -> Handle { self.document.clone() } - fn get_template_contents(&mut self, target: &Handle) -> Handle { + fn get_template_contents(&self, target: &Handle) -> Handle { if let NodeData::Element { ref template_contents, .. @@ -184,8 +184,8 @@ impl TreeSink for RcDom { } } - fn set_quirks_mode(&mut self, mode: QuirksMode) { - self.quirks_mode = mode; + fn set_quirks_mode(&self, mode: QuirksMode) { + self.quirks_mode.set(mode); } fn same_node(&self, x: &Handle, y: &Handle) -> bool { @@ -199,12 +199,7 @@ impl TreeSink for RcDom { }; } - fn create_element( - &mut self, - name: QualName, - attrs: Vec, - flags: ElementFlags, - ) -> Handle { + fn create_element(&self, name: QualName, attrs: Vec, flags: ElementFlags) -> Handle { Node::new(NodeData::Element { name, attrs: RefCell::new(attrs), @@ -217,18 +212,18 @@ impl TreeSink for RcDom { }) } - fn create_comment(&mut self, text: StrTendril) -> Handle { + fn create_comment(&self, text: StrTendril) -> Handle { Node::new(NodeData::Comment { contents: text }) } - fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Handle { + fn create_pi(&self, target: StrTendril, data: StrTendril) -> Handle { Node::new(NodeData::ProcessingInstruction { target, contents: data, }) } - fn append(&mut self, parent: &Handle, child: NodeOrText) { + fn append(&self, parent: &Handle, child: NodeOrText) { if let NodeOrText::AppendText(ref text) = child { if let Some(h) = parent.children.borrow().last() { if append_to_existing_text(h, text) { @@ -248,7 +243,7 @@ impl TreeSink for RcDom { ); } - fn append_before_sibling(&mut self, sibling: &Handle, child: NodeOrText) { + fn append_before_sibling(&self, sibling: &Handle, child: NodeOrText) { let (parent, i) = get_parent_and_index(sibling) .expect("append_before_sibling called on node without parent"); @@ -276,7 +271,7 @@ impl TreeSink for RcDom { } fn append_based_on_parent_node( - &mut self, + &self, element: &Self::Handle, prev_element: &Self::Handle, child: NodeOrText, @@ -293,7 +288,7 @@ impl TreeSink for RcDom { } fn append_doctype_to_document( - &mut self, + &self, name: StrTendril, public_id: StrTendril, system_id: StrTendril, @@ -308,7 +303,7 @@ impl TreeSink for RcDom { ); } - fn add_attrs_if_missing(&mut self, target: &Handle, attrs: Vec) { + fn add_attrs_if_missing(&self, target: &Handle, attrs: Vec) { let mut existing = if let NodeData::Element { ref attrs, .. } = target.data { attrs.borrow_mut() } else { @@ -326,11 +321,11 @@ impl TreeSink for RcDom { ); } - fn remove_from_parent(&mut self, target: &Handle) { + fn remove_from_parent(&self, target: &Handle) { remove_from_parent(target); } - fn reparent_children(&mut self, node: &Handle, new_parent: &Handle) { + fn reparent_children(&self, node: &Handle, new_parent: &Handle) { let mut children = node.children.borrow_mut(); let mut new_children = new_parent.children.borrow_mut(); for child in children.iter() { @@ -360,8 +355,8 @@ impl Default for RcDom { fn default() -> RcDom { RcDom { document: Node::new(NodeData::Document), - errors: vec![], - quirks_mode: tree_builder::NoQuirks, + errors: RefCell::default(), + quirks_mode: Cell::new(tree_builder::NoQuirks), } } } From 45017e34bb6466e3b2632c303fb281d41ad013b5 Mon Sep 17 00:00:00 2001 From: Rodney Lab Date: Fri, 9 Aug 2024 04:22:14 +0100 Subject: [PATCH 2/2] =?UTF-8?q?build(deno-dependencies):=20=F0=9F=A7=B1=20?= =?UTF-8?q?update=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deno.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index fd0f0ec..cfbbc5e 100644 --- a/deno.json +++ b/deno.json @@ -3,7 +3,6 @@ "test": "deno test -A", "wasmbuild": "deno run -A jsr:@deno/wasmbuild@0.17.2 --project=parsedown" }, - "imports": { - "@std/assert": "jsr:@std/assert@^1.0.0" - } + "exclude": ["lib/"], + "imports": { "@std/assert": "jsr:@std/assert@^1.0.2" } }