diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-14 22:33:22 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-14 22:34:43 +0100 |
| commit | 2a86e4db0bb3894d1cc3b94e1a1af31a6cd87b80 (patch) | |
| tree | d5c0954ef779689c40eb9b2f58d477869546ea89 /src/syntax/ast.rs | |
| parent | e50189cfa75d83ea1b74b1dc2cf1fc9c01f8c825 (diff) | |
Reference supplements
Diffstat (limited to 'src/syntax/ast.rs')
| -rw-r--r-- | src/syntax/ast.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index 2fdedbcf..8e48358d 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -101,7 +101,7 @@ pub enum Expr { Link(Link), /// A label: `<intro>`. Label(Label), - /// A reference: `@target`. + /// A reference: `@target`, `@target[..]`. Ref(Ref), /// A section heading: `= Introduction`. Heading(Heading), @@ -604,14 +604,23 @@ impl Label { } node! { - /// A reference: `@target`. + /// A reference: `@target`, `@target[..]`. Ref } impl Ref { /// Get the target. - pub fn get(&self) -> &str { - self.0.text().trim_start_matches('@') + pub fn target(&self) -> &str { + self.0 + .children() + .find(|node| node.kind() == SyntaxKind::RefMarker) + .map(|node| node.text().trim_start_matches('@')) + .unwrap_or_default() + } + + /// Get the supplement. + pub fn supplement(&self) -> Option<ContentBlock> { + self.0.cast_last_match() } } |
