fabianmichael / kirby-markdown-field

Super-sophisticated markdown editor for Kirby 3, community built.
Other
160 stars 14 forks source link

Markdown syntax for images #183

Open tobimori opened 7 months ago

tobimori commented 7 months ago

Should be pickable similiar to the link button option.

Example: ![Alt text](image.png)

fabianmichael commented 6 months ago

@tobimori I had this idea before, but since the field does not extend the Markdown parser, we would either have to change this to have path resolution for image files or would need to resolve to some static paths here. Extending the parser is not a problem (I know a thing or two about Parsedown because I did this quite a few times), the only downside would be that this would make it harder for other plugins to extend Parsedown. Any ideas?

tobimori commented 6 months ago

Similar to the solution you suggested for the highlight text, I used a kirbytags.before hook to turn this syntax into the KirbyTag. A bit hacky but it works.

tobimori commented 6 months ago

I don't think extending Parsedown would be an issue if the plugin extensions could support extending the Parsedown stuff.

If you use Markdown this will be the backbone of your site, so it all has to work with the plugin anyway.

tobimori commented 6 months ago

tbh, what confused me working with this plugin is, that this syntax seemingly gets resolved but the images do not work (because they are relative to the content folder and not the resolved urls)

in an optimal solution i would be able to customize this with a snippet or something that gets rendered

fabianmichael commented 6 months ago

@tobimori Like I said before, this plugin only provides a Markdown field an nothing else. I did not want it to interfere with Kirby’s Markdown parser, because this would break other people’s Parsedown extensions or would make it much harder to switch the Markdown parser …

The most practial solution that would not require anything in the backend to change would probably to let images resolve to their absolute path, which would no require any additional backend processing, e.g. ![ALT](/home/image-bw.jpg). Of course this does not optimize images or do any other cool stuff and would break if you move the site to a subfolder, but anything else would require us to change the Markdown processor. What do you think?