summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eval/library.rs2
-rw-r--r--src/syntax/ast.rs2
-rw-r--r--src/syntax/lexer.rs10
3 files changed, 5 insertions, 9 deletions
diff --git a/src/eval/library.rs b/src/eval/library.rs
index 85d5647b..5b0ff8e6 100644
--- a/src/eval/library.rs
+++ b/src/eval/library.rs
@@ -74,7 +74,7 @@ pub struct LangItems {
/// An item in a bullet list: `- ...`.
pub list_item: fn(body: Content) -> Content,
/// An item in an enumeration (numbered list): `+ ...` or `1. ...`.
- pub enum_item: fn(number: Option<NonZeroUsize>, body: Content) -> Content,
+ pub enum_item: fn(number: Option<usize>, body: Content) -> Content,
/// An item in a term list: `/ Term: Details`.
pub term_item: fn(term: Content, description: Content) -> Content,
/// A mathematical equation: `$x$`, `$ x^2 $`.
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index bd8fa230..b064da88 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -681,7 +681,7 @@ node! {
impl EnumItem {
/// The explicit numbering, if any: `23.`.
- pub fn number(&self) -> Option<NonZeroUsize> {
+ pub fn number(&self) -> Option<usize> {
self.0.children().find_map(|node| match node.kind() {
SyntaxKind::EnumMarker => node.text().trim_end_matches('.').parse().ok(),
_ => Option::None,
diff --git a/src/syntax/lexer.rs b/src/syntax/lexer.rs
index 90a10f52..c46fa37b 100644
--- a/src/syntax/lexer.rs
+++ b/src/syntax/lexer.rs
@@ -170,7 +170,6 @@ impl Lexer<'_> {
'`' => self.raw(),
'h' if self.s.eat_if("ttp://") => self.link(),
'h' if self.s.eat_if("ttps://") => self.link(),
- '0'..='9' => self.numbering(start),
'<' if self.s.at(is_id_continue) => self.label(),
'@' => self.ref_marker(),
@@ -200,6 +199,7 @@ impl Lexer<'_> {
'-' if self.space_or_end() => SyntaxKind::ListMarker,
'+' if self.space_or_end() => SyntaxKind::EnumMarker,
'/' if self.space_or_end() => SyntaxKind::TermMarker,
+ '0'..='9' => self.numbering(start),
_ => self.text(),
}
@@ -284,12 +284,8 @@ impl Lexer<'_> {
self.s.eat_while(char::is_ascii_digit);
let read = self.s.from(start);
- if self.s.eat_if('.') {
- if let Ok(number) = read.parse::<usize>() {
- if number == 0 {
- return self.error("must be positive");
- }
-
+ if self.s.eat_if('.') && self.space_or_end() {
+ if read.parse::<usize>().is_ok() {
return SyntaxKind::EnumMarker;
}
}