aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/flow.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-31 16:50:20 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-31 16:50:20 +0200
commitb1590a4fb0c28fdb6af866ea79c186ea57284493 (patch)
tree61264dc36135e7dae34a04992a99b9f3f71e7b8e /src/construct/flow.rs
parent670f1d82e01ea2394b21d7d1857f41bdc67b3fce (diff)
downloadmarkdown-rs-b1590a4fb0c28fdb6af866ea79c186ea57284493.tar.gz
markdown-rs-b1590a4fb0c28fdb6af866ea79c186ea57284493.tar.bz2
markdown-rs-b1590a4fb0c28fdb6af866ea79c186ea57284493.zip
Add support for GFM tables
Diffstat (limited to '')
-rw-r--r--src/construct/flow.rs41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/construct/flow.rs b/src/construct/flow.rs
index 3f1cd77..3f7bc9c 100644
--- a/src/construct/flow.rs
+++ b/src/construct/flow.rs
@@ -65,29 +65,10 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
);
State::Retry(StateName::HtmlFlowStart)
}
- // Note: `-` is also used in thematic breaks so it’s not included here.
- Some(b'=') => {
- tokenizer.attempt(
- State::Next(StateName::FlowAfter),
- State::Next(StateName::FlowBeforeParagraph),
- );
- State::Retry(StateName::HeadingSetextStart)
- }
- Some(b'[') => {
- tokenizer.attempt(
- State::Next(StateName::FlowAfter),
- State::Next(StateName::FlowBeforeParagraph),
- );
- State::Retry(StateName::DefinitionStart)
- }
// Actual parsing: blank line? Indented code? Indented anything?
- // Also includes `-` which can be a setext heading underline or thematic break.
- None | Some(b'\t' | b'\n' | b' ' | b'-') => State::Retry(StateName::FlowBlankLineBefore),
- // Must be a paragraph.
- Some(_) => {
- tokenizer.attempt(State::Next(StateName::FlowAfter), State::Nok);
- State::Retry(StateName::ParagraphStart)
- }
+ // Tables, setext heading underlines, definitions, and paragraphs are
+ // particularly weird.
+ _ => State::Retry(StateName::FlowBlankLineBefore),
}
}
@@ -185,11 +166,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::FlowBeforeDefinition),
+ State::Next(StateName::FlowBeforeGfmTable),
);
State::Retry(StateName::ThematicBreakStart)
}
+/// At GFM table.
+///
+/// ```markdown
+/// > | | a |
+/// ^
+/// ```
+pub fn before_gfm_table(tokenizer: &mut Tokenizer) -> State {
+ tokenizer.attempt(
+ State::Next(StateName::FlowAfter),
+ State::Next(StateName::FlowBeforeDefinition),
+ );
+ State::Retry(StateName::GfmTableStart)
+}
+
/// At definition.
///
/// ```markdown