From 493a9b3563ddcfab0cd1a9e9fa641042ee6b747e Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sun, 29 Jan 2023 13:34:10 +0100 Subject: [PATCH] heading event: limit level to u16 --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4fa6e3e..1f060b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,7 @@ pub enum Container<'s> { /// A paragraph. Paragraph, /// A heading. - Heading { level: usize }, + Heading { level: u16 }, /// A cell element of row within a table. TableCell { alignment: Alignment, head: bool }, /// A caption within a table. @@ -560,7 +560,7 @@ impl<'s> Parser<'s> { match l { block::Leaf::Paragraph => Container::Paragraph, block::Leaf::Heading => Container::Heading { - level: content.len(), + level: content.len().try_into().unwrap(), }, block::Leaf::CodeBlock => { if let Some(format) = content.strip_prefix('=') {