Struct diff_match_patch_rs::html::HtmlConfig

source ·
pub struct HtmlConfig<'a> { /* private fields */ }
Expand description

A struct representing some properties to control the pretty_html generation. The insert_tag, delete_tag and equality_tag represents the html tag to wrap the part of the text being inserted, deleted or equality.

E.g. if insert_tag is set to span, the text to be inserted will be wrapped around with <span>some text to insert</span>. insert_tag defaults to the ins tag, delete_tag defaults to the del tag and equality_tag defaults to span.

nltobr switch enables or disables replacing of \n in the text with a <br> element. Defaults to true

insert_class, delete_class or equality_class if set will be added as a class="your css class". Defaults to None

insert_style, delete_style and equality_style would add css style property to the output. E.g. if insert_style: Some("background: yellow; color: purple") is set the insert part of the pretty html would look like <ins style="background: yellow; color: purple">insert text</ins>

Implementations§

source§

impl<'a> HtmlConfig<'a>

source

pub fn new() -> Self

Creates a new instance of the struct with some defaults.

insert_tag defaults to “ins”.

delete_tag defaults to “del”

equality_tag defaults to “span”

nltobr defaults to true

Other fields defaults to None

source

pub fn set_insert_tag(&mut self, tag: &'a str)

Set the HTML tag to be used for text inserted

source

pub fn set_delete_tag(&mut self, tag: &'a str)

Set the HTML tag to be used for text deleted

source

pub fn set_equality_tag(&mut self, tag: &'a str)

Set the HTML tag to be used for text that has not changed

source

pub fn set_nl_to_br(&mut self, nltobr: bool)

Switch to control if \nl should be replaced with <br>

source

pub fn set_insert_class(&mut self, class: Option<&'a str>)

Set the css class for the text inserted

source

pub fn set_delete_class(&mut self, class: Option<&'a str>)

Set the delete class for text deleted

source

pub fn set_equality_class(&mut self, class: Option<&'a str>)

Set the css class for text that has not changed

source

pub fn set_insert_style(&mut self, style: Option<&'a str>)

Set the css style property for text inserted

source

pub fn set_delete_style(&mut self, style: Option<&'a str>)

Set the css style property for text deleted

source

pub fn set_equality_style(&mut self, style: Option<&'a str>)

Set the css style for text that has not changed

Trait Implementations§

source§

impl<'a> Default for HtmlConfig<'a>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for HtmlConfig<'a>

§

impl<'a> RefUnwindSafe for HtmlConfig<'a>

§

impl<'a> Send for HtmlConfig<'a>

§

impl<'a> Sync for HtmlConfig<'a>

§

impl<'a> Unpin for HtmlConfig<'a>

§

impl<'a> UnwindSafe for HtmlConfig<'a>

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.