Skip to content

Commit

Permalink
handle new types and change
Browse files Browse the repository at this point in the history
  • Loading branch information
Roms1383 committed Jun 11, 2024
1 parent 173b8a4 commit c81d969
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use std::{
ops::Range,
};

use pulldown_cmark::{Alignment as TableAlignment, Event, HeadingLevel, LinkType, MetadataBlockKind, Tag, TagEnd};
use pulldown_cmark::{
Alignment as TableAlignment, BlockQuoteKind, Event, HeadingLevel, LinkType, MetadataBlockKind, Tag, TagEnd,
};

mod source_range;
mod text_modifications;
Expand Down Expand Up @@ -368,7 +370,7 @@ where
}?;
formatter.write_char(' ')
}
BlockQuote => {
BlockQuote(None) => {
state.padding.push(" > ".into());
state.newlines_before_start = 1;

Expand All @@ -381,6 +383,26 @@ where
formatter.write_char('\n').and(padding(formatter, &state.padding))
}
}
BlockQuote(Some(kind)) => {
let kind = match kind {
BlockQuoteKind::Note => "NOTE",
BlockQuoteKind::Tip => "TIP",
BlockQuoteKind::Important => "IMPORTANT",
BlockQuoteKind::Warning => "WARNING",
BlockQuoteKind::Caution => "CAUTION",
};
state.padding.push(format!(" > [!{kind}]").into());
state.padding.push("\n".into());
state.padding.push(format!(" > ").into());
state.newlines_before_start = 1;

// same logic as traditional blockquote, see above
if consumed_newlines {
formatter.write_str(" > ")
} else {
formatter.write_char('\n').and(padding(formatter, &state.padding))
}
}
CodeBlock(CodeBlockKind::Indented) => {
state.is_in_code_block = true;
for _ in 0..options.code_block_token_count {
Expand Down Expand Up @@ -623,6 +645,8 @@ where
let check = if checked { "x" } else { " " };
write!(formatter, "[{}] ", check)
}
InlineMath(ref text) => write!(formatter, "${}$", text),
DisplayMath(ref text) => write!(formatter, "$${}$$", text),
}
}

Expand Down

0 comments on commit c81d969

Please sign in to comment.