Skip to content

Commit 0ec601f

Browse files
committed
Remove fn parse() from public API and replace with pub fn do_parse() method on Config
The parse function is an odd one in the current API, other functions can be separated cleanly into functions that are convenient and functions that need to be configured. The parse function does not advertise what configuration it uses, and will silently drop css information, as it parses with config::plain() as default configuration. This can lead to the following misuse of the public API let render_tree = parse(html)?; customcfg.render_to_string(render_tree, 80)?;
1 parent e9786ac commit 0ec601f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,8 +2370,9 @@ pub mod config {
23702370
wrap_links: self.wrap_links,
23712371
}
23722372
}
2373-
/// Parse with context.
2374-
pub(crate) fn do_parse<R: io::Read>(&self, input: R) -> Result<RenderTree> {
2373+
2374+
/// Reads and parses HTML from `input` and prepares a render tree.
2375+
pub fn do_parse<R: io::Read>(&self, input: R) -> Result<RenderTree> {
23752376
let doc = self.parse_html(input)?;
23762377
self.dom_to_render_tree(&doc)
23772378
}
@@ -2660,11 +2661,6 @@ impl<D: TextDecorator> RenderedText<D> {
26602661
}
26612662
}
26622663

2663-
/// Reads and parses HTML from `input` and prepares a render tree.
2664-
pub fn parse(input: impl io::Read) -> Result<RenderTree> {
2665-
config::plain().do_parse(input)
2666-
}
2667-
26682664
/// Reads HTML from `input`, decorates it using `decorator`, and
26692665
/// returns a `String` with text wrapped to `width` columns.
26702666
pub fn from_read_with_decorator<R, D>(input: R, width: usize, decorator: D) -> Result<String>

0 commit comments

Comments
 (0)