From 118cc91fd56a9b4c93bec5b1cb4c5f25924d353e Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 9 Sep 2022 13:17:59 +0200 Subject: Add mdx expression (flow, text) --- src/construct/flow.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/construct/flow.rs') 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 -- cgit