"#, c)?;
- } else {
- self.out.write_str("
")?;
- }
- }
- Container::Paragraph => self.out.write_str("
")?,
- Container::Heading { level } => write!(self.out, "", level)?,
- Container::TableCell => self.out.write_str("")?,
- Container::DescriptionTerm => self.out.write_str("")?,
- Container::CodeBlock { lang } => {
- if let Some(l) = lang {
- write!(self.out, r#""#, l)?;
- } else {
- self.out.write_str("")?;
- }
- }
- Container::Span => self.out.write_str("")?,
- Container::Link(dst, ..) => write!(self.out, r#""#, dst)?,
+ Container::Table => self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str(" write!(self.out, " self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str(" write!(self.out, r#" {
self.text_only = true;
self.out.write_str(" self.out.write_str("")?,
- Container::Math { display } => self.out.write_str(if display {
- r#"\["#
- } else {
- r#"\("#
- })?,
+ Container::Verbatim => self.out.write_str(" {
- self.raw = if format == "html" {
+ self.raw = if format == &"html" {
Raw::Html
} else {
Raw::Other
- }
+ };
+ continue;
}
- Container::Subscript => self.out.write_str("")?,
- Container::Superscript => self.out.write_str("")?,
- Container::Insert => self.out.write_str("")?,
- Container::Delete => self.out.write_str("")?,
- Container::Strong => self.out.write_str("")?,
- Container::Emphasis => self.out.write_str("")?,
- Container::Mark => self.out.write_str("")?,
+ Container::Subscript => self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str("‘")?,
Container::DoubleQuoted => self.out.write_str("“")?,
}
+
+ if attrs.iter().any(|(a, _)| a == "class")
+ || matches!(
+ c,
+ Container::Div { class: Some(_) } | Container::Math { .. }
+ )
+ {
+ self.out.write_str(r#" class=""#)?;
+ let mut classes = attrs
+ .iter()
+ .filter(|(a, _)| a == &"class")
+ .map(|(_, cls)| cls);
+ let has_attr = if let Container::Math { display } = c {
+ self.out.write_str(if display {
+ "math display"
+ } else {
+ "math inline"
+ })?;
+ true
+ } else if let Some(cls) = classes.next() {
+ self.out.write_str(cls)?;
+ for cls in classes {
+ self.out.write_char(' ')?;
+ self.out.write_str(cls)?;
+ }
+ true
+ } else {
+ false
+ };
+ if let Container::Div { class: Some(cls) } = c {
+ if has_attr {
+ self.out.write_char(' ')?;
+ }
+ self.out.write_str(cls)?;
+ }
+ self.out.write_char('"')?;
+ }
+
+ match c {
+ Container::CodeBlock { lang } => {
+ if let Some(l) = lang {
+ write!(self.out, r#">"#, l)?;
+ } else {
+ self.out.write_str(">")?;
+ }
+ }
+ Container::Image(..) => {
+ self.out.write_str(r#" alt=""#)?;
+ }
+ Container::Math { display } => {
+ self.out
+ .write_str(if display { r#">\["# } else { r#">\("# })?;
+ }
+ _ => self.out.write_char('>')?,
+ }
}
Event::End(c) => {
if c.is_block_container() && !matches!(c, Container::Footnote { .. }) {
@@ -154,9 +193,7 @@ impl<'s, I: Iterator- >, W: std::fmt::Write> Writer {
Container::TableCell => self.out.write_str("
| ")?,
Container::DescriptionTerm => self.out.write_str("")?,
Container::CodeBlock { .. } => self.out.write_str("")?,
- Container::Span | Container::Math { .. } => {
- self.out.write_str("")?;
- }
+ Container::Span => self.out.write_str("")?,
Container::Link(..) => self.out.write_str("")?,
Container::Image(src, ..) => {
self.text_only = false;
@@ -167,6 +204,13 @@ impl<'s, I: Iterator- >, W: std::fmt::Write> Writer {
}
}
Container::Verbatim => self.out.write_str("")?,
+ Container::Math { display } => {
+ self.out.write_str(if display {
+ r#"\]"#
+ } else {
+ r#"\)"#
+ })?;
+ }
Container::RawBlock { .. } | Container::RawInline { .. } => {
self.raw = Raw::None;
}
|