stefanopagliari / bibnotes

357 stars 30 forks source link

Zotero 6 Annotation Support #95

Closed Servinjesus1 closed 2 years ago

Servinjesus1 commented 2 years ago

Zotero 6 has brought annotation extraction into the base program, and Zotfile has decided to discontinue their functionality in favor of what Zotero now has built-in. This extracts the exact color of annotations and highlights the content of the note itself rather than prepending the name of the color as Zotfile did. Is there any hope of getting bibnotes to parse this for color-aware annotation importing? It seems like the same feature that's needed for importing formatting from Zotero notes into markdown will be needed to support this workflow.

stefanopagliari commented 2 years ago

Thank you for mentioning this. I was not aware of this change. I will look into this!

pdatlinger commented 2 years ago

This would be incredible! In my workflow I like to use different colors for specific kinds of information. It would be amazing to get the annotations by color into Obsidian, for example to put them under different subheadings. Amazing work so far!

dzackgarza commented 2 years ago

+1, so far I've had good luck extracting highlighted text and clipped regions from the new "Select Area" tool in the Zotero PDF reader, along with comments on the annotations themselves, but not the per-annotation tags:

image

stefanopagliari commented 2 years ago

@Servinjesus1, are you referring to highlights made using an external pdf reader (not the one inside Zotero) and then imported using the command "add note from annotation" in Zotero?

stefanopagliari commented 2 years ago

I have checked the logs and it looks like betterbibtex exports the hex code of the highlight colour (e.g. "#facd5a" for the yellow in Mac Preview). I would imagine that the colour will differ across different highlighter. I think there are two options: 1) letting the user specify the hex code in the settings 2) find a JS library that associates hex codes with the name of a few colours (preferably the one already recognised by the native reader or Zotero to avoid creating new ones in the settings)

Servinjesus1 commented 2 years ago

@stefanopagliari I do mean the Add Note from Annotations button from an attachment's context menu. However, in my experience both sources of annotations (internal or external editors) behave the same.

I also learned the underlying RDF of the annotation does include the hex color as well, and will show it transparent in Zotero with #80 tagged onto the highlight color (so ~19.6% transparent) if you click Show Annotation Colors from the note's meatballs menu. So, luckily, showing the annotation colors shouldn't be necessary for better bibtex to hand out the highlight colour. Anyway...

My opinion for your two options would be (1) - I prefer the freedom of granularity. Additionally, it would be great to be able to set an arbitrary number of hex-to-markdown transformations for as many colors as you'd like. Templater is a great example of a plugin with this kind of arbitrarily expanding user option interface. Off the hip, I'd probably want to specify:

  1. The color in Hex
  2. A friendly name for the hex
  3. The transformation

I'd probably use the friendly name only for readability in the settings, but I could also see users using it to define a template variable to add to highlight transformations (i.e. in the Custom text before/after all highlights box), like #colorName, so people can replicate ZotFile's old export scheme.

stefanopagliari commented 2 years ago

I have addressed this in the version 0.9.149. @Servinjesus1, could you please test it?

I've used a Color Classifier library (https://github.com/wadackel/color-classifier) that converts the custom HEX to one of the 10 colours already supported in the settings of the plugin (and previously supported by Zotfile). The main drawback of this approach is in the case of borderline colour, e.g. those that the classifier recognise was yellow but the user thinks are orange.

I have also added in the setting the possibility of \specifying a custom Hex code and the associated transformation. I have added in the template a new placeholder called {{CustomHex}}

stefanopagliari commented 2 years ago

I'm closing this issue but please re-open it if the problem has not been solved

kvgaever commented 2 years ago

Only recently started using the plug-in, so not sure if there's a wonky setting on my end, but different colored highlights in Zotero only show up as yellow in Obsidian. However, the custom text before certain color does match with the annotated color from Zotero. Any idea what could be causing this?

Using version 0.9.209, and Zotero 6.0.10

stefanopagliari commented 2 years ago

@kvgaever: could you share the json file of the a source where this problem is occurring? you will need to change the file path to txt in order to upload it here

kvgaever commented 2 years ago

zotero_test.txt

@stefanopagliari: I've extracted a single item where I added one of each highlight colors. When imported, the annotations are shown this way:

annotations

.

stefanopagliari commented 2 years ago

@kvgaever The colours are recognised correctly by the plugin. For instance in the two screenshots below I have set it up so that the name of the colour is pasted before the highlight and it works correctly.

If the problem is that the highlight is yellow, that is the standard behaviour of the plugin. Selecting the "highlighted" setting simply wraps a "==" around the text and that is rendered by Obsidian as yellow. I'm planning to add a feature that would allow the users to import the actual colour of the highlight rather than the standard yellow

CleanShot 2022-08-07 at 22 47 36@2x CleanShot 2022-08-07 at 22 47 06@2x
kvgaever commented 2 years ago

@kvgaever The colours are recognised correctly by the plugin. For instance in the two screenshots below I have set it up so that the name of the colour is pasted before the highlight and it works correctly.

If the problem is that the highlight is yellow, that is the standard behaviour of the plugin. Selecting the "highlighted" setting simply wraps a "==" around the text and that is rendered by Obsidian as yellow. I'm planning to add a feature that would allow the users to import the actual colour of the highlight rather than the standard yellow

My apologies then, I thought that feature was already implemented. Thank you for clearing it up and for your work on the plug-in.