Skip to content

Commit ec40e98

Browse files
authored
Merge pull request #265 from jugglerchris/update_edition_2024
Changes for 0.16.7
2 parents 401d944 + 028ce0d commit ec40e98

11 files changed

Lines changed: 87 additions & 99 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Possible log types:
99
- `[fixed]` for any bug fixes.
1010
- `[security]` to invite users to upgrade in case of vulnerabilities.
1111

12+
### 0.16.7
13+
14+
- [added] Support `<b>` tags as bold (thanks amir)
15+
- [changed] Update html5ever to 0.38.0 (thanks mtorromeo)
16+
1217
### 0.16.6
1318

1419
- [changed] Update html5ever and tendril dependencies.

Cargo.lock

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[package]
22
name = "html2text"
3-
version = "0.16.6"
3+
version = "0.16.7"
44
authors = ["Chris Emerson <github@mail.nosreme.org>"]
55
description = "Render HTML as plain text."
66
repository = "https://github.com/jugglerchris/rust-html2text/"
77
readme = "README.md"
88
documentation = "https://docs.rs/html2text/"
9-
edition = "2021"
9+
edition = "2024"
1010
rust-version = "1.85"
1111
categories = ["text-processing"]
1212

1313
keywords = ["html", "text"]
1414
license = "MIT"
1515

1616
[dependencies]
17-
html5ever = "0.37.1"
17+
html5ever = "0.38.0"
1818
tendril = "0.5"
1919
unicode-width = "0.2"
2020
backtrace = { version = "0.3", optional=true }

examples/html2text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn default_colour_map(
1616
use_css_colours: bool,
1717
no_default_colours: bool,
1818
) -> String {
19-
use termion::color::*;
2019
use RichAnnotation::*;
20+
use termion::color::*;
2121
// Explicit CSS colours override any other colours
2222
let mut have_explicit_colour = no_default_colours;
2323
let mut start = Vec::new();

src/css.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use parser::parse_style_attribute;
1414
use types::Importance;
1515

1616
use crate::{
17+
ComputedStyle, Specificity, StyleOrigin,
1718
markup5ever_rcdom::{
1819
Handle,
1920
NodeData::{self, Comment, Document, Element},
2021
},
21-
ComputedStyle, Specificity, StyleOrigin,
2222
};
2323

2424
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -179,25 +179,22 @@ impl Selector {
179179
_ => false,
180180
},
181181
SelectorComponent::Star => Self::do_matches(&comps[1..], node),
182-
SelectorComponent::CombChild => {
183-
if let Some(parent) = node.get_parent() {
184-
Self::do_matches(&comps[1..], &parent)
185-
} else {
186-
false
187-
}
188-
}
189-
SelectorComponent::CombDescendant => {
190-
if let Some(parent) = node.get_parent() {
182+
SelectorComponent::CombChild => match node.get_parent() {
183+
Some(parent) => Self::do_matches(&comps[1..], &parent),
184+
_ => false,
185+
},
186+
SelectorComponent::CombDescendant => match node.get_parent() {
187+
Some(parent) => {
191188
Self::do_matches(&comps[1..], &parent) || Self::do_matches(comps, &parent)
192-
} else {
193-
false
194189
}
195-
}
190+
_ => false,
191+
},
196192
SelectorComponent::NthChild { a, b, sel } => {
197-
let parent = if let Some(parent) = node.get_parent() {
198-
parent
199-
} else {
200-
return false;
193+
let parent = match node.get_parent() {
194+
Some(parent) => parent,
195+
_ => {
196+
return false;
197+
}
201198
};
202199
let mut idx = 0i32;
203200
for child in parent.children.borrow().iter() {
@@ -724,11 +721,12 @@ pub(crate) mod dom_extract {
724721
use crate::{expanded_name, local_name, ns};
725722

726723
use crate::{
724+
Result, TreeMapResult,
727725
markup5ever_rcdom::{
728726
Handle,
729727
NodeData::{self, Comment, Document, Element},
730728
},
731-
tree_map_reduce, Result, TreeMapResult,
729+
tree_map_reduce,
732730
};
733731

734732
use super::StyleData;

src/css/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use std::{borrow::Cow, ops::Deref, str::FromStr};
44

55
use nom::{
6+
AsChar, IResult, Parser,
67
branch::alt,
78
bytes::complete::{tag, take_until},
89
character::complete::{self, digit0, digit1},
910
combinator::{fail, map, opt, recognize},
1011
error::ErrorKind,
1112
multi::{many0, many1, separated_list0},
12-
AsChar, IResult, Parser,
1313
};
1414

1515
#[derive(Debug, PartialEq)]
@@ -175,7 +175,7 @@ pub(crate) struct Declaration {
175175

176176
use crate::css::styles_from_properties;
177177

178-
use super::{types::Importance, PseudoElement, Selector, SelectorComponent, StyleDecl, WhiteSpace};
178+
use super::{PseudoElement, Selector, SelectorComponent, StyleDecl, WhiteSpace, types::Importance};
179179

180180
#[derive(Debug, PartialEq)]
181181
pub(crate) struct RuleSet {
@@ -1161,8 +1161,8 @@ pub(crate) fn parse_style_attribute(text: &str) -> crate::Result<Vec<StyleDecl>>
11611161
#[cfg(test)]
11621162
mod test {
11631163
use crate::css::{
1164-
parser::{Height, Importance, LengthUnit, RuleSet, Selector},
11651164
AttrOperator, PseudoElement, SelectorComponent,
1165+
parser::{Height, Importance, LengthUnit, RuleSet, Selector},
11661166
};
11671167

11681168
use super::{Colour, Decl, Declaration, Overflow, PropertyName};

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ impl RenderTableRow {
522522
}
523523
/// Return an iterator which returns cells by values (removing
524524
/// them from the row).
525-
fn cells_drain(&mut self) -> impl Iterator<Item = RenderTableCell> {
525+
fn cells_drain(&mut self) -> impl Iterator<Item = RenderTableCell> + use<> {
526526
std::mem::take(&mut self.cells).into_iter()
527527
}
528528
/// Count the number of cells in the row.
@@ -2858,15 +2858,15 @@ pub mod config {
28582858
use super::Error;
28592859
use crate::css::types::Importance;
28602860
use crate::css::{Ruleset, Selector, SelectorComponent, Style, StyleData};
2861+
#[cfg(feature = "css_ext")]
2862+
use crate::{HighlighterMap, SyntaxHighlighter};
28612863
use crate::{
2864+
HtmlContext, MIN_WIDTH, RenderTree, Result,
28622865
css::{PseudoContent, PseudoElement, StyleDecl},
28632866
render::text_renderer::{
28642867
PlainDecorator, RichAnnotation, RichDecorator, TaggedLine, TextDecorator,
28652868
},
2866-
HtmlContext, RenderTree, Result, MIN_WIDTH,
28672869
};
2868-
#[cfg(feature = "css_ext")]
2869-
use crate::{HighlighterMap, SyntaxHighlighter};
28702870

28712871
/// Specify how images with missing or empty alt text are handled
28722872
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]

src/macros.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ macro_rules! html_trace {
4040
#[macro_export]
4141
#[doc(hidden)]
4242
macro_rules! html_trace {
43-
($fmt:expr) => {
43+
($fmt:expr_2021) => {
4444
$crate::macros::nop();
4545
};
46-
($fmt:expr, $( $args:expr ),*) => {
46+
($fmt:expr_2021, $( $args:expr_2021 ),*) => {
4747
$crate::macros::nop();
4848
};
4949
}
@@ -64,10 +64,10 @@ macro_rules! html_trace_quiet {
6464
#[macro_export]
6565
#[doc(hidden)]
6666
macro_rules! html_trace_quiet {
67-
($fmt:expr) => {
67+
($fmt:expr_2021) => {
6868
$crate::macros::nop();
6969
};
70-
($fmt:expr, $( $args:expr ),*) => {
70+
($fmt:expr_2021, $( $args:expr_2021 ),*) => {
7171
$crate::macros::nop();
7272
};
7373
}

0 commit comments

Comments
 (0)