summaryrefslogtreecommitdiff
path: root/src/syntax
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-22 18:25:29 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-22 18:25:29 +0100
commit8527517258cf62a2f229796cc3f118d8bf0494b6 (patch)
tree7662e90bcb9d610e63f4b1a9f1f12f84cb1f742a /src/syntax
parent947522b71aa6220ce8f006bfab4700d6e3cb04f1 (diff)
Rename `desc` to `terms`
Diffstat (limited to 'src/syntax')
-rw-r--r--src/syntax/ast.rs28
-rw-r--r--src/syntax/kind.rs19
-rw-r--r--src/syntax/parsing.rs6
3 files changed, 25 insertions, 28 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index 5847e816..d2b19ee3 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -101,12 +101,12 @@ pub enum MarkupNode {
Ref(Ref),
/// A section heading: `= Introduction`.
Heading(Heading),
- /// An item in an unordered list: `- ...`.
+ /// An item in a bullet list: `- ...`.
List(ListItem),
- /// An item in an enumeration (ordered list): `+ ...` or `1. ...`.
+ /// An item in an enumeration (numbered list): `+ ...` or `1. ...`.
Enum(EnumItem),
- /// An item in a description list: `/ Term: Details`.
- Desc(DescItem),
+ /// An item in a term list: `/ Term: Details`.
+ Term(TermItem),
/// An expression.
Expr(Expr),
}
@@ -129,7 +129,7 @@ impl AstNode for MarkupNode {
SyntaxKind::Heading => node.cast().map(Self::Heading),
SyntaxKind::ListItem => node.cast().map(Self::List),
SyntaxKind::EnumItem => node.cast().map(Self::Enum),
- SyntaxKind::DescItem => node.cast().map(Self::Desc),
+ SyntaxKind::TermItem => node.cast().map(Self::Term),
_ => node.cast().map(Self::Expr),
}
}
@@ -151,7 +151,7 @@ impl AstNode for MarkupNode {
Self::Heading(v) => v.as_untyped(),
Self::List(v) => v.as_untyped(),
Self::Enum(v) => v.as_untyped(),
- Self::Desc(v) => v.as_untyped(),
+ Self::Term(v) => v.as_untyped(),
Self::Expr(v) => v.as_untyped(),
}
}
@@ -362,7 +362,7 @@ impl Heading {
}
node! {
- /// An item in an unordered list: `- ...`.
+ /// An item in a bullet list: `- ...`.
ListItem
}
@@ -374,7 +374,7 @@ impl ListItem {
}
node! {
- /// An item in an enumeration (ordered list): `+ ...` or `1. ...`.
+ /// An item in an enumeration (numbered list): `+ ...` or `1. ...`.
EnumItem
}
@@ -394,23 +394,21 @@ impl EnumItem {
}
node! {
- /// An item in a description list: `/ Term: Details`.
- DescItem
+ /// An item in a term list: `/ Term: Details`.
+ TermItem
}
-impl DescItem {
+impl TermItem {
/// The term described by the item.
pub fn term(&self) -> Markup {
- self.0
- .cast_first_child()
- .expect("description list item is missing term")
+ self.0.cast_first_child().expect("term list item is missing term")
}
/// The description of the term.
pub fn description(&self) -> Markup {
self.0
.cast_last_child()
- .expect("description list item is missing description")
+ .expect("term list item is missing description")
}
}
diff --git a/src/syntax/kind.rs b/src/syntax/kind.rs
index 02e972c4..27a8da0f 100644
--- a/src/syntax/kind.rs
+++ b/src/syntax/kind.rs
@@ -39,8 +39,7 @@ pub enum SyntaxKind {
/// A semicolon terminating an expression: `;`.
Semicolon,
/// A colon between name/key and value in a dictionary, argument or
- /// parameter list, or between the term and body of a description list
- /// term: `:`.
+ /// parameter list, or between the term and body of a term list term: `:`.
Colon,
/// The strong text toggle, multiplication operator, and wildcard import
/// symbol: `*`.
@@ -54,8 +53,8 @@ pub enum SyntaxKind {
/// The unary negation, binary subtraction operator, and start of list
/// items: `-`.
Minus,
- /// The division operator, start of description list items, and fraction
- /// operator in a formula: `/`.
+ /// The division operator, start of term list items, and fraction operator
+ /// in a formula: `/`.
Slash,
/// The superscript operator in a formula: `^`.
Hat,
@@ -163,14 +162,14 @@ pub enum SyntaxKind {
Ref(EcoString),
/// A section heading: `= Introduction`.
Heading,
- /// An item in an unordered list: `- ...`.
+ /// An item in a bullet list: `- ...`.
ListItem,
- /// An item in an enumeration (ordered list): `+ ...` or `1. ...`.
+ /// An item in an enumeration (numbered list): `+ ...` or `1. ...`.
EnumItem,
/// An explicit enumeration numbering: `23.`.
EnumNumbering(NonZeroUsize),
- /// An item in a description list: `/ Term: Details`.
- DescItem,
+ /// An item in a term list: `/ Term: Details`.
+ TermItem,
/// A mathematical formula: `$x$`, `$ x^2 $`.
Math,
/// An atom in a formula: `x`, `+`, `12`.
@@ -405,7 +404,7 @@ impl SyntaxKind {
Self::ListItem => "list item",
Self::EnumItem => "enumeration item",
Self::EnumNumbering(_) => "enumeration item numbering",
- Self::DescItem => "description list item",
+ Self::TermItem => "term list item",
Self::Math => "math formula",
Self::Atom(s) => match s.as_str() {
"(" => "opening paren",
@@ -533,7 +532,7 @@ impl Hash for SyntaxKind {
Self::ListItem => {}
Self::EnumItem => {}
Self::EnumNumbering(num) => num.hash(state),
- Self::DescItem => {}
+ Self::TermItem => {}
Self::Math => {}
Self::Atom(c) => c.hash(state),
Self::Script => {}
diff --git a/src/syntax/parsing.rs b/src/syntax/parsing.rs
index d751b6aa..e0405407 100644
--- a/src/syntax/parsing.rs
+++ b/src/syntax/parsing.rs
@@ -247,7 +247,7 @@ fn markup_node(p: &mut Parser, at_start: &mut bool) {
SyntaxKind::Minus => list_item(p, *at_start),
SyntaxKind::Plus | SyntaxKind::EnumNumbering(_) => enum_item(p, *at_start),
SyntaxKind::Slash => {
- desc_item(p, *at_start).ok();
+ term_item(p, *at_start).ok();
}
SyntaxKind::Colon => {
let marker = p.marker();
@@ -341,7 +341,7 @@ fn enum_item(p: &mut Parser, at_start: bool) {
}
}
-fn desc_item(p: &mut Parser, at_start: bool) -> ParseResult {
+fn term_item(p: &mut Parser, at_start: bool) -> ParseResult {
let marker = p.marker();
let text: EcoString = p.peek_src().into();
p.eat();
@@ -351,7 +351,7 @@ fn desc_item(p: &mut Parser, at_start: bool) -> ParseResult {
markup_line(p, |node| matches!(node, SyntaxKind::Colon));
p.expect(SyntaxKind::Colon)?;
markup_indented(p, min_indent);
- marker.end(p, SyntaxKind::DescItem);
+ marker.end(p, SyntaxKind::TermItem);
} else {
marker.convert(p, SyntaxKind::Text(text));
}