lib: make code block language non option

no distinction between empty language and None
This commit is contained in:
Noah Hellman 2023-05-10 23:37:44 +02:00
parent e79f767604
commit 0484ee2011
2 changed files with 7 additions and 9 deletions

View file

@ -267,12 +267,12 @@ impl<'s> Writer<'s> {
write!(out, r#" style="text-align: {};">"#, a)?;
}
Container::CodeBlock { language } => {
if let Some(l) = language {
out.write_str(r#"><code class="language-"#)?;
write_attr(l, &mut out)?;
out.write_str(r#"">"#)?;
} else {
if language.is_empty() {
out.write_str("><code>")?;
} else {
out.write_str(r#"><code class="language-"#)?;
write_attr(language, &mut out)?;
out.write_str(r#"">"#)?;
}
}
Container::Image(..) => {

View file

@ -290,7 +290,7 @@ pub enum Container<'s> {
/// A block with raw markup for a specific output format.
RawBlock { format: &'s str },
/// A block with code in a specific language.
CodeBlock { language: Option<&'s str> },
CodeBlock { language: &'s str },
/// An inline divider element.
Span,
/// An inline link, the first field is either a destination URL or an unresolved tag.
@ -902,9 +902,7 @@ impl<'s> Parser<'s> {
if let Some(format) = content.strip_prefix('=') {
Container::RawBlock { format }
} else {
Container::CodeBlock {
language: (!content.is_empty()).then(|| content),
}
Container::CodeBlock { language: content }
}
}
block::Leaf::TableCell(alignment) => Container::TableCell {