A bug related to markdown escaping when exporting extracted annotations

If one copies the contents in an extracted annotations of a pdf, then paste in a markdown editor, e.g., obsidian, some symbols are escaped incorrectly. Examples can be found in the link below (where I placed some images ): https://github.com/zotero/zotero/issues/2343

When searching for a solution, I found the above github issue, and tried the following:

I copied the main.js and translator.js into the folder "...\Zotero\translators", then restarted zotero. Seems that something takes effect, for example, if I copy the notes and press Ctrl+Shift+V in a obsidian note, then the escape signs are no longer there. However, all the links (related to the annotation in the pdf) are gone, and these links are gone even if I paste them using Ctrl+V.

Besides, a wierd thing is that, the main.js, which I copied into the folder, is deleted automatically during the restart of zotero. This happens even if I copy it into the folder again. Now I tried deleting these two files from the folder, but the behavior won't recover.

The snapshots are also attached in the above link. Could someone help me solve this issue, or at least recover the behavior of how zotero handles the export, so that the links can be kept?


  • I've tried "Reset your translators from the Advanced → Files and Folders pane of the Zotero preferences", but nothing changes. The escape signs are still gone, along with the side effect of missing links completely, which means that the change is still taking effect.

    I have also tried different notetemplate strings, such as:

    {{highlight}} {{citation}} {{comment}}{{if tags}} #{{tags join=' #'}}{{endif}}

    The output looks like this:

    "Ctrl+V

    # Annotations
    (28/08/2022, 08:17:35)

    “Development of a Novel 3-DoF Purely Translational Parallel Mechanism” (Yunjiang Lou et al., 2007, p. 169)

    “In view of the successful application of planar parallelogram in the Delta robot and its variants, we are interested to investigate mechanisms consisting of spatial parallelograms.” (Yunjiang Lou et al., 2007, p. 169)

    “Using the formulation of maximizing effective cubic workspace, the Orthopod,” (Yunjiang Lou et al., 2007, p. 169)



    Ctrl+Shift+v:



    Annotations(28/08/2022, 08:17:35)

    “Development of a Novel 3-DoF Purely Translational Parallel Mechanism”

    “In view of the successful application of planar parallelogram in the Delta robot and its variants, we are interested to investigate mechanisms consisting of spatial parallelograms.”

    “Using the formulation of maximizing effective cubic workspace, the Orthopod,”


    "

    Notice that, when using Ctrl+Shift+V, the formatting seems to be lost, for example, The linebreak within Annotations(28/08/2022, 08:17:35) is lost, and "Annotations" is no longer recognized as a heading, which is thus not bolded.
  • Test with a regular text editor, not Obsidian.

    For Obsidian, see https://forums.zotero.org/discussion/comment/409004#Comment_409004
  • somehow the paste function starts working properly again today, not sure if it was because that I had restarted my computer.

    However, currently, the problem of the extra escape before ">", "[", "]" still exist, which should be hopefully solved in the future.

    Another related issue: if I paste into obsidian using Ctrl+Shift+V, the images won't be copied properly. Only a link to the item is kept. Below is an example:

    ([Chouaibi et al., 2016, p. 3](zotero://select/groups/27057**/items/X4JT**FP))
  • If I paste them into microsoft notepad, they look the same. Below is an example:

    \>\[!done\] “rm, while x0 is taken according to the right hand rule. Let S11(A1,x11,y0,z11), the reference frame fixed on the arm (2). The z11 is parallel to the line A1F1 (F1 corresponds to the middle of the segment C1C′” ([Chouaibi et al., 2016, p. 2](zotero://select/groups/27057**/items/X4JT4F**)) ([pdf](zotero://open-pdf/groups/27057**/items/QSU4QU**?page=3&annotation=D4LJP6**))

    ([Chouaibi et al., 2016, p. 3](zotero://select/groups/27057**/items/X4JT4F**))
  • Well, that's not the same — that's the Markdown. Above in Obsidian you were getting rich text or stripped rich text without the links.

    For the escaping, make sure you have translator updating enabled in the Advanced pane of the preferences, and click Update Now for good measure. If you're still seeing escaped brackets after that, provide a Debug ID for copying.
  • edited August 28, 2022
    I haved updated the translators, but still, when dragging the annotations to obsidian when pressing shift, an escape sign appears.

    The noteTemplates.Highlight is set as follows:

    [removed irrelevant note template — D.S.]

    The debug ID is below: D1689862257
  • edited August 28, 2022
    Parsing code for Note Markdown (1412e9e2-51e1-42ec-aa35-e036a895534b, 2022-04-29 11:00:00)
    Because your translators aren't updated properly. This should say 2022-08-26.

    Based on other errors in your error report, the update request might be getting blocked by your internet connection.
  • If you can't figure it out, provide a Debug ID for resetting and updating translators.
  • Thanks for pointing out the issue. I restarted zotero, then tried update the translators, it displays updated, but nothing changes.

    The ID is D580804468
  • edited August 28, 2022
    That doesn't show you resetting translators.
  • Sorry I forgot it. After I reset the translator then choose update, it first shows "error", then if I click again, it shows "updated".

    D159387257
  • OK, that shows you with the 2022-08-26 version of the translator.
  • Unfortunatly, when I press Ctrl+V or Ctrl+Shift+V in obsidian, both leads to the same results:

    ">[!warning] “wn in Figs. 2 and 3). Two forearms (3) and (3′) are connected to the arm (2) by two spherical joints centered at C and C′. The line CC′ is taken parallel to i. These two forearms (3) and (3′) are als” (Chouaibi et al., 2016, p. 2)

    >[!danger] “(4) is connected to the platform by a revolute joint with axis taken parallel to i, in order to eliminate all possible rotations of the platform with respect to the base. The axes of the first revolute joints con” (Chouaibi et al., 2016, p. 2)
    "

    the links are again missing.

    Moreover, I can no longer drag an annotation directly into obsidian, a symbol of cicle with a backlash appears, which means forbidden.
  • Again, test in a regular text editor.
  • edited August 28, 2022
    I don't have another decent markdown editor, so I tried this website: https://dillinger.io/

    the results is as follows:

    Ctrl+V

    [!warning] “wn in Figs. 2 and 3). Two forearms (3) and (3′) are connected to the arm (2) by two spherical joints centered at C and C′. The line CC′ is taken parallel to i. These two forearms (3) and (3′) are als”

    [!danger] “(4) is connected to the platform by a revolute joint with axis taken parallel to i, in order to eliminate all possible rotations of the platform with respect to the base. The axes of the first revolute joints con”

    [!done] “rm, while x0 is taken according to the right hand rule. Let S11(A1,x11,y0,z11), the reference frame fixed on the arm (2). The z11 is parallel to the line A1F1 (F1 corresponds to the middle of the segment C1C′”

    Ctrl+Shift+V:

    [removed duplicate output — D.S.]

    Then I tried another md editor I have, and tried notepad, the results are the same for all cases.
  • Pressing Ctrl+V or Ctrl+Shift+V both produce the same text, not sure why my comment above displays sth like "removed duplicate output".

    Might the problem be because that the translators are not fully updated?
  • Forget about Ctrl-Shift-V — that has no meaning in a standard text editor. This is just plain text. Notepad and Ctrl-V are all you need here.

    So then the escaping is fixed, right?

    For the links, reset your note template to the default and test again.
  • Yes, the escapeing is fixed, but somehow the links (and their associated text) are missing. Actually, I have achieved this yesterday, but failed to get the links back. I have tried using different note template including the default, which doesn't solve the problem.

    I just reset the note template to default, the extracted notes changes format as expected, but the links (including the name for the links) are still gone. The related ID is: D1430924622

    ```
    “wn in Figs. 2 and 3). Two forearms (3) and (3′) are connected to the arm (2) by two spherical joints centered at C and C′. The line CC′ is taken parallel to i. These two forearms (3) and (3′) are als”

    “(4) is connected to the platform by a revolute joint with axis taken parallel to i, in order to eliminate all possible rotations of the platform with respect to the base. The axes of the first revolute joints con”

    “rm, while x0 is taken according to the right hand rule. Let S11(A1,x11,y0,z11), the reference frame fixed on the arm (2). The z11 is parallel to the line A1F1 (F1 corresponds to the middle of the segment C1C′”
    ```
  • BTW, the links are indeed within the note extracted from annotations, which, when clicked on, leads me to the correct page.
  • Another related question: can we after all use shift+Drag, or ctrl+Shift+V to paste the comments into obsidian, when the comment is an image made in the zotero reader?

    If I use Ctrl+V, the image can be pasted properly, though with an extremely long name, while the links are missing; if I use Ctrl+Shift+V, the links are there but the image is not (when the translators are not updated);

    If I successfully solve the translator issue, can I paste the image and links properly in obisidan, using Ctrl+Shift+V or Shift+Drag? If not, it may be better to consider using other plugins for the communication between zotero and obsidian.
  • Disable all your other third-party plugins, make a new PDF highlight, add it to a new empty note, and try again.
  • I disabled all the plugins, restarted, tried a new pdf without highlights. Surprisingly, the issue seems to be solved, but somehow the escaping problem comes back:

    D1779151383

    Below is the output using default note template:

    # Annotations
    (28/08/2022, 22:00:08)

    “The remainder of this article is organized as follows. In the next section,” ([Staicu et al., 2018, p. 2](zotero://select/groups/27057**/items/PGSXL5FQ)) ([pdf](zotero://open-pdf/groups/27057**/items/JJKRJLP4?page=2&annotation=KJZ4VCGR))

    “Considering the symmetric structure of the” ([Staicu et al., 2018, p. 4](zotero://select/groups/27057**/items/PGSXL5FQ)) ([pdf](zotero://open-pdf/groups/27057**/items/JJKRJLP4?page=4&annotation=Z3RFQJKW)) user comments

    Below is the output using the template I created

    # Annotations
    (28/08/2022, 21:55:33)

    \>[!danger] “The remainder of this article is organized as follows. In the next section,” ([Staicu et al., 2018, p. 2](zotero://select/groups/27057**/items/PGSXL5FQ)) ([pdf](zotero://open-pdf/groups/27057**/items/JJKRJLP4?page=2&annotation=KJZ4VCGR))

    \>[!note] “Considering the symmetric structure of the” ([Staicu et al., 2018, p. 4](zotero://select/groups/27057**/items/PGSXL5FQ)) ([pdf](zotero://open-pdf/groups/27057**/items/JJKRJLP4?page=4&annotation=Z3RFQJKW)) user comments
    #testtags

    I also tried pasting an image, for both cases the image is not pasted when using Ctrl+Shift+V

  • I made another attempt: reset the translators, update it, restart zotero, tried some notes which didn't work, then updated the translators again, the more tests that didn't work.

    Below is the debug ID: D290113542.
  • edited August 28, 2022
    The escaping didn't come back — we addressed escaping of square brackets, so it's working as expected.

    We can look into not escaping angled brackets.
  • oh you are right. Now I have re-enabled most of the plugins, and it still works properly, with the links displayed, even though the issue related to angled brackets is yet to be fixed.

    Another remaining issue is, it is not importing the images properly. Below is an example of two comments (extracted from a normal text and an image):

    "# Annotations
    (29/08/2022, 07:19:53)

    \>[!note] “Given Cartesian position p, taking norm of both s” ([Lou et al., 2006, p. 2147](zotero://select/groups/27057**/items/6T7GZRUN)) ([pdf](zotero://open-pdf/groups/27057**/items/9PK77JRI?page=4&annotation=J3J9RLVI))

    ([Lou et al., 2006, p. 2147](zotero://select/groups/27057**/items/6T7GZRUN))
    "

    As can be seen, the link for the image leads to the item rather than the annotated snapshot. This test is done on a clean pdf.

    If the images can be made to be pasted properly in the future, it would be very convienient if an "!" symbol is added automatically before the left bracket of the image link, so that the images can be embedded directly into the obsidian notes, which can be displayed when switched to the preview mode in obsidian.

    I acknowledge that it is likely that some others may don't like the automatic "!", but if one needs to add "!" by himself one by one, it is a challenging task; on the other hand, removing all the "!" from a note can be done simply upon replacing "(![" with "([" in batch, will is much simpler.

    I would recommend the developers to consider offering a way to paste the images with the appropriate link and the automatic "!"
  • edited August 30, 2022
    Now I manage to handle the issues of escaping of angled bracket with the following notetemplate.highlight:

    {{if color == '#ff6666'}}
    <blockquote>[!danger] {{highlight quotes='false'}} {{citation}} {{if comment}} {{comment}} {{endif}} <br /> {{if tags}} #{{tags join=' #'}}{{endif}} </blockquote>
    {{elseif color == '#ffd400'}}
    <blockquote>[!warning] {{highlight quotes='false'}} {{citation}}{{if comment}} {{comment}} {{endif}} <br /> {{if tags}} #{{tags join=' #'}}{{endif}}</blockquote>
    {{elseif color == '#5fb236'}}
    <blockquote>[!done] {{highlight quotes='false'}} {{citation}} {{if comment}} {{comment}} {{endif}} <br /> {{if tags}} #{{tags join=' #'}}{{endif}}</blockquote>
    {{elseif color == '#2ea8e5'}}
    <blockquote>[!note] {{highlight quotes='false'}} {{citation}} {{if comment}} {{comment}} {{endif}} <br /> {{if tags}} #{{tags join=' #'}}{{endif}}</blockquote>
    {{elseif color == '#a28ae5'}}
    <blockquote>[!example] {{highlight quotes='false'}} {{citation}} {{if comment}} {{comment}} {{endif}} <br/> {{if tags}} #{{tags join=' #'}}{{endif}}</blockquote>
    {{else}}
    <blockquote>[!] {{highlight quotes='false'}} {{citation}} {{if comment}} {{comment}} {{endif}} <br/> {{if tags}} #{{tags join=' #'}}{{endif}}</blockquote>
    {{endif}}
  • However, the problem of pasting images still exist. I created examples of two items from "Mylibrary" or a group, but somehow failed to paste them here. Please refer to my note here:

    https://github.com/zotero/zotero/issues/2343
  • Context re: blockquotes: https://github.com/zotero/zotero/issues/2343#issuecomment-1231388567

    Please start new threads for new issues (but see existing threads on images in Markdown).
Sign In or Register to comment.