feat: support backslash line breaks for formatting in steps and notes#256
feat: support backslash line breaks for formatting in steps and notes#256
Conversation
This comment has been minimized.
This comment has been minimized.
The Cooklang parser converts backslash-newline sequences into literal newline characters in text items. This change makes both the CLI and web UI honor those newlines for precise formatting control. CLI (human-readable output): - Step text containing newlines is split into paragraphs, each properly indented under the step number - Note text containing newlines preserves line breaks with consistent indentation Web UI: - Added LineBreak variant to StepItem enum, rendered as <br> in HTML - Text items are split on newline characters into separate Text and LineBreak items during template data construction - Note paragraphs use white-space: pre-line for newline rendering https://claude.ai/code/session_01YUd1SFaAakySfqdq4qBYnD
7f10161 to
40f4987
Compare
This comment has been minimized.
This comment has been minimized.
Fixes clippy::unnecessary_unwrap warnings in latex, markdown, and typst output formatters. https://claude.ai/code/session_01YUd1SFaAakySfqdq4qBYnD
Pull Request Review: Backslash Line Break SupportSummaryThis PR adds support for backslash-newline sequences in recipe steps and notes, enabling precise formatting control in both CLI and web UI. The implementation is generally well-executed with good attention to detail. ✅ Strengths
🔍 Code Quality Issues1. Potential Issue: Empty Paragraph Handling (CLI)Location: The CLI implementation doesn't filter empty paragraphs after splitting on Current code: let paragraphs: Vec<&str> = step_text.trim().split('\n').collect();
for (i, paragraph) in paragraphs.iter().enumerate() {
if i == 0 {
let first = format\!("{:>2}. {}", step.number, paragraph.trim_start());
print_wrapped_with_options(w, &first, |o| o.subsequent_indent(" "))?;
} else {
print_wrapped_with_options(w, paragraph.trim_start(), |o| {
o.initial_indent(" ").subsequent_indent(" ")
})?;
}
}Suggested fix: let paragraphs: Vec<&str> = step_text.trim().split('\n').filter(|p| \!p.trim().is_empty()).collect();Same issue exists at line 453 for notes. 2. Inconsistency: Web UI Empty Text CheckLocation: The Web UI filters empty parts (
This means Suggested approach: 3. Template ReadabilityLocation: The entire step rendering logic is on a single 900+ character line, making it very difficult to maintain. While this is a pre-existing issue, adding Recommendation: Consider breaking the template into multiple lines or extracting a partial template for step items. 🔒 Security ConsiderationsXSS Risk Assessment: ✅ SAFE
⚡ Performance Considerations
Verdict: Performance impact is minimal and acceptable. 🧪 Test CoverageIssue: No tests were added for this feature. Given the scope of changes across multiple output formats, I recommend adding:
The repository has existing test infrastructure in
📋 Minor Observations
📊 Best Practices AlignmentPer
🎯 RecommendationsMust Fix (before merge):
Should Consider (optional): Nice to Have: 📝 Overall AssessmentThis is a solid implementation of a useful feature. The code quality is good, and the clippy fixes are a welcome bonus. The main concerns are:
With the empty paragraph filtering fix, this PR would be ready to merge. The test coverage gap is consistent with the project's current state (as noted in CONTRIBUTING.md) but should be addressed eventually. Recommendation: ✅ Approve with minor fixes Great work on this feature! The backslash-newline support will give recipe authors much better control over formatting. |
The Cooklang parser converts backslash-newline sequences into literal
newline characters in text items. This change makes both the CLI and
web UI honor those newlines for precise formatting control.
CLI (human-readable output):
indented under the step number
indentation
Web UI:
in HTML
LineBreak items during template data construction
https://claude.ai/code/session_01YUd1SFaAakySfqdq4qBYnD