From 74d2688aa329f0a41c2a92034c3454ed9299e71a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 14 Sep 2022 16:21:42 +0200 Subject: Fix to prefer flow over definitions, setext headings An undocumented part of CommonMark is how to deal with things in definition labels or definition titles (which both can span multiple lines). Can flow (or containers?) interrupt them? They can according to the `cmark` reference parser, so this was implemented here. This adds a new `Content` content type, which houses zero or more definitions, and then zero-or-one paragraphs. Content can be followed by a setext heading underline, which either turns into a setext heading when the content ends in a paragraph, or turns into the start of the following paragraph when it is followed by content that starts with a paragraph, or turns into a stray paragraph. --- src/event.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index de3f95f..a2626ee 100644 --- a/src/event.rs +++ b/src/event.rs @@ -554,6 +554,26 @@ pub enum Name { /// ^ ^ /// ``` CodeTextSequence, + /// Content. + /// + /// ## Info + /// + /// * **Context**: + /// [flow content][crate::construct::flow] + /// * **Content model**: + /// [content][crate::construct::content] + /// * **Construct**: + /// [`content`][crate::construct::content] + /// + /// ## Example + /// + /// ```markdown + /// > | [a]: b + /// ^^^^^^ + /// > | c. + /// ^^ + /// ``` + Content, /// Data. /// /// ## Info @@ -1754,7 +1774,8 @@ pub enum Name { /// * **Context**: /// [`HeadingSetext`][Name::HeadingSetext] /// * **Content model**: - /// void + /// [`HeadingSetextUnderlineSequence`][Name::HeadingSetextUnderlineSequence], + /// [`SpaceOrTab`][Name::SpaceOrTab] /// * **Construct**: /// [`heading_setext`][crate::construct::heading_setext] /// @@ -1766,6 +1787,25 @@ pub enum Name { /// ^^^^^ /// ``` HeadingSetextUnderline, + /// Heading (setext) underline sequence. + /// + /// ## Info + /// + /// * **Context**: + /// [`HeadingSetext`][Name::HeadingSetext] + /// * **Content model**: + /// void + /// * **Construct**: + /// [`heading_setext`][crate::construct::heading_setext] + /// + /// ## Example + /// + /// ```markdown + /// | alpha + /// > | ===== + /// ^^^^^ + /// ``` + HeadingSetextUnderlineSequence, /// Whole html (flow). /// /// ## Info @@ -2914,13 +2954,12 @@ pub enum Name { /// ^ /// ``` MdxJsxTagSelfClosingMarker, - - /// Whole paragraph. + /// Paragraph. /// /// ## Info /// /// * **Context**: - /// [flow content][crate::construct::flow] + /// [content][crate::construct::content] /// * **Content model**: /// [text content][crate::construct::text] /// * **Construct**: @@ -3340,7 +3379,7 @@ pub const VOID_EVENTS: [Name; 75] = [ Name::HardBreakEscape, Name::HardBreakTrailing, Name::HeadingAtxSequence, - Name::HeadingSetextUnderline, + Name::HeadingSetextUnderlineSequence, Name::HtmlFlowData, Name::HtmlTextData, Name::LabelImageMarker, @@ -3380,6 +3419,8 @@ pub const VOID_EVENTS: [Name; 75] = [ pub enum Content { /// Represents [flow content][crate::construct::flow]. Flow, + /// Represents [content][crate::construct::content]. + Content, /// Represents [string content][crate::construct::string]. String, /// Represents [text content][crate::construct::text]. -- cgit