aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-14 16:21:42 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-14 16:26:24 +0200
commit74d2688aa329f0a41c2a92034c3454ed9299e71a (patch)
tree9ec8fdc6e40ff7cd40a14408afcc47716990134e /src/event.rs
parent65d4b46c2a3bdecb0493e484473d2de3d124f839 (diff)
downloadmarkdown-rs-74d2688aa329f0a41c2a92034c3454ed9299e71a.tar.gz
markdown-rs-74d2688aa329f0a41c2a92034c3454ed9299e71a.tar.bz2
markdown-rs-74d2688aa329f0a41c2a92034c3454ed9299e71a.zip
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.
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs51
1 files changed, 46 insertions, 5 deletions
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].