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
impl Options
Sourcepub fn gfm() -> Self
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§
Auto Trait Implementations§
impl Freeze for Options
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
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