-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Replace invalid regex for storage placeholder the export functions #2897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@ehhc Thanks for your feedback with your pull request. I've merged the tests into this pull request. I'm not sure but I think that the markdown with the curly bracket at the image name |
|
hi @dredav why do you think the |
|
@Rokt33r what do you think about this? :) |
|
@ehhc I need more context to understand the current situation. But the current changes in this pr look reasonable to me. URL of image should be inside of |
Sorry for the late response. I suppose that the |
you might be correct, but i can't remember if thats the reason why it was done - and according to the "blame-view" most of the cases are from me and have not been modified later.. :) But i don't mind, if it stays in the tests :)
@Rokt33r: |
|
@ehhc I was able to test this - in Windows 7 - by applying the changes to |
|
@ehhc @dredav apologies if I'm making a bunch of noise with all these comments, hopefully I'm being helpful :) I'm not an experienced contributor to open source and only have limited development experience with NodeJS (none with React or Electron). |
incredibleweirdo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because path.sep is platform specific, but HTML image source paths are not/should not be platform specific, I think this is the change that needs to be made for this fix to fully work for all cases.
The backslash is also an escape character in markdown and treated specially, so this avoids the issue of it being later replaced with %5C on markdown render to HTML.
I've tested this on Windows 7 to work with HTML, PDF, text, and markdown export, as well as printing.
Apologies that the suggestions are in separate comments, but that is the only way github would allow me to make them and have it work properly.
| const temp = match | ||
| return input.replace(new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|\\))', 'g'), function (match) { | ||
| const storagePath = match | ||
| .replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep) | |
| .replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.posix.sep) |
| return input.replace(new RegExp('/?' + STORAGE_FOLDER_PLACEHOLDER + '.*?("|\\))', 'g'), function (match) { | ||
| const storagePath = match | ||
| .replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep) | ||
| .replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.sep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.sep) | |
| .replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.posix.sep) |
| const storagePath = match | ||
| .replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep) | ||
| .replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.sep) | ||
| .replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.sep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.sep) | |
| .replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.posix.sep) |
| .replace(new RegExp(mdurl.encode(path.win32.sep), 'g'), path.sep) | ||
| .replace(new RegExp(mdurl.encode(path.posix.sep), 'g'), path.sep) | ||
| .replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.sep) | ||
| .replace(new RegExp(escapeStringRegexp(path.posix.sep), 'g'), path.sep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .replace(new RegExp(escapeStringRegexp(path.posix.sep), 'g'), path.sep) | |
| .replace(new RegExp(escapeStringRegexp(path.posix.sep), 'g'), path.posix.sep) |
| .replace(new RegExp(escapeStringRegexp(path.win32.sep), 'g'), path.sep) | ||
| .replace(new RegExp(escapeStringRegexp(path.posix.sep), 'g'), path.sep) | ||
| return temp.replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER + '(' + escapeStringRegexp(path.sep) + noteKey + ')?', 'g'), DESTINATION_FOLDER) | ||
| return storagePath.replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER + escapeStringRegexp(path.sep) + noteKey, 'g'), DESTINATION_FOLDER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return storagePath.replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER + escapeStringRegexp(path.sep) + noteKey, 'g'), DESTINATION_FOLDER) | |
| return storagePath.replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER + escapeStringRegexp(path.posix.sep) + noteKey, 'g'), DESTINATION_FOLDER) |
|
@dredav @ehhc Sorry, I forgot to review this pr. Could you review @incredibleweirdo 's suggestion? I'll try to merge this asap. |
|
@ehhc It's okay. I'll try it by myself too in a week. |
To be sure, it's not everywhere, it's only in these 5 lines in |
|
Sorry for my late response. This and next week I'm very busy - but I will check your input @incredibleweirdo when I find some time. |
|
I'm going to fix this by myself in this week. I'll directly commit to this pr. |
|
Fixed by #3549 |

This pull request will fix the issue #2884. The match to
("|])doesn't make sense for me. The or match]should match). I also removed the group match at the replacement withDESTINATION_FOLDER. The group is not needed.Issue fixed
Fix wrong test
#2884
Type of changes
Checklist: