diff options
Diffstat (limited to 'src/helpers.rs')
| -rw-r--r-- | src/helpers.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/helpers.rs b/src/helpers.rs index 3ea7e37..b87ff76 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,13 +1,15 @@ //! Pure helpers (no Chromium). -/// Join title + body the way Apple Notes expects (first line = title). +use crate::format::{format_apple_note, build_paragraphs, Paragraph}; + +/// Format title + body for Apple Notes (Title / headings / lists / body spacing). pub fn format_note_text(title: &str, body: &str) -> String { - match (title.is_empty(), body.is_empty()) { - (true, true) => String::new(), - (false, true) => title.to_string(), - (true, false) => body.to_string(), - (false, false) => format!("{title}\n\n{body}"), - } + format_apple_note(title, body) +} + +/// Structured paragraphs (for browser styling when available). +pub fn note_paragraphs(title: &str, body: &str) -> Vec<Paragraph> { + build_paragraphs(title, body) } pub fn is_apple_auth_url(url: &str) -> bool { @@ -103,8 +105,9 @@ mod tests { #[test] fn format_joins_title_body() { assert_eq!(format_note_text("Hi", "body"), "Hi\n\nbody"); - assert_eq!(format_note_text("Hi", ""), "Hi"); - assert_eq!(format_note_text("", "body"), "body"); + assert!(format_note_text("Hi", "").starts_with("Hi")); + let body_only = format_note_text("", "Just a body paragraph."); + assert!(body_only.contains("Just a body paragraph.")); } #[test] |
