weichenw/obsidian-hypothesis-plugin

How to customize file name?

Closed this issue · 3 comments

I have two requirements, and I didn't find how to implement them when I read the documentation.

  1. How to customize the file name
  2. How to get the Id of the article

My usage in Obsidian looks like this:

I need to set the title of the article to (take the SimpRead application as an example):

  Extract-SR{{Id}}-{{Title}}

This indicates:

  • This is an Extract (to distinguish it from my normal notes, to avoid being polluted by the title when using `[[]]``)
  • This Extract comes from SR (SimpRead)
  • The serial number (Id) of this Extract

I don't know if my idea is reasonable, but it is effective in my practice.

  1. Unfortunately there is no customisation of filename at this point in time. I am still looking into frontmatter that should be able to make this happen

  2. id generated by Hypothesis only comes with the highlights, not the article. Hope that makes sense.

Noting for posterity: I looked into doing this today, but encountered an architectural problem. If the user changes the file name template after a sync has already been performed, then the plugin won't be able to "line up" the old file names with new highlights added to those articles; it'll treat updates to previously-synced articles as it would a newly-highlighted article, creating a new note for those new highlights.

This is probably what @weichenw meant by the mention of frontmatter (#13): it seems like the "right" way to do this is probably to locate the article's file for updating by URL or some other unique indicator.

Noting for posterity: I looked into doing this today, but encountered an architectural problem. If the user changes the file name template after a sync has already been performed, then the plugin won't be able to "line up" the old file names with new highlights added to those articles; it'll treat updates to previously-synced articles as it would a newly-highlighted article, creating a new note for those new highlights.

This is probably what @weichenw meant by the mention of frontmatter (#13): it seems like the "right" way to do this is probably to locate the article's file for updating by URL or some other unique indicator.

If the file name template is changed during use, there is really no good way to match the new file name with the old file name. Matching through frontmatter is one way.

But I think the better way is not to match. Just use the new rules. This is my practice in SimpRead. The probability of changing the file name template midway is not too high, and the user can be guided to perform a full synchronization.

The synchronization between Obsidian and hypothesis is, after all, one-way synchronization, so many problems encountered in two-way synchronization will not be encountered here. I think full synchronization is an affordable cost.