gallery shortcode in markdown

39 views
Skip to first unread message

Tanja

unread,
Jun 8, 2017, 8:22:00 AM6/8/17
to nikola-...@googlegroups.com
Hi!

I’ve used the .rst shortcode to insert galleries in my posts for a while and it works as expected (especially now with the separate template). However, for various reasons I’d prefer to use Markdown but I can’t seem to figure out how to insert a gallery into a post with a shortcode in a markdown file.
I thought ‘how hard can it be to fix that myself?’ based on the .rst gallery-directive, and looking at the markdown podcast-plugin to see how to handle a shortcode and how to match etc.

Well, famous last words, I guess, because I stayed up waaaay past my bedtime and fried my brain and still haven’t figured it out.

Could this be added into a future release? It seems like something other people would use too…
Or could someone point me in the right direction to fix this myself?

Thanks in advance!

~ Tanja
signature.asc

Roberto Alsina

unread,
Jun 8, 2017, 12:03:45 PM6/8/17
to nikola-...@googlegroups.com
Hi!

Yes, making the gallery directive into a shortcode is not exactly easy :-P

I want to do it, just not right away, but I have added it to issue #2809


That's not a promise that it will get done fast (some issues I have fixed a couple of years after creating) but it's a promise that it's in my TODO.

Hope you have fun using Nikola even if this feature is not there yet :-)

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tanja

unread,
Jun 9, 2017, 9:50:46 PM6/9/17
to nikola-...@googlegroups.com

Hi!

Thanks for your answer. Nikola is always my go-to if I need something simple to set up and easy to use ;)

I gave it another shot and after looking at the mdx_gist.py plugin I came up with something that works (for me): https://github.com/tannie/md_gallery/

It has none of the json/flowr/script parts, but I don’t really need those anyway (for this purpose). Not sure if I did everything right with getting the output folder name though…

Kind regards,

~ Tanja

signature.asc

Chris Warrick

unread,
Jun 10, 2017, 6:51:50 AM6/10/17
to Nikola—Discuss
That one looks interesting — perhaps you could submit it to the repo
at https://github.com/getnikola/plugins ?

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

Thomas Janotta

unread,
Oct 3, 2018, 12:47:07 PM10/3/18
to nikola-discuss
Hi Tanja,
this script is great. How can one at least add the name of the image (without underscores) as alt attribute? (for the gallery-lightbox)
Thanks...

Thomas Janotta

unread,
Oct 3, 2018, 2:12:58 PM10/3/18
to nikola-discuss
Hi,
I found a way, but I don't kno if i can *cascade* the functions.

after
for img in photo_array:

add the "alt"-variable, remove the file type, replace undescore with spaces and capitalise (title) it.
img_alt = img['url']
img_alt = img_alt[:-4]
img_alt = img_alt.replace('_', ' ')
img_alt = img_alt.title()

then add it to the img tag

img_src.set('alt',img_alt)

WOW.

jmcp

unread,
Oct 4, 2018, 12:04:42 AM10/4/18
to nikola-discuss

Hi Thomas,
if you're using v8 then you can add arbitrary metadata for gallery images. Please have a look at the manual section https://github.com/getnikola/nikola/blob/master/docs/manual.rst#images-and-galleries


James

Thomas Janotta

unread,
Oct 4, 2018, 3:38:07 AM10/4/18
to nikola-discuss
 Hi James,
yes I had this, but it seems the gallery use rst, but my pages use md. I tested the mix but the md-gallery is good for me.

I found that I can directly acess the title:

img_alt = img['title']

as it is in the metadata.yml, this is fine for me.
Reply all
Reply to author
Forward
0 new messages