From 43565ad1b6e806a049b628ca750295284edf0a18 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 1 Oct 2026 10:10:45 +0200 Subject: [PATCH] Fix planning line stripping in section_body - Use 'contains' instead of 'starts_with' to handle combined lines like 'SCHEDULED: <...> DEADLINE: <...>' - Track 'seen_content' to strip planning/drawers only at the start - Skip empty lines before content - Continue stripping planning lines until real content appears --- crates/ork-server/src/state.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/crates/ork-server/src/state.rs b/crates/ork-server/src/state.rs index dc117da..2e906c3 100644 --- a/crates/ork-server/src/state.rs +++ b/crates/ork-server/src/state.rs @@ -484,22 +484,26 @@ impl OrkState { let lines: Vec<&str> = raw_body.lines().collect(); let mut result_lines = Vec::new(); let mut in_drawer = false; - let mut first_line = true; + let mut seen_content = false; // Have we seen actual content yet? for line in lines { let trimmed = line.trim(); - // Skip planning line at the very start - if first_line && (trimmed.starts_with("SCHEDULED:") || - trimmed.starts_with("DEADLINE:") || - trimmed.starts_with("CLOSED:")) { - first_line = false; + // Skip empty lines before content + if !seen_content && trimmed.is_empty() { continue; } - first_line = false; - // Handle drawer - if trimmed.starts_with(":") && trimmed.ends_with(":") && trimmed.len() > 2 { + // Skip planning lines at the start (before any content) + // Planning lines contain SCHEDULED:, DEADLINE:, or CLOSED: + if !seen_content && (trimmed.contains("SCHEDULED:") || + trimmed.contains("DEADLINE:") || + trimmed.contains("CLOSED:")) { + continue; + } + + // Handle drawer start + if trimmed.starts_with(':') && trimmed.ends_with(':') && trimmed.len() > 2 { let drawer_name = &trimmed[1..trimmed.len()-1]; if drawer_name.chars().all(|c| c.is_ascii_uppercase() || c == '_') { in_drawer = true; @@ -507,6 +511,7 @@ impl OrkState { } } + // Handle drawer end if in_drawer { if trimmed == ":END:" { in_drawer = false; @@ -514,6 +519,8 @@ impl OrkState { continue; } + // This is actual content + seen_content = true; result_lines.push(line); }