Syncing highlights/annotations between PDF and markdown

When annotating PDFs I’m sometimes doing this in the PDF directly, sometimes I copy/paste text into a markdown (annotation) file from the PDF (or from the web page I clipped to PDF). I’m working on writing a script that can sync highlights/annotation between Markdown and PDF.

I’m describing a proposed workflow for doing this below - I’m sure I might have overlooked some things. Happy to hear any suggestions or feedback!

Start situation

  • Higlights A,B,C (+ comments) in annotation (Markdown)
  • Highlights A,C,D (+ comments) in PDF

Workflow (steps)

  1. Extract annotations+notes from PDF to sheet using summarize higlights
  2. Extract annotations+notes from Markdown to sheet using regular expressions
  3. Get PDF location for each annotation+notes in sheet to determine sort order using a PDF search script (e.g. based on this: Text highlighting via script-function - #25 by pete31)
  4. Write list of annotation+notes (in order) from sheet to Markdown
  5. Write list of annotation+notes (in order) from sheet to PDF

Questions to solve

  • What to do if a markdown annotation is not found in PDF (-> add to back/front of markdown, e.g. in front of the first > blockquote)
  • What if the same highlights has different comments (-> set preferred source)
  • Would it be preferable to ‘update’ annotations in PDF or remove them all and then re-add them?
Example annotation file
---
date: 2022-05-08 22:43
url: https://annehelen.substack.com/p/youre-still-not-working-from-home
itemurl: x-devonthink-item://5C89CF00-7BD6-4FFC-AF02-3440C9EA7035
annotationurl: x-devonthink-item://A6B3D685-D6F5-4626-9197-1F47EFE6771F
path: you're still not working from home.pdf
tags: [review]
---

excerpt:: This is the Sunday edition of Culture Study — the newsletter from Anne Helen Petersen, which you can read about here. If you like it and want more like it in your inbox, consider subscribing. A very weird thing about writing books = you often start thinking about your next one as you’re in the process of promoting the current one. I finished the fact checking and copy editing process on

via:: [[Dense Discovery – Issue 182]]

This article peaked my interested because most articles by Anne Helen Petersen are quite thought provoking and interesting.

> But you’re not working from home. You are laboring in confinement and under duress.   

Well, that's one way to look at it...

> Here’s the nightmare scenario: this could be the future.   

Sure hope not.
2 Likes

Is there any progress on this?

Sorry - I’ve been quite busy. When I’ve got more time I’ll report back here.

This looks very promising. Waiting for an update…!