Skip to content

Commit

Permalink
Add boolean to tell if it's an indented code block or not
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 17, 2019
1 parent 7777d0e commit 6a7cd69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/html.rs
Expand Up @@ -250,7 +250,7 @@ where
self.write("\n<blockquote>\n")
}
}
Tag::CodeBlock(info) => {
Tag::CodeBlock(_, info) => {
if !self.end_newline {
self.write_newline()?;
}
Expand Down Expand Up @@ -375,7 +375,7 @@ where
Tag::BlockQuote => {
self.write("</blockquote>\n")?;
}
Tag::CodeBlock(_) => {
Tag::CodeBlock(_, _) => {
self.write("</code></pre>\n")?;
}
Tag::List(Some(_)) => {
Expand Down
17 changes: 10 additions & 7 deletions src/parse.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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')' {
Expand Down Expand Up @@ -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')' {
Expand Down

0 comments on commit 6a7cd69

Please sign in to comment.