adding document mode
I've been thinking a lot about the treehouse and I feel like it's time to say goodbye to the tree format.
This commit is contained in:
parent
550c062327
commit
36705e7c1e
31 changed files with 940 additions and 409 deletions
|
|
@ -106,21 +106,6 @@ impl<'a> Writer<'a> {
|
|||
range: Range<usize>,
|
||||
out: &mut String,
|
||||
) -> std::fmt::Result {
|
||||
if let Event::Start(Container::Footnote { label: _ }, ..) = e {
|
||||
self.diagnostics.push(Diagnostic {
|
||||
severity: Severity::Error,
|
||||
code: Some("djot".into()),
|
||||
message: "Djot footnotes are not supported".into(),
|
||||
labels: vec![Label {
|
||||
style: LabelStyle::Primary,
|
||||
file_id: self.renderer.file_id,
|
||||
range: range.clone(),
|
||||
message: "".into(),
|
||||
}],
|
||||
notes: vec![],
|
||||
})
|
||||
}
|
||||
|
||||
if matches!(&e, Event::Start(Container::LinkDefinition { .. }, ..)) {
|
||||
self.ignore_next_event = true;
|
||||
return Ok(());
|
||||
|
|
@ -163,7 +148,7 @@ impl<'a> Writer<'a> {
|
|||
} => {
|
||||
out.push_str("<ol");
|
||||
if *start > 1 {
|
||||
write!(out, r#" start="{}""#, start)?;
|
||||
write!(out, r#" start="{start}""#)?;
|
||||
}
|
||||
if let Some(ty) = match numbering {
|
||||
Decimal => None,
|
||||
|
|
@ -172,7 +157,7 @@ impl<'a> Writer<'a> {
|
|||
RomanLower => Some('i'),
|
||||
RomanUpper => Some('I'),
|
||||
} {
|
||||
write!(out, r#" type="{}""#, ty)?;
|
||||
write!(out, r#" type="{ty}""#)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +167,7 @@ impl<'a> Writer<'a> {
|
|||
}
|
||||
Container::DescriptionList => out.push_str("<dl"),
|
||||
Container::DescriptionDetails => out.push_str("<dd"),
|
||||
Container::Footnote { .. } => unreachable!(),
|
||||
Container::Footnote { label } => out.push_str(label),
|
||||
Container::Table => out.push_str("<table"),
|
||||
Container::TableRow { .. } => out.push_str("<tr"),
|
||||
Container::Section { .. } => {}
|
||||
|
|
@ -193,7 +178,7 @@ impl<'a> Writer<'a> {
|
|||
}
|
||||
out.push_str("<p");
|
||||
}
|
||||
Container::Heading { level, .. } => write!(out, "<h{}", level)?,
|
||||
Container::Heading { level, .. } => write!(out, "<h{level}")?,
|
||||
Container::TableCell { head: false, .. } => out.push_str("<td"),
|
||||
Container::TableCell { head: true, .. } => out.push_str("<th"),
|
||||
Container::Caption => out.push_str("<caption"),
|
||||
|
|
@ -275,7 +260,7 @@ impl<'a> Writer<'a> {
|
|||
.into_iter()
|
||||
.filter(|(a, _)| !(*a == "class" || a.starts_with(':')))
|
||||
{
|
||||
write!(out, r#" {}=""#, key)?;
|
||||
write!(out, r#" {key}=""#)?;
|
||||
value.parts().for_each(|part| write_attr(part, out));
|
||||
out.push('"');
|
||||
}
|
||||
|
|
@ -338,7 +323,7 @@ impl<'a> Writer<'a> {
|
|||
Alignment::Center => "center",
|
||||
Alignment::Right => "right",
|
||||
};
|
||||
write!(out, r#" style="text-align: {};">"#, a)?;
|
||||
write!(out, r#" style="text-align: {a};">"#)?;
|
||||
}
|
||||
Container::CodeBlock { language } => {
|
||||
if language.is_empty() {
|
||||
|
|
@ -444,7 +429,7 @@ impl<'a> Writer<'a> {
|
|||
}
|
||||
Container::DescriptionList => out.push_str("</dl>"),
|
||||
Container::DescriptionDetails => out.push_str("</dd>"),
|
||||
Container::Footnote { .. } => unreachable!(),
|
||||
Container::Footnote { label } => out.push_str(label),
|
||||
Container::Table => out.push_str("</table>"),
|
||||
Container::TableRow { .. } => out.push_str("</tr>"),
|
||||
Container::Section { .. } => {}
|
||||
|
|
@ -455,7 +440,7 @@ impl<'a> Writer<'a> {
|
|||
}
|
||||
out.push_str("</p>");
|
||||
}
|
||||
Container::Heading { level, .. } => write!(out, "</h{}>", level)?,
|
||||
Container::Heading { level, .. } => write!(out, "</h{level}>")?,
|
||||
Container::TableCell { head: false, .. } => out.push_str("</td>"),
|
||||
Container::TableCell { head: true, .. } => out.push_str("</th>"),
|
||||
Container::Caption => out.push_str("</caption>"),
|
||||
|
|
@ -537,19 +522,8 @@ impl<'a> Writer<'a> {
|
|||
Raw::Html => out.push_str(s),
|
||||
Raw::Other => {}
|
||||
},
|
||||
Event::FootnoteReference(_label) => {
|
||||
self.diagnostics.push(Diagnostic {
|
||||
severity: Severity::Error,
|
||||
code: Some("djot".into()),
|
||||
message: "Djot footnotes are unsupported".into(),
|
||||
labels: vec![Label {
|
||||
style: LabelStyle::Primary,
|
||||
file_id: self.renderer.file_id,
|
||||
range,
|
||||
message: "".into(),
|
||||
}],
|
||||
notes: vec![],
|
||||
});
|
||||
Event::FootnoteReference(label) => {
|
||||
out.push_str(label);
|
||||
}
|
||||
Event::Symbol(sym) => {
|
||||
if let Some(vpath) = self.renderer.config.emoji.get(sym.as_ref()) {
|
||||
|
|
@ -624,7 +598,7 @@ impl<'a> Writer<'a> {
|
|||
}
|
||||
out.push_str("<hr");
|
||||
for (a, v) in attrs {
|
||||
write!(out, r#" {}=""#, a)?;
|
||||
write!(out, r#" {a}=""#)?;
|
||||
v.parts().for_each(|part| write_attr(part, out));
|
||||
out.push('"');
|
||||
}
|
||||
|
|
@ -655,7 +629,7 @@ fn write_escape(mut s: &str, escape_quotes: bool, out: &mut String) {
|
|||
'"' if escape_quotes => Some("""),
|
||||
_ => None,
|
||||
}
|
||||
.map_or(false, |s| {
|
||||
.is_some_and(|s| {
|
||||
ent = s;
|
||||
true
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue