Skip to content

Commit

Permalink
fix: upgrade htmlentity version to fix the APIs break changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fefit committed Apr 17, 2023
1 parent d9ec0a6 commit e6c683a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "visdom"
version = "0.5.9"
version = "0.5.10"
edition = "2018"
description = "A html document syntax and operation library, use APIs similar to jquery, easy to use for web scraping and confused html."
keywords = ["html", "scrape", "jquery", "query", "selector"]
Expand All @@ -10,10 +10,10 @@ repository = "https://github.com/fefit/visdom"
documentation = "https://docs.rs/visdom/"
categories = ["web-programming"]
license = "MIT"
exclude = [".vscode/*.*", ".editorconfig", ".travis.yml", "src/main.rs", "performance/*.*"]
exclude = [".vscode/*.*", ".github/*.*", ".editorconfig", "src/main.rs", "performance/*.*"]

[dependencies]
rphtml = "0.5.8"
rphtml = "0.5.9"
lazy_static = "1.4.0"
thiserror = "1.0.24"
regex = "1.7.0"
Expand Down
18 changes: 12 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use mesdoc::utils::is_equal_chars;
use mesdoc::{error::Error as IError, utils::retain_by_index};
use rphtml::{
config::RenderOptions,
entity::{encode, encode_chars, EncodeType, EntitySet},
entity::{encode, encode_char, CharacterSet, EncodeType, ICodedDataTrait},
parser::{
allow_insert, is_content_tag, Attr, AttrData, Doc, DocHolder, NameCase, Node, NodeType, RefNode,
},
Expand Down Expand Up @@ -247,8 +247,12 @@ impl INodeTrait for Rc<RefCell<Node>> {
if !content.is_empty() {
if no_content_tag {
// encode content
let content = encode(content, EntitySet::Html, EncodeType::NamedOrDecimal);
let mut text_node = Node::create_text_node(content, None);
let content = encode(
content.as_bytes(),
&EncodeType::NamedOrDecimal,
&CharacterSet::Html,
);
let mut text_node = Node::create_text_node(content.to_chars().unwrap(), None);
// set text node parent
text_node.parent = Some(Rc::downgrade(self));
// set childs
Expand Down Expand Up @@ -633,9 +637,11 @@ impl IElementTrait for Rc<RefCell<Node>> {
if find_quote {
if quote == ch {
// find more quotes
let mut encoded_quote =
encode_chars(&[ch], EntitySet::SpecialChars, EncodeType::Named);
content.append(&mut encoded_quote);
if let Some(entity) = encode_char(&ch, &EncodeType::Named) {
entity.write_chars(&mut content);
} else {
content.push(ch);
}
} else {
content.push(ch);
}
Expand Down

0 comments on commit e6c683a

Please sign in to comment.