aboutsummaryrefslogtreecommitdiffstats
path: root/src/content/content.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-16 19:04:16 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-16 19:04:16 +0200
commit60ea2fd3a09f10fa28bf48575736b47afebf3221 (patch)
treef7aae5cec9181f7ff5df23e648fe1da22a94209f /src/content/content.rs
parentef14d6581848ba5052d3389bb61fc96645551eef (diff)
downloadmarkdown-rs-60ea2fd3a09f10fa28bf48575736b47afebf3221.tar.gz
markdown-rs-60ea2fd3a09f10fa28bf48575736b47afebf3221.tar.bz2
markdown-rs-60ea2fd3a09f10fa28bf48575736b47afebf3221.zip
Add heading (setext)
Diffstat (limited to 'src/content/content.rs')
-rw-r--r--src/content/content.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/content/content.rs b/src/content/content.rs
index 4660fbe..4ca69ee 100644
--- a/src/content/content.rs
+++ b/src/content/content.rs
@@ -27,7 +27,7 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => {
unreachable!("expected non-eol/eof");
}
- _ => paragraph_initial(tokenizer, code)
+ _ => after_definitions(tokenizer, code)
// To do: definition.
// _ => tokenizer.attempt(definition, |ok| {
// Box::new(if ok {
@@ -44,10 +44,26 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
/// ```markdown
/// |asd
/// ```
+fn after_definitions(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
+ match code {
+ Code::None => (State::Ok, None),
+ Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => {
+ unreachable!("to do: handle eol after definition");
+ }
+ _ => paragraph_initial(tokenizer, code),
+ }
+}
+
+/// Before a paragraph.
+///
+/// ```markdown
+/// |asd
+/// ```
fn paragraph_initial(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
match code {
- Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => {
- unreachable!("expected non-eol/eof");
+ Code::None => (State::Ok, None),
+ Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => {
+ unreachable!("to do: handle eol after definition");
}
_ => {
tokenizer.enter(TokenType::Paragraph);