Giter Site home page Giter Site logo

weichenw / obsidian-hypothesis-plugin Goto Github PK

View Code? Open in Web Editor NEW
230.0 8.0 21.0 63 KB

An Obsidian.md plugin that syncs highlights from Hypothesis.

License: MIT License

TypeScript 82.99% JavaScript 3.14% Nunjucks 1.86% Svelte 9.26% HTML 2.75%
plugin highlights annotations hypothesis obsidian-md obsidian-plugin

obsidian-hypothesis-plugin's People

Contributors

chenyukang avatar mschrader15 avatar phgn0 avatar radekkozak avatar weichenw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obsidian-hypothesis-plugin's Issues

How to customize file name?

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.

Support sync annotations added later

Currently, annotations added as follows would not be synced:

  • One syncs highlights into Obsidian
  • One adds/updates some annotations to a "file" that has been synced into Obsidian
  • One syncs everything into Obsidian

It would be great if annotations added after syncing the file can be updated into the existing file.

Sync seems to be broken in mobile version of Obsidian

Love that you made this and it works great on desktop/computers. However on iOS version of Obsidian, it creates the folder but doesn't put anything in it so it's empty. Let me know how I can help debug this.

Thank you!
Ray

Strange whitespaces in my highlight

website: https://www.w3.org/publishing/epub32/epub-packages.html
I highlighted several sentences in this website, for example: The package element is the root element of the Package Document and defines various aspects of the EPUB Package
However, the synced highlight text becomes: image
As you can see, there are strange whitespaces.
I have checked on my personal page to make sure that the highlight text on hypothes.is server does not have so many whitespaces.

Resync Hypothes.is articles

It would be great that you can resync new notes on an article as you do on Omnivore Obsidian app for example.

Dataview compatibility metadata

I'm trying to create 2 metadata fields with the creation and update date that is compatible with dataview, but I can't.
Could you help me?

No highlights/annotations are synced after installation (web not pdf)

The integration works just fine, however, annotations and highlights are not detected
image

even tho I have 10 highlights and annotations in my Hypothesis.is
image

the plugin detects my groups no problem, but it just doesn't detect the content
image

It's worth mentioning I tried restarting Obsidian, tried reconnecting the API, but to no avail

Couldn't get it to sync

Hi I don't know what's wrong with my setup but the plugin doesn't do anything.
image

I have clicked the hypothesis icon on the ribbon and run command to trigger manual sync but nothing happened.
I have close and restart Obsidian, tried the plugin on multiple vaults, and restart my PC, but nothing worked.
Please let me know where I have set things up wrong.

Edit: After posting this I got it to run somehow on 1 of the 3 vaults I tried. However, it still didn't do anything
image

I certainly have highlights in my hypothesis account, but no idea why it doesn't sync.
image

Creation date as backlink

Is it possible to have the creation date as backlink [[YYYY-MM-DD]] in a template, so that my daily note would show it at linked mentions?

File name cannot be created correctly if it contains :

For instance, if a file name is File: A, then the created note would be File, i.e. everything after : would be omitted. As a result, if there would be a new file called File: B, then all highlights corresponding to File: B would be synced into File as well.

Therefore, it would be great if special symbols like : would be handled properly. For instance, symbols like : can be replaced by _ or spaces.

Incorrect line spacing between highlights

Your plugin works fine but I have noticed a problem:

At the end of the loop there is no instruction that creates a line break, so the highlights after the first are written on the same line corresponding to the last. That last line break instruction is required.

If you could add a variable whose function is the line break that would be great.

PD. At the moment I have partially solved it with double <br> at some point in the template.

"Untitled document" do not sync

I'm finding that there are some web pages that either do not have a title defined or that the title does not get picked up by Hypothes.is. In Hypothes.is these get titled as "Untitled document" and annoations/highlights do not get synced to Obsidian.

Here is an example:
CleanShot 2022-01-20 at 13 48 25

Better support for multiple-line notes

It would be great if the multiple-line notes can be synced as sub list items, to better style multiple-line notes.

The note:

First line
Second line

The desired synced note: (This is also the Readwise Official plugin handles multiple-line notes.)

- [ ] First line
    - Second line

The template:

{% if is_new_article %}# {{title}}

{% if is_new_article %}## Metadata{% endif %}

{% if is_new_article %}{% if author %}- Author:: [{{author}}]({{authorUrl}}){% endif %}
- Title:: {{title}}
- Category Hypothesis:: Article{% endif %}
{% if url %}- Source URL:: {{url}}{% endif %}{% endif %}

{% if is_new_article %}## Highlights{% endif %}

{% for highlight in highlights %}> {{highlight.text}} (View Highlight [{{highlight.location}}]({{highlight.incontext}})) ^hs{{highlight.id}}{% if highlight.tags | length %}
- Tag: {% for tag in highlight.tags %}#{{tag| replace(" ", "-")}} {% endfor %}{% endif %}{% if highlight.annotation %}
- [ ] {{highlight.annotation}}{% endif %}{% if highlight.created %}
- Highlighted on {{highlight.created}}{% endif %}{% if highlight.updated %}
- Updated on {{highlight.updated}}{% endif %}

{% endfor %}

no proper support for reply highlights

when replying to a annotation.
the reply is not linked to the annotation in hypothesis

instead it is treated as a new annotation, with no highlight.text

image image

Random public annotations & page notes appear after sync

Thanks for creating this plugin! It synced my hypothesis highlights correctly. (Edit: I found out later that it's not syncing all my page highlights: some but not all highlights belonging to a self-owned private group got lost. This got solved by #58 (comment) )

However, it also for some reason synced 1 public annotations and 1 page notes from other users:

https://stackoverflow.com/questions/57369700/how-do-i-add-permissions-to-activestorage
https://arxiv.org/pdf/1409.3478.pdf

Could this phenomenon be avoided if I save my hypothesis highlights in a group other than the Public group?

Bug: created and updated fields not being filled

The {{created}} and {{updated}} fields never appear to be filled. Do they depend on information from the article or is the time of the import used? If the former, is it possible that none of the articles I have been highlighting have this information? If that is so, then this is not a bug, but it would be nice to fill these in with the current timestamp if not provided by the article. Cheers.

[Feature Request] Template should allow us to customize the frontmatter

My notes usually have created and updated fields in the frontmatter as part of the core Templates (which are then kept up to date by obsidian-linter).

It would be nice if the template setting actually included the current frontmatter that's injected by this plugin, so that I can add my own fields (also want to add tags:).

It would be even nicer too if the updated date could be filled in to be the most recent date of all the highlights/annotations that are synced. As for the created date, maybe it could be set to the oldest date.

Error when trying to sync the highlights

I got the following error messages when trying to sync the highlights into Obsidian:

Uncaught (in promise) TypeError: Cannot read property '2' of undefined
    at eval (eval at <anonymous> (app.js:1), <anonymous>:2:128829)
    at Array.reduce (<anonymous>)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:2:128552)
    at et.startSync (eval at <anonymous> (app.js:1), <anonymous>:2:128958)
    at async at.startSync (eval at <anonymous> (app.js:1), <anonymous>:2:131252)

Re-starting Obsidian did not resolve the issue either.

[Feature request] Settings option to customise file naming pattern

Thanks a lot for this great plugin! 👏

Would it be possible, though, to provide an option in the settings to customise how file names of imports are generated? As far as I can tell, this currently is essentially the {{title}} variable cleansed of forbidden characters. However, if one has several workflows for generating source notes in place, it may be valuable to facilitate sticking to a joint naming convention. Ideally, Nunjucks could be used in the specified naming pattern?

For reference, this is what such an option looks like in the settings of the Zotero Desktop Connector plugin:
grafik

Sync different hypothesis groups in different vaults/folders?

Hi, This is not an issue
Firstly, thank you so much for this plugin - it's a huge help to myself and my students.
When collaborating in hypothesis you can create different groups, say for a research dissertation and another for, perhaps crisis management - I was wondering if it is possible to have those groups sync to specific folders or different vaults in obsidian.
for e.g. my critical research students collaborate on a group but use different vaults for other modules and hypothesis groups.
Hope this makes sense!
Thanks again
C

Annotations by other members of a private group

Thanks for the wonderful plugin!

I noticed that the plugin only imports my own annotations. I was wondering whether there is a way to capture annotations contributed by other members of a group.

Thank you!

Highlights from local PDF file don't sync

It would be amazing to be able to sync the highlights from a local PDF. I know you wrote "Have not tested to sync annotations on PDFs." so I tested it. The highlights show in hypothes.is webpage but they are not syncing to Obsidian vault. Do you think there is a way to fix this?

How to customize date format?

Currently, I have the created date in the format like 2021-10-20T00:00:00.000000+00:00. Is it possible to customize it into something like 2021-10-20T00:00:00?

I tried to look for this in the Nunjucks template, but did not figure out how to do this.

Plugin no longer syncing Hypothesis Account

Hello,

This plugin is no longer syncing my Hypothes.is account, quite randomly. Things I have tried:

  • Reinstalling the plugin
  • Resetting the plugin
  • Manually syncing
  • Automatic sync with restarting
  • Refreshing the API token.

I am using the latest version of the app on Obsidian v.0.12.19.

Any help would be fantastic!

Thanks.

Does not sync after installation

I just installed the plugin, but unfortunately the synchronization doesn't work on my latest AppImage on Ubuntu.
I think this either happens because of this fact or because of the fact that all annotations I made are for a local pdf file?
But furthermore, I've now created an annotation on a public website, still, it didn't sync on start-up although that box was checked.
Also, the reset button does not solve this. It still says it never synced.
In case it only syncs if the user does something proactively using the templater tool you mentioned later on in your ReadMe, can you please state this anywhere if that's the case?

Resync deleted files

Otherwise, you have to reset the history, delete all the synced files. Then when you sync again, it will recreate everything again.

Is it possible to only re-sync a specific file, instead of deleting all synced files first and syncing all files again?

The sync mechanism reminds me of two Readwise-related plugins:

The first one mainly works as follows:

  • If a file exists already in Obsidian, only new highlights are appended at the end of the file/note when executing the sync command
  • If a file is deleted from Obsidian, one can manually force re-syncing this specific file on the Readwise website.
    • After that, one can execute the sync command in Obsidian.
    • Then, this specific (deleted) file would be re-created, with all old and new highlights included.
    • For all other (existing) files in Obsidian, only new highlights would be appended to the end of the corresponding files.

The second one just mirrors/downloads all old and new highlights to Obsidian.

Originally posted by @wenlzhang in #1 (comment)

Duplication of highlights and annotations

Hi,

First of all I would like to thank you for making this plugin. This has made live a lot easier for me. However, there are a few things I would like to bring to your attention.

  1. The highlights are being imported in duplicates.
  2. I don't know if this by design. An annotation is followed by the highlighted passage rather than the highlighted passage being followed by the annotation as in hypothes.is.
  3. All highlights are not being imported. My highlights from the last 7 days has not be imported.

Thanks again for your effort. Even with the above issues this plugin is a great help.

Cheers

Priyam

Broken url in frontmatter

A note's frontmatter's url will have some weird characters

---
doc_type: hypothesis-highlights
url: >-
  https: //forum.obsidian.md/t/embedding-cloud-hosted-documents-and-working-collaboratively-in-teams/30641
---

It should be

---
doc_type: hypothesis-highlights
url: https://forum.obsidian.md/t/embedding-cloud-hosted-documents-and-working-collaboratively-in-teams/30641
---

[Feature Request] split annotation into commment and quote

The highlight.annotation seems to be of the format {comment} - {quoted}. Is is this a limitation of the hypothesis API not splitting these two parts up in the returned annotation.text?

I was trying to regex around this in the templating, but it doesn't work when the quoted text includes a hyphen.

{% if highlight.annotation %}   - Annotation: 
{% set regExpQuote = r/(.+)(\-.+)$/g %}
{{ regExpQuote.exec(highlight.annotation)[0] }}
> {{ regExpQuote.exec(highlight.annotation)[1] }}{%- endif -%}

[Feature request] Ability to mirror highlights, in the same order as on the page

In my workflow, highlights order is very important as it gives context to other highlights - crucial for long articles.
As I am aware that preserving order and existing edits is technically challenging, it's more of a mirror workflow, like https://github.com/jsonMartin/readwise-mirror . I don't edit those mirrored files, just reference them by persistent highlight id at the end.

Hypothesis is one of the few platforms that allow for extracting this order through the API.
Screenshot 2022-05-19 at 14 24 04
Readwise makes use of it in https://github.com/readwiseio/obsidian-readwise, but it has many issues of its own and is an unnecessary intermediary.

So, it would be great if you could implement following story:

  • User selects "Ordered mirror mode" in the options
    On sync:
  • Folder with highlights is deleted
  • Highlights are inserted as usual, but ordered based on the position in the API, from the lowest start position to the highest

Better support for multiple-line highlights

When highlighting the README page of Hypothesis like the following, the highlighted part cannot be styled well.

Not sure if the indentation of list items can be kept the same way as the source, but it would be great if the quotation (in the following example) can be kept for the highlighted text.

The source:
Screenshot 2022-02-07 at 16 33 17

The synced annotations:
Screenshot 2022-02-07 at 16 37 45

The improved/desired annotations:
Screenshot 2022-02-07 at 16 38 01

The template:

{% if is_new_article %}# {{title}}

{% if is_new_article %}## Metadata{% endif %}

{% if is_new_article %}{% if author %}- Author:: [{{author}}]({{authorUrl}}){% endif %}
- Title:: {{title}}
- Category Hypothesis:: Article{% endif %}
{% if url %}- Source URL:: {{url}}{% endif %}{% endif %}

{% if is_new_article %}## Highlights{% endif %}

{% for highlight in highlights %}> {{highlight.text}} (View Highlight [{{highlight.location}}]({{highlight.incontext}})) ^hs{{highlight.id}}{% if highlight.tags | length %}
- Tag: {% for tag in highlight.tags %}#{{tag| replace(" ", "-")}} {% endfor %}{% endif %}{% if highlight.annotation %}
- [ ] {{highlight.annotation}}{% endif %}{% if highlight.created %}
- Highlighted on {{highlight.created}}{% endif %}{% if highlight.updated %}
- Updated on {{highlight.updated}}{% endif %}

{% endfor %}

sync conflict using Obsidian Git plugsin in combination with Obsidian Hypothes.is plugin

I get a sync error everytime I start up Obsidian if I have both plugins enabled.
The error is in the file obsidian-hypothesis-plugin\data.json.

It concerns the following line:
"lastSyncDate": "2022-04-08T04:20:14.319Z"

Could it be the case that the hypothesis plugin syncs just before de git plugin?
If so, it could maybe be solved if there was an option for the hypothesis plugin to start about 30s after startup of Obsidian.

Recognize files based on Front Matter instead of file name

As this plugin is inspired by Obsidian Kindle Plugin, I think it is good to post the idea here.

As of the new update of Obsidian Kindle Plugin, the plugin recognizes the files based on front matter data,instead of filenames, this gives extra advantages, for example: we can move files anywhere in the vault and also rename, still the plugin recognizes the file.

But in the hypothes.is plugin, we can't move or rename the files. If we do, the plugin thinks the item is deleted (Command: resync deleted files confirms that) and shows it on the deleted list. So, I think recognizing files based on metadata should be more convenient for most users.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.