summaryrefslogtreecommitdiff
path: root/src/syntax/tree.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-09-01 13:25:53 +0200
committerGitHub <noreply@github.com>2020-09-01 13:25:53 +0200
commit862f1ccad821820c10eef85c204e2b7b0c9f8d84 (patch)
tree1617d58f1ab23c0686c3f773752bb7b027acc3bf /src/syntax/tree.rs
parent798c8a10c861c6185f1fdee3b0ce3c46dcd96700 (diff)
parent280cd91474fc214d0684aeaa57e95d6f17163f2b (diff)
Merge pull request #15 from typst/headings
Add section headings 👨‍🦲
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,
-}