#[non_exhaustive]pub struct Options<S: StyleSheet = DefaultStyleSheet> { /* private fields */ }Expand description
Rendering options for crate::from_str_with_options.
S is the style sheet consulted while Markdown events are rendered. Options::default uses
DefaultStyleSheet. Use Options::new to supply another StyleSheet.
StyleSheet::heading_marker and StyleSheet::code_block_fence customize or hide the
corresponding presentation symbols.
§Example
use tui_markdown::Options;
let options = Options::default();
// or with a custom style sheet
use ratatui_core::style::{Style, Stylize};
use tui_markdown::StyleSheet;
#[derive(Debug, Clone)]
struct MyStyleSheet;
impl StyleSheet for MyStyleSheet {
fn heading(&self, _level: u8) -> Style {
Style::new().bold()
}
}
let options = Options::new(MyStyleSheet);Implementations§
Source§impl<S: StyleSheet> Options<S>
impl<S: StyleSheet> Options<S>
Sourcepub fn new(styles: S) -> Self
pub fn new(styles: S) -> Self
Creates rendering options that use styles.
Image fallback and syntax-highlighting settings retain their defaults.
Sourcepub fn image_fallback(self, image_fallback: ImageFallback) -> Self
pub fn image_fallback(self, image_fallback: ImageFallback) -> Self
Selects the text used to represent Markdown images.
See ImageFallback for the exact output of each mode.
Sourcepub fn code_theme(self, code_theme: impl Into<CodeTheme>) -> Self
pub fn code_theme(self, code_theme: impl Into<CodeTheme>) -> Self
Selects the syntax-highlighting theme for fenced code blocks.
By default, no explicit theme is stored and the renderer borrows its shared
Base16OceanDark theme.
Pass a BuiltinCodeTheme directly, or pass an owned
CodeTheme. Construct custom themes from TextMate source with
CodeTheme::from_textmate, or load a TextMate file with
CodeTheme::from_file. The selected theme applies when a
fenced code block names a recognized language.
§Example
use tui_markdown::{BuiltinCodeTheme, Options};
let options = Options::default().code_theme(BuiltinCodeTheme::SolarizedDark);Sourcepub fn selected_code_theme(&self) -> Option<&CodeTheme>
pub fn selected_code_theme(&self) -> Option<&CodeTheme>
Returns the explicitly configured syntax-highlighting theme.
Returns None when the renderer will use the shared
Base16OceanDark default.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Options<S>where
S: Freeze,
impl<S> RefUnwindSafe for Options<S>where
S: RefUnwindSafe,
impl<S> Send for Options<S>
impl<S> Sync for Options<S>
impl<S> Unpin for Options<S>where
S: Unpin,
impl<S> UnsafeUnpin for Options<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for Options<S>where
S: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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