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
This commit is contained in:
parent
f5f2bffce4
commit
43565ad1b6
|
|
@ -484,22 +484,26 @@ impl OrkState {
|
||||||
let lines: Vec<&str> = raw_body.lines().collect();
|
let lines: Vec<&str> = raw_body.lines().collect();
|
||||||
let mut result_lines = Vec::new();
|
let mut result_lines = Vec::new();
|
||||||
let mut in_drawer = false;
|
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 {
|
for line in lines {
|
||||||
let trimmed = line.trim();
|
let trimmed = line.trim();
|
||||||
|
|
||||||
// Skip planning line at the very start
|
// Skip empty lines before content
|
||||||
if first_line && (trimmed.starts_with("SCHEDULED:") ||
|
if !seen_content && trimmed.is_empty() {
|
||||||
trimmed.starts_with("DEADLINE:") ||
|
|
||||||
trimmed.starts_with("CLOSED:")) {
|
|
||||||
first_line = false;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
first_line = false;
|
|
||||||
|
|
||||||
// Handle drawer
|
// Skip planning lines at the start (before any content)
|
||||||
if trimmed.starts_with(":") && trimmed.ends_with(":") && trimmed.len() > 2 {
|
// 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];
|
let drawer_name = &trimmed[1..trimmed.len()-1];
|
||||||
if drawer_name.chars().all(|c| c.is_ascii_uppercase() || c == '_') {
|
if drawer_name.chars().all(|c| c.is_ascii_uppercase() || c == '_') {
|
||||||
in_drawer = true;
|
in_drawer = true;
|
||||||
|
|
@ -507,6 +511,7 @@ impl OrkState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle drawer end
|
||||||
if in_drawer {
|
if in_drawer {
|
||||||
if trimmed == ":END:" {
|
if trimmed == ":END:" {
|
||||||
in_drawer = false;
|
in_drawer = false;
|
||||||
|
|
@ -514,6 +519,8 @@ impl OrkState {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is actual content
|
||||||
|
seen_content = true;
|
||||||
result_lines.push(line);
|
result_lines.push(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue