Skip to content

Bug in notes with more than one link #1

@sampaio96

Description

@sampaio96

Bug report

If a note has more than one link, all links in the note will link to the same page.

The problem is on line 581 of everlink.py.

body = link_regex.sub('[\\1](:\/{:s})'.format(n['id']), body)

With the code above, the first Joplin link constructed will be replaced into all regex instances of evernote:// links inside the note.
(Notice that, after the first run of this substitution, there are no more links matching the regex pattern. The loop will keep visiting the evernote:// links that had been already extracted, but it won't be able to change those, because they have already been replaced.)

The expected behavior is this:

body = body.replace(link[1],':/{:s})'.format(n['id']))

Since we already know the full text of the specific evernote:// link you want to replace, we don't need to use regex again.

Thank you very much for the great work! I'm using this to export to Obsidian, so my only change to the project was also in this line. I commented out lines 566 to 581 and wrote this version of Markdown Wiki Links:

old_link = '[' + link[0] + '](' + link[1] + ')'
wiki_link = '[[' + link[0] + '|' + match.title + ']]'
body = body.replace(old_link, wiki_link)

Note

I only looked at the .enex .md notes, and not at the .enex .html section coming after.

Minor bug

To leave the date of update unaltered, on line 584 you should have note['user_updated_time'] instead of n['user_updated_time'].
In this case, n refers to the note being linked, while note is the actual note being changed.
To change this, you also have to change line 501, to include user_updated_time in the fields

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions