Struct Options

Source
pub struct Options {
    pub parse: MdxParseOptions,
    pub development: bool,
    pub provider_import_source: Option<String>,
    pub jsx: bool,
    pub jsx_runtime: Option<JsxRuntime>,
    pub jsx_import_source: Option<String>,
    pub pragma: Option<String>,
    pub pragma_frag: Option<String>,
    pub pragma_import_source: Option<String>,
    pub filepath: Option<String>,
}
Expand description

Configuration (optional).

Fields§

§parse: MdxParseOptions

Configuration that describes how to parse from markdown.

§development: bool

Whether to add extra information to error messages in generated code (default: false).

When in the automatic JSX runtime, this also enabled its development functionality.

§provider_import_source: Option<String>

Place to import a provider from (default: None, example: Some("@mdx-js/react").into()).

Useful for runtimes that support context (React, Preact). The provider must export a useMDXComponents, which is called to access an object of components.

§jsx: bool

Whether to keep JSX (default: false).

The default is to compile JSX away so that the resulting file is immediately runnable.

§jsx_runtime: Option<JsxRuntime>

JSX runtime to use (default: Some(JsxRuntime::Automatic)).

The classic runtime compiles to calls such as h('p'), the automatic runtime compiles to import _jsx from '$importSource/jsx-runtime'\n_jsx('p').

§jsx_import_source: Option<String>

Place to import automatic JSX runtimes from (Option<String>, default: Some("react".into())).

When in the automatic runtime, this is used to define an import for _Fragment, _jsx, and _jsxs.

§pragma: Option<String>

Pragma for JSX (default: Some("React.createElement".into())).

When in the classic runtime, this is used as an identifier for function calls: <x /> to React.createElement('x').

You should most probably define pragma_frag and pragma_import_source too when changing this.

§pragma_frag: Option<String>

Pragma for JSX fragments (default: Some("React.Fragment".into())).

When in the classic runtime, this is used as an identifier for fragments: <> to React.createElement(React.Fragment).

You should most probably define pragma and pragma_import_source too when changing this.

§pragma_import_source: Option<String>

Where to import the identifier of pragma from (default: Some("react".into())).

When in the classic runtime, this is used to import the pragma function. To illustrate with an example: when pragma is "a.b" and pragma_import_source is "c", the following will be generated: import a from 'c'.

§filepath: Option<String>

File path to the source file (example: Some("path/to/example.mdx".into())).

Used when development: true to improve error messages.

Implementations§

Source§

impl Options

Source

pub fn gfm() -> Self

MDX with GFM.

GFM stands for GitHub flavored markdown. GFM extends CommonMark and adds support for autolink literals, footnotes, strikethrough, tables, and tasklists. On the compilation side, GFM turns on the GFM tag filter. The tagfilter is useless, but it’s included here for consistency.

For more information, see the GFM specification: https://github.github.com/gfm/

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Options

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Options

Source§

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

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

impl Default for Options

Source§

fn default() -> Self

Default options to use the automatic JSX runtime with React and handle MDX according to CommonMark.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> MaybeSendSync for T

Source§

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

Source§

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