pub struct Config<D: TextDecorator> { /* private fields */ }
Expand description
Configure the HTML processing.
Implementations§
source§impl<D: TextDecorator> Config<D>
impl<D: TextDecorator> Config<D>
sourcepub fn parse_html<R: Read>(&self, input: R) -> Result<RcDom, Error>
pub fn parse_html<R: Read>(&self, input: R) -> Result<RcDom, Error>
Parse the HTML into a DOM structure.
sourcepub fn dom_to_render_tree(&self, dom: &RcDom) -> Result<RenderTree, Error>
pub fn dom_to_render_tree(&self, dom: &RcDom) -> Result<RenderTree, Error>
Convert an HTML DOM into a RenderTree.
sourcepub fn render_to_string(
&self,
render_tree: RenderTree,
width: usize
) -> Result<String, Error>
pub fn render_to_string( &self, render_tree: RenderTree, width: usize ) -> Result<String, Error>
Render an existing RenderTree into a string.
sourcepub fn render_to_lines(
&self,
render_tree: RenderTree,
width: usize
) -> Result<Vec<TaggedLine<Vec<D::Annotation>>>, Error>
pub fn render_to_lines( &self, render_tree: RenderTree, width: usize ) -> Result<Vec<TaggedLine<Vec<D::Annotation>>>, Error>
Take an existing RenderTree, and returns text wrapped to width
columns.
The text is returned as a Vec<TaggedLine<_>>
; the annotations are vectors
of the provided text decorator’s Annotation
. The “outer” annotation comes first in
the Vec
.
sourcepub fn string_from_read<R: Read>(
self,
input: R,
width: usize
) -> Result<String, Error>
pub fn string_from_read<R: Read>( self, input: R, width: usize ) -> Result<String, Error>
Reads HTML from input
, and returns a String
with text wrapped to
width
columns.
sourcepub fn lines_from_read<R: Read>(
self,
input: R,
width: usize
) -> Result<Vec<TaggedLine<Vec<D::Annotation>>>, Error>
pub fn lines_from_read<R: Read>( self, input: R, width: usize ) -> Result<Vec<TaggedLine<Vec<D::Annotation>>>, Error>
Reads HTML from input
, and returns text wrapped to width
columns.
The text is returned as a Vec<TaggedLine<_>>
; the annotations are vectors
of the provided text decorator’s Annotation
. The “outer” annotation comes first in
the Vec
.
sourcepub fn pad_block_width(self) -> Self
pub fn pad_block_width(self) -> Self
Pad lines out to the full render width.
sourcepub fn max_wrap_width(self, wrap_width: usize) -> Self
pub fn max_wrap_width(self, wrap_width: usize) -> Self
Set the maximum text wrap width. When set, paragraphs will be wrapped to that width even if there is more total width available for rendering.
sourcepub fn allow_width_overflow(self) -> Self
pub fn allow_width_overflow(self) -> Self
Allow the output to be wider than the max width. When enabled,
then output wider than the specified width will be returned
instead of returning Err(TooNarrow)
if the output wouldn’t
otherwise fit.
sourcepub fn min_wrap_width(self, min_wrap_width: usize) -> Self
pub fn min_wrap_width(self, min_wrap_width: usize) -> Self
Set the minimum width for text wrapping. The default is 3.
Blocks of text will be forced to have at least this width
(unless the text inside is less than that). Increasing this
can increase the chance that the width will overflow, leading
to a TooNarrow error unless allow_width_overflow()
is set.
sourcepub fn raw_mode(self, raw: bool) -> Self
pub fn raw_mode(self, raw: bool) -> Self
Raw extraction, ensures text in table cells ends up rendered together
This traverses tables as if they had a single column and every cell is its own row.
Implies no_table_borders()
sourcepub fn no_table_borders(self) -> Self
pub fn no_table_borders(self) -> Self
Do not render table borders
source§impl Config<RichDecorator>
impl Config<RichDecorator>
sourcepub fn coloured<R, FMap>(
self,
input: R,
width: usize,
colour_map: FMap
) -> Result<String, Error>
pub fn coloured<R, FMap>( self, input: R, width: usize, colour_map: FMap ) -> Result<String, Error>
Return coloured text. colour_map
is a function which takes
a list of RichAnnotation
and some text, and returns the text
with any terminal escapes desired to indicate those annotations
(such as colour).
sourcepub fn render_coloured<FMap>(
&self,
render_tree: RenderTree,
width: usize,
colour_map: FMap
) -> Result<String, Error>
pub fn render_coloured<FMap>( &self, render_tree: RenderTree, width: usize, colour_map: FMap ) -> Result<String, Error>
Return coloured text from a RenderTree. colour_map
is a function which takes a list
of RichAnnotation
and some text, and returns the text with any terminal escapes
desired to indicate those annotations (such as colour).