|
|
|
@ -142,39 +142,39 @@ where
|
|
|
|
|
match tag {
|
|
|
|
|
Tag::Paragraph => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.write("<p>")
|
|
|
|
|
self.write("<p dir=\"auto\">")
|
|
|
|
|
} else {
|
|
|
|
|
self.write("\n<p>")
|
|
|
|
|
self.write("\n<p dir=\"auto\">")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Tag::Heading(level) => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.end_newline = false;
|
|
|
|
|
write!(&mut self.writer, "<h{}>", level)
|
|
|
|
|
write!(&mut self.writer, "<h{} dir=\"auto\">", level)
|
|
|
|
|
} else {
|
|
|
|
|
write!(&mut self.writer, "\n<h{}>", level)
|
|
|
|
|
write!(&mut self.writer, "\n<h{} dir=\"auto\">", level)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Tag::Table(alignments) => {
|
|
|
|
|
self.table_alignments = alignments;
|
|
|
|
|
self.write("<table>")
|
|
|
|
|
self.write("<table dir=\"auto\">")
|
|
|
|
|
}
|
|
|
|
|
Tag::TableHead => {
|
|
|
|
|
self.table_state = TableState::Head;
|
|
|
|
|
self.table_cell_index = 0;
|
|
|
|
|
self.write("<thead><tr>")
|
|
|
|
|
self.write("<thead dir=\"auto\"><tr dir=\"auto\">")
|
|
|
|
|
}
|
|
|
|
|
Tag::TableRow => {
|
|
|
|
|
self.table_cell_index = 0;
|
|
|
|
|
self.write("<tr>")
|
|
|
|
|
self.write("<tr dir=\"auto\">")
|
|
|
|
|
}
|
|
|
|
|
Tag::TableCell => {
|
|
|
|
|
match self.table_state {
|
|
|
|
|
TableState::Head => {
|
|
|
|
|
self.write("<th")?;
|
|
|
|
|
self.write("<th dir=\"auto\"")?;
|
|
|
|
|
}
|
|
|
|
|
TableState::Body => {
|
|
|
|
|
self.write("<td")?;
|
|
|
|
|
self.write("<td dir=\"auto\"")?;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
match self.table_alignments.get(self.table_cell_index) {
|
|
|
|
@ -186,9 +186,9 @@ where
|
|
|
|
|
}
|
|
|
|
|
Tag::BlockQuote => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.write("<blockquote>\n")
|
|
|
|
|
self.write("<blockquote dir=\"auto\">\n")
|
|
|
|
|
} else {
|
|
|
|
|
self.write("\n<blockquote>\n")
|
|
|
|
|
self.write("\n<blockquote dir=\"auto\">\n")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Tag::CodeBlock(info) => {
|
|
|
|
@ -199,44 +199,44 @@ where
|
|
|
|
|
CodeBlockKind::Fenced(info) => {
|
|
|
|
|
let lang = info.split(' ').next().unwrap();
|
|
|
|
|
if lang.is_empty() {
|
|
|
|
|
self.write("<pre><code>")
|
|
|
|
|
self.write("<pre><code dir=\"auto\">")
|
|
|
|
|
} else {
|
|
|
|
|
self.write("<pre><code class=\"language-")?;
|
|
|
|
|
self.write("<pre><code dir=\"auto\" class=\"language-")?;
|
|
|
|
|
escape_html(&mut self.writer, lang)?;
|
|
|
|
|
self.write("\">")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CodeBlockKind::Indented => self.write("<pre><code>"),
|
|
|
|
|
CodeBlockKind::Indented => self.write("<pre><code dir=\"auto\">"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Tag::List(Some(1)) => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.write("<ol>\n")
|
|
|
|
|
self.write("<ol dir=\"auto\">\n")
|
|
|
|
|
} else {
|
|
|
|
|
self.write("\n<ol>\n")
|
|
|
|
|
self.write("\n<ol dir=\"auto\">\n")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Tag::List(Some(start)) => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.write("<ol start=\"")?;
|
|
|
|
|
self.write("<ol dir=\"auto\" start=\"")?;
|
|
|
|
|
} else {
|
|
|
|
|
self.write("\n<ol start=\"")?;
|
|
|
|
|
self.write("\n<ol dir=\"auto\" start=\"")?;
|
|
|
|
|
}
|
|
|
|
|
write!(&mut self.writer, "{}", start)?;
|
|
|
|
|
self.write("\">\n")
|
|
|
|
|
}
|
|
|
|
|
Tag::List(None) => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.write("<ul>\n")
|
|
|
|
|
self.write("<ul dir=\"auto\">\n")
|
|
|
|
|
} else {
|
|
|
|
|
self.write("\n<ul>\n")
|
|
|
|
|
self.write("\n<ul dir=\"auto\">\n")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Tag::Item => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.write("<li>")
|
|
|
|
|
self.write("<li dir=\"auto\">")
|
|
|
|
|
} else {
|
|
|
|
|
self.write("\n<li>")
|
|
|
|
|
self.write("\n<li dir=\"auto\">")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Tag::Emphasis => self.write("<em>"),
|
|
|
|
@ -273,9 +273,9 @@ where
|
|
|
|
|
}
|
|
|
|
|
Tag::FootnoteDefinition(name) => {
|
|
|
|
|
if self.end_newline {
|
|
|
|
|
self.write("<div class=\"footnote-definition\" id=\"")?;
|
|
|
|
|
self.write("<div dir=\"auto\" class=\"footnote-definition\" id=\"")?;
|
|
|
|
|
} else {
|
|
|
|
|
self.write("\n<div class=\"footnote-definition\" id=\"")?;
|
|
|
|
|
self.write("\n<div dir=\"auto\" class=\"footnote-definition\" id=\"")?;
|
|
|
|
|
}
|
|
|
|
|
escape_html(&mut self.writer, &*name)?;
|
|
|
|
|
self.write("\"><sup class=\"footnote-definition-label\">")?;
|
|
|
|
|