diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-09-09 13:17:59 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-09-09 13:17:59 +0200 |
commit | 118cc91fd56a9b4c93bec5b1cb4c5f25924d353e (patch) | |
tree | 3a33911c5b3f7da33919dfb48f1a0b8f8b46bb1b /src/construct/flow.rs | |
parent | ffef323d3c927f84e94cae21afeb541be7320f1c (diff) | |
download | markdown-rs-118cc91fd56a9b4c93bec5b1cb4c5f25924d353e.tar.gz markdown-rs-118cc91fd56a9b4c93bec5b1cb4c5f25924d353e.tar.bz2 markdown-rs-118cc91fd56a9b4c93bec5b1cb4c5f25924d353e.zip |
Add mdx expression (flow, text)
Diffstat (limited to 'src/construct/flow.rs')
-rw-r--r-- | src/construct/flow.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/construct/flow.rs b/src/construct/flow.rs index 5b2cbfe..e97ee63 100644 --- a/src/construct/flow.rs +++ b/src/construct/flow.rs @@ -16,6 +16,7 @@ //! * [Heading (atx)][crate::construct::heading_atx] //! * [Heading (setext)][crate::construct::heading_setext] //! * [HTML (flow)][crate::construct::html_flow] +//! * [MDX expression (flow)][crate::construct::mdx_expression_flow] //! * [MDX JSX (flow)][crate::construct::mdx_jsx_flow] //! * [Raw (flow)][crate::construct::raw_flow] (code (fenced), math (flow)) //! * [Thematic break][crate::construct::thematic_break] @@ -66,6 +67,13 @@ pub fn start(tokenizer: &mut Tokenizer) -> State { ); State::Retry(StateName::HtmlFlowStart) } + Some(b'{') => { + tokenizer.attempt( + State::Next(StateName::FlowAfter), + State::Next(StateName::FlowBeforeParagraph), + ); + State::Retry(StateName::MdxExpressionFlowStart) + } // Actual parsing: blank line? Indented code? Indented anything? // Tables, setext heading underlines, definitions, and paragraphs are // particularly weird. @@ -181,11 +189,25 @@ pub fn before_heading_setext(tokenizer: &mut Tokenizer) -> State { pub fn before_thematic_break(tokenizer: &mut Tokenizer) -> State { tokenizer.attempt( State::Next(StateName::FlowAfter), - State::Next(StateName::FlowBeforeGfmTable), + State::Next(StateName::FlowBeforeMdxExpression), ); State::Retry(StateName::ThematicBreakStart) } +/// At MDX expression (flow). +/// +/// ```markdown +/// > | {Math.PI} +/// ^ +/// ``` +pub fn before_mdx_expression(tokenizer: &mut Tokenizer) -> State { + tokenizer.attempt( + State::Next(StateName::FlowAfter), + State::Next(StateName::FlowBeforeGfmTable), + ); + State::Retry(StateName::MdxExpressionFlowStart) +} + /// At GFM table. /// /// ```markdown |