Repub

Struct Repub 

Source
pub struct Repub<Css, Trans> {
    pub include_url: bool,
    pub include_title: bool,
    pub include_byline: bool,
    pub include_cover: bool,
    pub strip_links: bool,
    pub href_sim_thresh: f64,
    pub image_handling: ImageHandling,
    pub css: Css,
    pub transform: Trans,
    pub epub_version: EpubVersion,
}
Expand description

The main class for converting mhtml

Fields§

§include_url: bool

if true, inclue the origin url at the top of the article

§include_title: bool

if true, add the article as an h1 tag preceeding the content

§include_byline: bool

if true, add the byline preceeding the content

§include_cover: bool

if true, add the cover image found preceeding the content

§strip_links: bool

if true, strip all links from the epub

§href_sim_thresh: f64

threshold for approximate url matching

Due to some bugs with chromiums renderer, some urls will be stripped from the final mhtml, and as a fallback this can be set to a value less then one to allow for approximate matching. 1.0 will accept any reasonable image, 0.0 only accepts complete matches and is significantly faster than any other setting.

§image_handling: ImageHandling

how to handle images

§css: Css

optional css content to render to the final epub

§transform: Trans

function to transform images

§epub_version: EpubVersion

the version of epub to write

Implementations§

Source§

impl<C, T> Repub<C, T>
where C: AsRef<str>, T: ImageTransform,

Source

pub fn mhtml_to_epub( &self, mhtml: impl AsRef<str>, out: &mut impl Write, ) -> Result<Option<String>, Error>

convert an mhtml string to an epub with current options

Trait Implementations§

Source§

impl<Css: Debug, Trans: Debug> Debug for Repub<Css, Trans>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Repub<&'static str, NoopTransform>

Source§

fn default() -> Self

creates minimalist settings that have the least “impact” but probably aren’t desired

Auto Trait Implementations§

§

impl<Css, Trans> Freeze for Repub<Css, Trans>
where Css: Freeze, Trans: Freeze,

§

impl<Css, Trans> RefUnwindSafe for Repub<Css, Trans>
where Css: RefUnwindSafe, Trans: RefUnwindSafe,

§

impl<Css, Trans> Send for Repub<Css, Trans>
where Css: Send, Trans: Send,

§

impl<Css, Trans> Sync for Repub<Css, Trans>
where Css: Sync, Trans: Sync,

§

impl<Css, Trans> Unpin for Repub<Css, Trans>
where Css: Unpin, Trans: Unpin,

§

impl<Css, Trans> UnwindSafe for Repub<Css, Trans>
where Css: UnwindSafe, Trans: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,