diff options
| author | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 18:56:14 -0400 |
|---|---|---|
| committer | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 18:56:14 -0400 |
| commit | ce524225a4c74aed82813b9bc067fd54c8160516 (patch) | |
| tree | e320077b0c1f1ec7be972694cb29ef654b648f94 /src/helpers.rs | |
| parent | f0c2eecc2c53f9bea72783cc376a337892b5a392 (diff) | |
| download | iphone-notes-ce524225a4c74aed82813b9bc067fd54c8160516.tar.gz iphone-notes-ce524225a4c74aed82813b9bc067fd54c8160516.tar.bz2 iphone-notes-ce524225a4c74aed82813b9bc067fd54c8160516.tar.xz iphone-notes-ce524225a4c74aed82813b9bc067fd54c8160516.zip | |
feat: format notes with Apple Notes-style structure
Rewrite Markdown bodies into title, headings, spaced paragraphs, and
Notes-friendly lists so iPhone notes no longer look like raw dumps.
Co-authored-by: Cursor <cursoragent@cursor.com>
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] |
