summaryrefslogtreecommitdiff
path: root/src/syntax/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax/ast.rs')
-rw-r--r--src/syntax/ast.rs17
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()
}
}