Retrieve annotations for Hypothes.is via Templater plugin (Hypothes.idian)

I unfortunately don’t have mac, but I’ll surely check out the first one. Thanks a lot!:slight_smile:

You can drag and drop .pdf files from your computer into https://docdrop.org/, which is a project built by Hypothes.is, and that should allow you to be able to annotate raw .pdf files within your browser if they’re not hosted elsewhere.

3 Likes

If you’ve annotated local (private) files within your browser using Hypothes.is, you’ll need to find the uri path (a rough equivalent to http address for web pages) for your .pdf file with its “fingerprint” (a long unique number).

To do this

  1. Visit View and export Hypothesis annotations
  2. Search for your Hypothes.is username (and perhaps a tag) to find the document name and annotations you made on it.
  3. You should be able to click on the document title which will take you to a non-loading web page with an address that looks something like this:
    urn:x-pdf:1ab23cd45e678fgh9012i34j56k78l90
  4. Copy and paste that address you get into Hypothesidian as the address for an appropriate option like “Retrieve my annotations for a web article or web pdf”.
  5. Hit enter/return.
  6. Hypothesidian should return the appropriate annotations for that document.

If others know of alternate/faster methods of finding URis for local pdf files I’d be happy to hear about them.

Thanks for the help getting my locally annotated files into Obsidian!

I ran against an issue when the Hypothes.is didn’t store the file name. By replacing the apiAnnotationSimplify method with this more error handling variant I was able to also get the highlights of files without titles.

const apiAnnotationSimplify = async (results) => {
  return results.rows.map(e => {
    const r = {
      title: e.document?.title?.[0] || '', // Handle potential undefined title
      uri: e.uri || '', // Handle potential undefined URI
      context: e.links?.incontext || '', // Handle potential undefined incontext
      text: e.text || '', // Handle potential undefined text
      highlight: '',
      tags: e.tags || [], // Handle potential undefined tags
      user: e.user || '', // Handle potential undefined user
      group: e.group || '', // Handle potential undefined group
      created: e.created || '', // Handle potential undefined created
      updated: e.updated || '', // Handle potential undefined updated
    };

    try {
      if (e.target && e.target[0] && e.target[0].selector) {
        const txt = e.target[0].selector.filter(e => e.type === 'TextQuoteSelector');
        if (txt && txt.length > 0) { // Check if txt is not empty
          r.highlight = txt[0].exact || ''; // Handle potential undefined exact
        }
      }
    } catch (error) {
      console.error('Error processing annotation:', error); // Log the error for debugging
    }

    return r;
  });
};