brrd / abricotine

Markdown editor with inline preview
GNU General Public License v3.0
2.63k stars 156 forks source link

Link rendering error #195

Closed MatteoCampinoti94 closed 2 years ago

MatteoCampinoti94 commented 7 years ago

As seen in the screenshots below every time there is an open square bracket '[' everything between it and any closed square bracket ']' or the EOF (like in the second case pictured) is rendered as link screenshot screenshot

The bug does not transfer to html output, it is present only when rendering inside Abricotine.

Not sure how Abricotine handles parsing for rendering but this bug could be fixed by looking for a closed square bracket ']' and a pair of brackets '( )' after the first '['.

brrd commented 7 years ago

I don't reproduce this issue.

image

Which version do you use? What is your OS? Can you provide a full sample markdown file?

MatteoCampinoti94 commented 7 years ago

Am on Arch Linux and using latest 5.0 version from AUR

To reproduce try removing '(url)' For example try:

Hello [ world
Hello ] world

And also: [hello] [world] In this case it seems to consider the second pair of '[]' (if it is on the same line) as the second part of the link instead of looking for matching '()'.

The bug only occurs when there isn't a closing ']' or if there aren't any matching pairs '()'.

Will try to use the git version and see if maybe the problem is mine but it doesn't look like it.

MatteoCampinoti94 commented 7 years ago

You were right. Problem is with AUR version. It must be out of date.

Sorry for the mistake.

brrd commented 7 years ago

Well... I can reproduce it partially.

image

Anyway, it looks like an issue with CodeMirror markdown mode. Could you find any refrence to this issue in https://github.com/codemirror/CodeMirror/issues ?

MatteoCampinoti94 commented 7 years ago

I'll look into it.

Also checked the AUR page and it uses the current 0.5.0 source code. It doesn't change it, just builds the package for Arch. Not sure why a bug like this would occur in this case and not using the app directly from the git repo. Building it now from the 0.5.0 source. Will see if maybe the problem was solved after the last release.

MatteoCampinoti94 commented 7 years ago

Built the 0.5.0 version and the bug is indeed present there. It was fixed in the meantime it seems.

MatteoCampinoti94 commented 7 years ago

Now this is weird. If I use the linux 64bit binaries from here 0.5.0/Abricotine-linux-x64.tar.gz then the bug is not present.

I've tried to build both the master and develop branches and the bug appears in both. I thought it was isolated to the 0.5.0 version but it seems it isnt. If it's not in the code maybe the problem is with the building. What version of npm and Node.js was the 0.5.0 release built with?

MatteoCampinoti94 commented 7 years ago

I've looked into CodeMirror open issues but couldn't find anything specific to this. I did find these two though: /issues/4456 This one seems to relate to incorrect brackets matching. Doesn't seem to be the problem I've found though. /issues/4501 This one seems to be the closest to what happened with me.

MatteoCampinoti94 commented 7 years ago

Found it in the closed issues! /issues/4735 The bug has already been patched on the 9th of May though so not sure how it could still happen to me and even less sure why the binary release doesn't have the bug even if older.

MatteoCampinoti94 commented 7 years ago

Will try to merge the patch and see if the problem still occurs.

Sent from my Nextbit Robin using FastHub

MatteoCampinoti94 commented 7 years ago

Can't find anything that causes the problem. Though tbh am not sure I found all the parts of the code responsible for recognizing a link/image.

brrd commented 7 years ago

I finally understood what happens!

I can reproduce this bug there: http://codemirror.net/demo/simplescrollbars.html. On that page, CodeMirror version is "5.27.5".

On my build of Abricotine, CodeMirror version is "5.24.2" (you can see it by opening the devtools (F12) and calling CodeMirror.version in the console).

In package.json, version is "codemirror": "^5.24.2", which means any 5.x.x version upper to 5.24.2 and lower to 6.0.0.

Obviously some regression was introduced in CodeMirror markdown mode since version 5.24.2 and this buggy version was the latest available when AUR package was build. This explains why we find different behaviors between builds.

So IMO the correct way to fix this would be to submit an issue in CodeMirror and update the build it when this issue is fixed.

MatteoCampinoti94 commented 7 years ago

That's great to hear! Well, great cause we now know what happened and not that great cause we can't really do much about it XD Hopefully it'll be fixed soon.

My compliments for your investigative work though! I'll open an issue in CodeMirror repo tomorrow if you won't have done it already.

MatteoCampinoti94 commented 7 years ago

Sorry, wrong button