Issue Description
The tokenize_markdown function in src/tokenize.rs unconditionally calls out.pop() at line 150 to remove the final newline token. This could panic if the output vector is empty or incorrectly remove a non-newline token if the input doesn't end with a newline.
Location
- File:
src/tokenize.rs
- Lines: 150-151
Problem
The unconditional pop() operation assumes:
- The vector is not empty
- The last token is always a newline
Suggested Fix
Add a guard to only remove the final token if it's actually a newline:
if matches!(out.last(), Some(Token::Newline)) {
out.pop();
}
out
Context
Requested by
@leynos
Issue Description
The
tokenize_markdownfunction insrc/tokenize.rsunconditionally callsout.pop()at line 150 to remove the final newline token. This could panic if the output vector is empty or incorrectly remove a non-newline token if the input doesn't end with a newline.Location
src/tokenize.rsProblem
The unconditional
pop()operation assumes:Suggested Fix
Add a guard to only remove the final token if it's actually a newline:
Context
Requested by
@leynos