Struct markdown::Constructs

source ·
pub struct Constructs {
Show 34 fields pub attention: bool, pub autolink: bool, pub block_quote: bool, pub character_escape: bool, pub character_reference: bool, pub code_indented: bool, pub code_fenced: bool, pub code_text: bool, pub definition: bool, pub frontmatter: bool, pub gfm_autolink_literal: bool, pub gfm_footnote_definition: bool, pub gfm_label_start_footnote: bool, pub gfm_strikethrough: bool, pub gfm_table: bool, pub gfm_task_list_item: bool, pub hard_break_escape: bool, pub hard_break_trailing: bool, pub heading_atx: bool, pub heading_setext: bool, pub html_flow: bool, pub html_text: bool, pub label_start_image: bool, pub label_start_link: bool, pub label_end: bool, pub list_item: bool, pub math_flow: bool, pub math_text: bool, pub mdx_esm: bool, pub mdx_expression_flow: bool, pub mdx_expression_text: bool, pub mdx_jsx_flow: bool, pub mdx_jsx_text: bool, pub thematic_break: bool,
}
Expand description

Control which constructs are enabled.

Not all constructs can be configured. Notably, blank lines and paragraphs cannot be turned off.

Examples

use markdown::Constructs;

// Use the default trait to get `CommonMark` constructs:
let commonmark = Constructs::default();

// To turn on all of GFM, use the `gfm` method:
let gfm = Constructs::gfm();

// Or, mix and match:
let custom = Constructs {
  math_flow: true,
  math_text: true,
  ..Constructs::gfm()
};

Fields§

§attention: bool

Attention.

> | a *b* c **d**.
      ^^^   ^^^^^
§autolink: bool

Autolink.

> | a <https://example.com> b <user@example.org>.
      ^^^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^^
§block_quote: bool

Block quote.

> | > a
    ^^^
§character_escape: bool

Character escape.

> | a \* b
      ^^
§character_reference: bool

Character reference.

> | a &amp; b
      ^^^^^
§code_indented: bool

Code (indented).

> |     a
    ^^^^^
§code_fenced: bool

Code (fenced).

> | ~~~js
    ^^^^^
> | console.log(1)
    ^^^^^^^^^^^^^^
> | ~~~
    ^^^
§code_text: bool

Code (text).

> | a `b` c
      ^^^
§definition: bool

Definition.

> | [a]: b "c"
    ^^^^^^^^^^
§frontmatter: bool

Frontmatter.

> | ---
    ^^^
> | title: Neptune
    ^^^^^^^^^^^^^^
> | ---
    ^^^
§gfm_autolink_literal: bool

GFM: autolink literal.

> | https://example.com
    ^^^^^^^^^^^^^^^^^^^
§gfm_footnote_definition: bool

GFM: footnote definition.

> | [^a]: b
    ^^^^^^^
§gfm_label_start_footnote: bool

GFM: footnote label start.

> | a[^b]
     ^^
§gfm_strikethrough: bool
> | a ~b~ c.
      ^^^
§gfm_table: bool

GFM: table.

> | | a |
    ^^^^^
> | | - |
    ^^^^^
> | | b |
    ^^^^^
§gfm_task_list_item: bool

GFM: task list item.

> | * [x] y.
      ^^^
§hard_break_escape: bool

Hard break (escape).

> | a\
     ^
  | b
§hard_break_trailing: bool

Hard break (trailing).

> | a␠␠
     ^^
  | b
§heading_atx: bool

Heading (atx).

> | # a
    ^^^
§heading_setext: bool

Heading (setext).

> | a
    ^^
> | ==
    ^^
§html_flow: bool

HTML (flow).

> | <div>
    ^^^^^
§html_text: bool

HTML (text).

> | a <b> c
      ^^^
§label_start_image: bool

Label start (image).

> | a ![b](c) d
      ^^
§label_start_link: bool

Label start (link).

> | a [b](c) d
      ^
§label_end: bool

Label end.

> | a [b](c) d
        ^^^^
§list_item: bool

List items.

> | * a
    ^^^
§math_flow: bool

Math (flow).

> | $$
    ^^
> | \frac{1}{2}
    ^^^^^^^^^^^
> | $$
    ^^
§math_text: bool

Math (text).

> | a $b$ c
      ^^^
§mdx_esm: bool

MDX: ESM.

> | import a from 'b'
    ^^^^^^^^^^^^^^^^^

👉 Note: to support ESM, you must pass mdx_esm_parse in ParseOptions too. Otherwise, ESM is treated as normal markdown.

§mdx_expression_flow: bool

MDX: expression (flow).

> | {Math.PI}
    ^^^^^^^^^

👉 Note: You can pass mdx_expression_parse in ParseOptions too, to parse expressions according to a certain grammar (typically, a programming language). Otherwise, expressions are parsed with a basic algorithm that only cares about braces.

§mdx_expression_text: bool

MDX: expression (text).

> | a {Math.PI} c
      ^^^^^^^^^

👉 Note: You can pass mdx_expression_parse in ParseOptions too, to parse expressions according to a certain grammar (typically, a programming language). Otherwise, expressions are parsed with a basic algorithm that only cares about braces.

§mdx_jsx_flow: bool

MDX: JSX (flow).

> | <Component />
    ^^^^^^^^^^^^^

👉 Note: You must pass html_flow: false to use this, as it’s preferred when on over mdx_jsx_flow.

👉 Note: You can pass mdx_expression_parse in ParseOptions too, to parse expressions in JSX according to a certain grammar (typically, a programming language). Otherwise, expressions are parsed with a basic algorithm that only cares about braces.

§mdx_jsx_text: bool

MDX: JSX (text).

> | a <Component /> c
      ^^^^^^^^^^^^^

👉 Note: You must pass html_text: false to use this, as it’s preferred when on over mdx_jsx_text.

👉 Note: You can pass mdx_expression_parse in ParseOptions too, to parse expressions in JSX according to a certain grammar (typically, a programming language). Otherwise, expressions are parsed with a basic algorithm that only cares about braces.

§thematic_break: bool

Thematic break.

> | ***
    ^^^

Implementations§

source§

impl Constructs

source

pub fn gfm() -> Self

GFM.

GFM stands for GitHub flavored markdown. GFM extends CommonMark and adds support for autolink literals, footnotes, strikethrough, tables, and tasklists.

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

source

pub fn mdx() -> Self

MDX.

This turns on CommonMark, turns off some conflicting constructs (autolinks, code (indented), and HTML), and turns on MDX (ESM, expressions, and JSX).

For more information, see the MDX website: https://mdxjs.com.

👉 Note: to support ESM, you must pass mdx_esm_parse in ParseOptions too. Otherwise, ESM is treated as normal markdown.

You can pass mdx_expression_parse to parse expressions according to a certain grammar (typically, a programming language). Otherwise, expressions are parsed with a basic algorithm that only cares about braces.

Trait Implementations§

source§

impl Clone for Constructs

source§

fn clone(&self) -> Constructs

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 Constructs

source§

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

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

impl Default for Constructs

source§

fn default() -> Self

CommonMark.

CommonMark is a relatively strong specification of how markdown works. Most markdown parsers try to follow it.

For more information, see the CommonMark specification: https://spec.commonmark.org.

source§

impl PartialEq for Constructs

source§

fn eq(&self, other: &Constructs) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Constructs

source§

impl StructuralEq for Constructs

source§

impl StructuralPartialEq for Constructs

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

§

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>,

§

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>,

§

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.