pub struct FormatterBuilder { /* private fields */ }Expand description
Builder for the MarkdownFormatter
Implementations§
Source§impl FormatterBuilder
impl FormatterBuilder
Sourcepub fn with_config(config: Config) -> Self
pub fn with_config(config: Config) -> Self
Create a FormatterBuilder with custom Config.
let builder = FormatterBuilder::with_config(Config {
max_width: Some(80),
..Default::default()
});
let formatter = builder.build();Sourcepub fn with_code_block_formatter<F>(formatter: F) -> Self
pub fn with_code_block_formatter<F>(formatter: F) -> Self
Create a FormatterBuilder with a custom code block formatter.
The closure used to reformat code blocks takes two arguments;
the info string and the complete code snippet
let builder = FormatterBuilder::with_code_block_formatter(|info_string, code_block| {
// Set the code block formatting logic
match info_string.to_lowercase().as_str() {
"rust" => {
// format rust code
}
_ => code_block,
}
});
let formatter = builder.build();Sourcepub fn build(self) -> MarkdownFormatter
pub fn build(self) -> MarkdownFormatter
Build a MarkdownFormatter
let builder = FormatterBuilder::default();
let formatter: MarkdownFormatter = builder.build();Sourcepub fn code_block_formatter<F>(&mut self, formatter: F) -> &mut Self
pub fn code_block_formatter<F>(&mut self, formatter: F) -> &mut Self
Configure how code blocks should be reformatted after creating the FormatterBuilder.
The closure passed to code_block_formatter takes two arguments;
the info string and the complete code snippet
Sourcepub fn max_width(&mut self, max_width: Option<usize>) -> &mut Self
pub fn max_width(&mut self, max_width: Option<usize>) -> &mut Self
Configure the max with when rewriting paragraphs.
When set to None, the deafault, paragraph width is left unchanged.
Sourcepub fn sichanghe_config(&mut self) -> &mut Self
pub fn sichanghe_config(&mut self) -> &mut Self
Set the configuration based on Steven Hé (Sīchàng)’s opinion.
Trait Implementations§
Source§impl Debug for FormatterBuilder
impl Debug for FormatterBuilder
Auto Trait Implementations§
impl Freeze for FormatterBuilder
impl !RefUnwindSafe for FormatterBuilder
impl !Send for FormatterBuilder
impl !Sync for FormatterBuilder
impl Unpin for FormatterBuilder
impl !UnwindSafe for FormatterBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more