jbaiter / zotero-cli

Command-line interface for Zotero
MIT License
274 stars 41 forks source link

Ugly workaround for the missing regexes #26

Closed joelostblom closed 7 years ago

joelostblom commented 7 years ago

I'm not familiar with regexes, I just wanted to highlight this problem. For me, no notes are being detected as previously edited with zotcli using the current regex. I had to change it to what is shown below, maybe you can figure out what is going on and make a permanent fix? Related to #21

jbaiter commented 7 years ago

Can you post some example note markup so I can see where the current regular expression patterns are failing?

joelostblom commented 7 years ago

For me it is failing on any note I create via add-note. Here is one example

<p>new-note-is-here</p>\n<div class="zotcli-note">\n<p id="zotcli-data" style="color: #cccccc;" title="b\'eJyrVipLLSrOzM9TslIwNDcx0VFQKkmtKAHylPJSy3Xz8ktSdTOLdTNSi1Jj8pSAsmn5RbmJYPnk\\n/Nzc/LzcxKJspVoAJ2sXHA==\\n\'">(hidden zotcli data)</p>\n</div>'
jbaiter commented 7 years ago

Does the data include the single ' at the end or is that a mistake that happened during copy&paste?

If so, I think I have found the root cause: I developed the application with Python 2 in mind, and a lot of string-related stuff is handled differently in Python 3. In this case, the encoded data was returned as a bytes instance and written to the HTML as its Python representation, i.e. b'{data}', which was not recognized by the pattern. I have a PR ready that fixes this (and will retroactively will fix any notes with bad data), so if you can confirm that the quote at the end is a mistake, I can push it :-)

joelostblom commented 7 years ago

Yes, you are correct, that trailing ' should not have been there, sorry about that.

I suspected that it was the switch in string handling between 2 and 3 that was somehow giving rise to this issue, but I could not figure out the exact cause. Thanks for sorting it out!