JetBrains / markdown

Markdown parser written in kotlin
Apache License 2.0
682 stars 75 forks source link

Normalization for local image urls. #11

Closed holgerbrandl closed 8 years ago

holgerbrandl commented 8 years ago

I'd love the Jetbrains Markdown plugin to support local images in the preview. Since WebView in JavaFX does not support those yet (see here or here), I've added a simple url-normalization scheme to your library to normalize relative image urls when rendering html from md.

To use this modification in the JB plugin, i all that's necessary is to change in instantiation fo the HtmlGenerator in org.intellij.plugins.markdown.ui.preview.MarkdownPreviewFileEditor. Here's the patch file: relative_image_in_md_preview.patch.txt

The patch is well tested with the JavaFx Preview Mode in the Markdown plugin, but should also work with LoboHtmlPanel.

Attached is also a patched build of the JB Markdown plugin including the changes so that you could test it easily: markdown-plugin.zip

Here's a screenshot of a relative image example

rel_images_in_md_preview

Feel welcome if you think that my PR still needs refinements.

valich commented 8 years ago

Hi @holgerbrandl,

I've just finished merging another PR meant to solve the same problem. AFAIU, that's almost the same thing you're proposing, the difference is in the implementation.

Do you think it's still actual?

holgerbrandl commented 8 years ago

Awesome, just trash mine than. It was still a good learning experience :-).

Great that this feature comes to Intellij. Do you know a rough timeline when this feature will become available in the Intellij Markdown plugin?

valich commented 8 years ago

I am in the process of porting this to the plugin, but because of some “bureaucracy” I generally say “a couple of days” :)

Of course, assuming you're using the latest IJ product versions because although I plan some backporting, that's a little bit more difficult.

holgerbrandl commented 8 years ago

Hi again,

not sure how to send you an email/IM, so please excuse me for abusing the github ticket system to draw your attention to a new small intellij plugin to streamline the process of pasting images into markdown documents: https://github.com/holgerbrandl/pasteimages

Not sure if such a functionality was planned for the official plugin anyway. It makes working with markdown in Intellij more fun (at least to me).

valich commented 8 years ago

Hi @holgerbrandl,

That's a nice feature! Actually I would definitely like to have it somewhere to IntelliJ, and probably that could be useful not only along with markdown (I mean, with any html templating languages and html itself).

Would you like to try to contribute this to our repo? Either markdown plugin in intellij-plugins or our community repo however the latter needs some API development which you may want to avoid :D.

holgerbrandl commented 8 years ago

Thank you for your encouraging feedback. For now I've just pushed ii into the the jetbrains plugin repository as https://plugins.jetbrains.com/plugin/8446 where it is awaiting its approval.

My plan for the next weeks is to use it a bit to see what's missing. In particular it would be great to allow to user to rescale images when pasting them. Also pasting image files and potentially even image-links from clipboard should work as well (but is not yet implemented).

Once I'm more confident about it, I'd be happy to contribute it to whatever repository you feel is most appropriate.