Skip to main content

PrettyCodeOptions

Struct PrettyCodeOptions 

Source
pub struct PrettyCodeOptions {
Show 14 fields pub theme: PrettyCodeTheme, pub default_mode: Option<String>, pub multi_theme_strategy: Option<MultiThemeStrategy>, pub keep_raw_string: Option<bool>, pub fragment_wrapper: Option<bool>, pub line_class: Option<String>, pub highlighted_line_attr: Option<String>, pub default_language: Option<String>, pub fallback_to_plaintext: Option<bool>, pub render_title: Option<bool>, pub include_data_language: Option<bool>, pub include_pre_background: Option<bool>, pub skip_languages: Vec<String>, pub tab_size: Option<u32>,
}
Expand description

Top-level pretty-code configuration. Stored on CompileConfig as Option<PrettyCodeOptions>; None means “use built-in defaults”.

Every field below has a sensible default; callers only set the knobs they care about. Field names match the TS-side PrettyCodeOptions shape exported from @gentleduck/md.

Fields§

§theme: PrettyCodeTheme

Theme spec. String for single-theme, object for multi-mode.

§default_mode: Option<String>

Mode key whose colors fill the unprefixed color / background-color attrs. Only meaningful for PrettyCodeTheme::Multi. When unset, resolves to "dark" if present, else the first key.

§multi_theme_strategy: Option<MultiThemeStrategy>

Multi-theme DOM strategy. Default CssVars (single tree, faster). Set to Split for one <pre data-theme="..."> subtree per theme (velite parity, ~2x the AST nodes). Single-theme mode ignores this

  • there’s only one tree either way.
§keep_raw_string: Option<bool>

Keep the __dmcRaw__ attribute on each <pre> so consumer <PreBlock> can offer a Copy button without re-parsing the tree. Default true.

§fragment_wrapper: Option<bool>

Wrap the per-theme <pre> blocks in a <div data-dmc-fragment=""> envelope. Default true. Set false to emit just the <pre> siblings (compatible with consumers that wrap themselves).

§line_class: Option<String>

Class on each line <span>. Default "line".

§highlighted_line_attr: Option<String>

Attribute name set on highlighted lines (from {1,3-5} meta). Default "data-dmc-line-highlighted".

§default_language: Option<String>

Language used when a fence has no lang and for unknown langs when Self::fallback_to_plaintext is on. Default "plaintext".

§fallback_to_plaintext: Option<bool>

When true (default), unknown fence languages render as plain text. When false, the code block is left as a CodeBlock node for downstream tooling.

§render_title: Option<bool>

Render a <figcaption data-dmc-title> from the fence’s title="..." meta. Default true.

§include_data_language: Option<bool>

Include data-language on every emitted <pre> and <code>. Default true.

§include_pre_background: Option<bool>

Emit a solid background-color on <pre> from the primary theme. Default true. Set to false to skip the inline bg so the outer [data-dmc-fragment] wrapper (or consumer chrome) owns the surface color. Per-mode --dmc-{mode}-bg custom properties are always emitted regardless of this flag, so consumer CSS can still opt back in via var(--dmc-{mode}-bg) if it wants.

§skip_languages: Vec<String>

Languages to skip - these blocks are passed through unchanged. mermaid is always skipped (owned by the mermaid transformer); add other langs to keep them as raw CodeBlock nodes.

§tab_size: Option<u32>

Expand tab characters to N spaces before highlighting. None preserves original tabs.

Trait Implementations§

Source§

impl Clone for PrettyCodeOptions

Source§

fn clone(&self) -> PrettyCodeOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PrettyCodeOptions

Source§

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

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

impl Default for PrettyCodeOptions

Source§

fn default() -> PrettyCodeOptions

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

impl<'de> Deserialize<'de> for PrettyCodeOptions

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<PrettyCodeOptions, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PrettyCodeOptions

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,