diff --git a/src/html.rs b/src/html.rs index 8a3cc5c10..1457e3f03 100644 --- a/src/html.rs +++ b/src/html.rs @@ -250,7 +250,7 @@ where self.write("\n
\n") } } - Tag::CodeBlock(info) => { + Tag::CodeBlock(_, info) => { if !self.end_newline { self.write_newline()?; } @@ -375,7 +375,7 @@ where Tag::BlockQuote => { self.write("
\n")?; } - Tag::CodeBlock(_) => { + Tag::CodeBlock(_, _) => { self.write("\n")?; } Tag::List(Some(_)) => { diff --git a/src/parse.rs b/src/parse.rs index e4cbca044..f0a00f20c 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -48,9 +48,12 @@ pub enum Tag<'a> { Heading(u32), BlockQuote, - /// A code block. The value contained in the tag describes the language of the code, - /// which may be empty. - CodeBlock(CowStr<'a>), + /// A code block. + /// + /// The boolean is `true` is this is an indented code block (not starting with "\`\`\`"). + /// + /// The value contained in the tag describes the language of the code, which may be empty. + CodeBlock(bool, CowStr<'a>), /// A list. If the list is ordered the field indicates the number of the first item. /// Contains only list items. @@ -2675,8 +2678,8 @@ fn item_to_tag<'a>(item: &Item, allocs: &Allocations<'a>) -> Tag<'a> { Tag::Image(*link_type, url.clone(), title.clone()) } ItemBody::Heading(level) => Tag::Heading(level), - ItemBody::FencedCodeBlock(cow_ix) => Tag::CodeBlock(allocs[cow_ix].clone()), - ItemBody::IndentCodeBlock => Tag::CodeBlock("".into()), + ItemBody::FencedCodeBlock(cow_ix) => Tag::CodeBlock(false, allocs[cow_ix].clone()), + ItemBody::IndentCodeBlock => Tag::CodeBlock(true, "".into()), ItemBody::BlockQuote => Tag::BlockQuote, ItemBody::List(_, c, listitem_start) => { if c == b'.' || c == b')' { @@ -2722,8 +2725,8 @@ fn item_to_event<'a>(item: Item, text: &'a str, allocs: &Allocations<'a>) -> Eve Tag::Image(*link_type, url.clone(), title.clone()) } ItemBody::Heading(level) => Tag::Heading(level), - ItemBody::FencedCodeBlock(cow_ix) => Tag::CodeBlock(allocs[cow_ix].clone()), - ItemBody::IndentCodeBlock => Tag::CodeBlock("".into()), + ItemBody::FencedCodeBlock(cow_ix) => Tag::CodeBlock(false, allocs[cow_ix].clone()), + ItemBody::IndentCodeBlock => Tag::CodeBlock(true, "".into()), ItemBody::BlockQuote => Tag::BlockQuote, ItemBody::List(_, c, listitem_start) => { if c == b'.' || c == b')' {