diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-06-11 14:00:06 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-11 14:00:06 +0200 |
| commit | 4dbd9285c91d59d527f4324df4aaf239ecb007ca (patch) | |
| tree | 561a9a18a1eea6a2e598157f305667c4ea8e3e08 /src/pretty.rs | |
| parent | 3330767c20e14a05176902a93dcefb08cb509173 (diff) | |
Basic enums
Diffstat (limited to 'src/pretty.rs')
| -rw-r--r-- | src/pretty.rs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/pretty.rs b/src/pretty.rs index 1281e27b..e2942f6f 100644 --- a/src/pretty.rs +++ b/src/pretty.rs @@ -97,13 +97,14 @@ impl Pretty for Node { Self::Strong(_) => p.push('*'), Self::Emph(_) => p.push('_'), Self::Raw(raw) => raw.pretty(p), - Self::Heading(heading) => heading.pretty(p), - Self::List(list) => list.pretty(p), - Self::Expr(expr) => { - if expr.has_short_form() { + Self::Heading(n) => n.pretty(p), + Self::List(n) => n.pretty(p), + Self::Enum(n) => n.pretty(p), + Self::Expr(n) => { + if n.has_short_form() { p.push('#'); } - expr.pretty(p); + n.pretty(p); } } } @@ -175,13 +176,23 @@ impl Pretty for HeadingNode { } } -impl Pretty for ListNode { +impl Pretty for ListItem { fn pretty(&self, p: &mut Printer) { p.push_str("- "); self.body.pretty(p); } } +impl Pretty for EnumItem { + fn pretty(&self, p: &mut Printer) { + if let Some(number) = self.number { + write!(p, "{}", number).unwrap(); + } + p.push_str(". "); + self.body.pretty(p); + } +} + impl Pretty for Expr { fn pretty(&self, p: &mut Printer) { match self { |
