Skip to content

Commit

Permalink
Merge pull request #163 from jugglerchris/update_html5ever_0.28.0
Browse files Browse the repository at this point in the history
Update html5ever and markup5ever.
Bumps MSRV to 0.72.
  • Loading branch information
jugglerchris authored Aug 18, 2024
2 parents e10dbe2 + c8bedcf commit 0476d71
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ orbs:
jobs:
build-stable:
docker:
- image: cimg/rust:1.73
- image: cimg/rust:1.80.1
steps:
- checkout
- run: cargo --version
Expand All @@ -26,15 +26,15 @@ jobs:
cargo clippy
build-css:
docker:
- image: cimg/rust:1.73
- image: cimg/rust:1.80.1
steps:
- checkout
- run: cargo --version
- run: cargo build --features=css
- run: cargo test --features=css
build-1-63:
build-1-72:
docker:
- image: cimg/rust:1.63
- image: cimg/rust:1.72
steps:
- checkout
- run: cargo --version
Expand Down Expand Up @@ -75,5 +75,5 @@ workflows:
jobs:
- "build-stable"
- "build-css"
- "build-1-63"
- "build-1-72"
- "build-windows"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Possible log types:
- `[fixed]` for any bug fixes.
- `[security]` to invite users to upgrade in case of vulnerabilities.

### Latest

- [changed] Updated html5ever and markup5ever crate versions. This has meant
updating the MSRV, which is now set to 1.72.

### 0.13.0-alpha.1

- [fixed] Table rows with colours would disappear. (thanks tkapias)
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ repository = "https://github.com/jugglerchris/rust-html2text/"
readme = "README.md"
documentation = "https://docs.rs/html2text/"
edition = "2021"
rust-version = "1.63"
rust-version = "1.72"
categories = ["text-processing"]

keywords = ["html", "text"]
license = "MIT"

[dependencies]
html5ever = "0.27.0"
markup5ever = "0.12.0"
html5ever = "0.28.0"
markup5ever = "0.13.0"
tendril = "0.4"
unicode-width = "0.1.5"
backtrace = { version = "0.3", optional=true }
Expand Down
45 changes: 20 additions & 25 deletions src/markup5ever_rcdom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ pub struct RcDom {
pub document: Handle,

/// Errors that occurred during parsing.
pub errors: Vec<Cow<'static, str>>,
pub errors: RefCell<Vec<Cow<'static, str>>>,

/// The document's quirks mode.
pub quirks_mode: QuirksMode,
pub quirks_mode: Cell<QuirksMode>,
}

impl TreeSink for RcDom {
Expand All @@ -225,15 +225,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,
..
Expand All @@ -249,8 +249,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 {
Expand All @@ -264,12 +264,7 @@ impl TreeSink for RcDom {
};
}

fn create_element(
&mut self,
name: QualName,
attrs: Vec<Attribute>,
flags: ElementFlags,
) -> Handle {
fn create_element(&self, name: QualName, attrs: Vec<Attribute>, flags: ElementFlags) -> Handle {
Node::new(NodeData::Element {
name,
attrs: RefCell::new(attrs),
Expand All @@ -282,18 +277,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<Handle>) {
fn append(&self, parent: &Handle, child: NodeOrText<Handle>) {
// Append to an existing Text node if we have one.
if let NodeOrText::AppendText(text) = &child {
if let Some(h) = parent.children.borrow().last() {
Expand All @@ -314,7 +309,7 @@ impl TreeSink for RcDom {
);
}

fn append_before_sibling(&mut self, sibling: &Handle, child: NodeOrText<Handle>) {
fn append_before_sibling(&self, sibling: &Handle, child: NodeOrText<Handle>) {
let (parent, i) = get_parent_and_index(sibling)
.expect("append_before_sibling called on node without parent");

Expand Down Expand Up @@ -350,7 +345,7 @@ impl TreeSink for RcDom {
}

fn append_based_on_parent_node(
&mut self,
&self,
element: &Self::Handle,
prev_element: &Self::Handle,
child: NodeOrText<Self::Handle>,
Expand All @@ -367,7 +362,7 @@ impl TreeSink for RcDom {
}

fn append_doctype_to_document(
&mut self,
&self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril,
Expand All @@ -382,7 +377,7 @@ impl TreeSink for RcDom {
);
}

fn add_attrs_if_missing(&mut self, target: &Handle, attrs: Vec<Attribute>) {
fn add_attrs_if_missing(&self, target: &Handle, attrs: Vec<Attribute>) {
let mut existing = if let NodeData::Element { ref attrs, .. } = target.data {
attrs.borrow_mut()
} else {
Expand All @@ -400,11 +395,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() {
Expand Down Expand Up @@ -434,8 +429,8 @@ impl Default for RcDom {
fn default() -> RcDom {
RcDom {
document: Node::new(NodeData::Document),
errors: vec![],
quirks_mode: tree_builder::NoQuirks,
errors: vec![].into(),
quirks_mode: tree_builder::NoQuirks.into(),
}
}
}
Expand Down

0 comments on commit 0476d71

Please sign in to comment.