Skip to content

Commit 409843f

Browse files
committed
fix(parse_clippings): skip notes
1 parent ee7f02a commit 409843f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/main.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ fn parse_clippings(content: &str) -> Vec<Clipping> {
162162
};
163163

164164
let meta = lines[1].trim();
165+
if meta.contains("Your Note") {
166+
eprintln!("warning: skipping note in \"{}\" ({})", title, meta);
167+
continue;
168+
}
165169
let page = page_re.captures(meta).map(|c| c[1].to_string());
166170
let (location_start, location_end) = match location_re.captures(meta) {
167171
Some(cap) => (
@@ -398,6 +402,26 @@ imagine, as indeed I had, many times."
398402
);
399403
}
400404

405+
const WITH_NOTE: &str = "\
406+
\u{feff}The Morning Star (Knausgaard, Karl Ove)
407+
- Your Note on page 309 | Location 5117 | Added on Thursday, September 18, 2025 8:47:00 PM
408+
409+
A personal annotation about the preceding passage.
410+
==========
411+
\u{feff}The Morning Star (Knausgaard, Karl Ove)
412+
- Your Highlight on page 309 | Location 5115-5117 | Added on Thursday, September 18, 2025 8:46:43 PM
413+
414+
I thought to myself, or pictured in my mind—for thoughts come as both pictures and words, a bit like light, which comes as both particles and waves, one could imagine, as indeed I had, many times.
415+
==========";
416+
417+
#[test]
418+
fn test_note_skipped() {
419+
let clips = parse_clippings(WITH_NOTE);
420+
assert_eq!(clips.len(), 1);
421+
assert_eq!(clips[0].title, "The Morning Star");
422+
assert!(!clips[0].body.contains("personal annotation"));
423+
}
424+
401425
#[test]
402426
fn test_merge_subset() {
403427
let clips = parse_clippings(SUBSET_PAIR);

0 commit comments

Comments
 (0)