lib: make code block language non option
no distinction between empty language and None
This commit is contained in:
parent
e79f767604
commit
0484ee2011
2 changed files with 7 additions and 9 deletions
10
src/html.rs
10
src/html.rs
|
@ -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(..) => {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue