From a346a61c7c94e8c261b74aa3a58c12d8eb3b2734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 23 Nov 2023 17:08:47 +0100 Subject: [PATCH] support indented nested list items in .md files --- samples/README.md | 6 +++--- samples/todo.md | 4 ++-- src/scan.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/samples/README.md b/samples/README.md index 2b6fc26..a73b428 100644 --- a/samples/README.md +++ b/samples/README.md @@ -11,12 +11,12 @@ abc def - foo -- baz + - baz - [ ] baz ## TODOs - abc -- todo0 def + - todo0 def - [ ] bar -- [ ] baz + - [ ] baz diff --git a/samples/todo.md b/samples/todo.md index 3642bfc..3cc4cc6 100644 --- a/samples/todo.md +++ b/samples/todo.md @@ -4,8 +4,8 @@ ## High priority - todo0 a -- foo -- [ ] bar + - foo + - [ ] bar ## Responsivity - abc diff --git a/src/scan.rs b/src/scan.rs index 35ebfec..9d5306d 100644 --- a/src/scan.rs +++ b/src/scan.rs @@ -161,7 +161,7 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec) -> io::Result<()> { continue; } - if ! line.starts_with('-') { + if ! line.trim_start().starts_with('-') { continue; } @@ -182,7 +182,7 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec) -> io::Result<()> { } } - let text = line.trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(); + let text = line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(); if let Some(category) = current_category { entries.push(Entry { @@ -234,7 +234,7 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec) -> io::Result<()> continue; } - if ! line.starts_with('-') { + if ! line.trim_start().starts_with('-') { continue; } @@ -257,7 +257,7 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec) -> io::Result<()> // README.md can only have priority entries and generic entries entries.push(Entry { - text: line.trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(), + text: line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(), location: Location { file: path.to_path_buf(), line: line_num + 1,