summaryrefslogtreecommitdiff
path: root/src/syntax/tree.rs
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2020-09-01 13:10:48 +0200
committerMartin Haug <mhaug@live.de>2020-09-01 13:10:48 +0200
commitd986bc4b0a35957c3f5cece82497c69e957f5c79 (patch)
treeacbf164c604f9c085866b23d7500b9282be12f2a /src/syntax/tree.rs
parent798c8a10c861c6185f1fdee3b0ce3c46dcd96700 (diff)
Add section headings 👨‍🦲
Co-authored-by: Laurenz Mädje <laurmaedje@gmail.com>
Diffstat (limited to 'src/syntax/tree.rs')
-rw-r--r--src/syntax/tree.rs25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/syntax/tree.rs b/src/syntax/tree.rs
index 7295ec04..94dfc124 100644
--- a/src/syntax/tree.rs
+++ b/src/syntax/tree.rs
@@ -31,6 +31,8 @@ pub enum SyntaxNode {
ToggleBolder,
/// Plain text.
Text(String),
+ /// Section headings.
+ Heading(Heading),
/// Lines of raw text.
Raw(Vec<String>),
/// An optionally highlighted (multi-line) code block.
@@ -39,6 +41,22 @@ pub enum SyntaxNode {
Call(CallExpr),
}
+/// A section heading.
+#[derive(Debug, Clone, PartialEq)]
+pub struct Heading {
+ /// The section depth (how many hashtags minus 1).
+ pub level: Spanned<u8>,
+ pub tree: SyntaxTree,
+}
+
+/// A code block.
+#[derive(Debug, Clone, PartialEq)]
+pub struct Code {
+ pub lang: Option<Spanned<Ident>>,
+ pub lines: Vec<String>,
+ pub block: bool,
+}
+
/// An expression.
#[derive(Clone, PartialEq)]
pub enum Expr {
@@ -197,10 +215,3 @@ impl CallExpr {
}
}
}
-/// A code block.
-#[derive(Debug, Clone, PartialEq)]
-pub struct Code {
- pub lang: Option<Spanned<Ident>>,
- pub lines: Vec<String>,
- pub block: bool,
-}