revolunet / sublimetext-markdown-preview

markdown preview and build plugin for sublime text 2/3
MIT License
2.31k stars 362 forks source link

some problem when handling image path with space key #349

Closed wpc062 closed 8 years ago

wpc062 commented 8 years ago

When use markdown parser, image path with space key could not be handled well.

E.g. ![](a b.txt) after convert to html, it becomes:

<img alt="" src="a" title="b.txt" />

PS: github parser could handle it well.

Thanks,

facelessuser commented 8 years ago

Are you using the github parser or the python markdown parser? If you are using the Python Markdown parser, this may be an issue with that module which should be fixed on their repo as we just use theirs. It appears they use a notation of ![alt](src title), so if that is the case, it is not really a bug per se...I guess it depends on how it is interpretted.

I will have to take a look and see what they are doing and what their intentions are first before I can give a definitive response.

facelessuser commented 8 years ago

I get the impression that Python Markdown is not following the Markdown spec on this one. The original Markdown spec states that the title should be enclosed in quotes following the path: http://daringfireball.net/projects/markdown/syntax#img. You can try out the code on the dingus and see it works as you are showing: http://waylan.pythonanywhere.com/dingus. It appears that it is a bug in their library.

wpc062 commented 8 years ago

Just tried ![alt text]("a b.txt" "title") in page http://waylan.pythonanywhere.com/dingus, it still doesn't work as expected.

It seems I have to switch to github parser. Could github parser support bullet list like below:

- [ ] a
- [x] b
- [ ] c
facelessuser commented 8 years ago

Just tried ![alt text]("a b.txt" "title") in page http://waylan.pythonanywhere.com/dingus, it still doesn't work as expected.

That's still not the right syntax. Surrounding the link with quotes is not the answer. Titles are supposed to be surrounded with quotes, but there is a bug that allows titles that aren't surrounding in quotes, and that is incorrect. Now, as for paths with spaces, Python Markdown doesn't support that, and the author is leaning towards not supporting it (at least that is what he told me when I asked him about it). You can probably replace the space with %20 though and give that a try: ![alt text](a%20b.txt "title").

I am working to get a patch for the title bug, but I don't think we are going to get support for spaces in the links in Python Markdown.

It seems I have to switch to github parser. Could github parser support bullet list like below:

Github parser can support those as it goes through their API, but you will probably have to put it in gfm mode (Github Flavored Markdown): https://github.com/revolunet/sublimetext-markdown-preview/blob/master/MarkdownPreview.sublime-settings#L137.

wpc062 commented 8 years ago

Thanks a lot for fixing my problem.