r-lib / hugodown

Make websites with hugo and RMarkdown
https://hugodown.r-lib.org
Other
166 stars 24 forks source link

workaround for shortcodes? #53

Closed maelle closed 4 years ago

maelle commented 4 years ago

Using pandoc raw attributes

I now feel guilty using shortcodes in hugodown Rmd but I've just found how to escape them. :smiling_imp: Would it be worth documenting in a footnote somewhere or is it best kept as a secret tip among the Hugo rebels? (the test is a POC, not a test) cc @jemus42 @apreshill

FWIW for things like embedding tweets I agree R might do a better job with safe failures.

hadley commented 4 years ago

I wouldn't be opposed to wrapping up into a couple of hugodown::shortcode() helpers.

maelle commented 4 years ago

wrapping what up? the pandoc blocks? or Hugo default shortcodes?

I'm wondering whether folks wanting to use shortcodes won't just want to copy-paste from theme docs.

jemus42 commented 4 years ago

Hmm… isn't that only marginally better than using blogdown::shortcode() in an inline code chunk? This solution probably also doesn't bode well for my pkg shortcode that produces an inline <span> as it would also introduce extra linebreaks/paragraphs, right?

I do, however, very much appreciate your dive into the 🐇 🕳️ & giving it a go 😁

maelle commented 4 years ago

@jemus42 would you mind trying the workaround on your shortcode just to see what it does? but yeah it's not magical anyway, more typing. the typing reminds us we should write an R function. :grin:

hadley commented 4 years ago

Wrapping it up just like blogdown::shortcode(); for inline short codes you'd use an inline html element (`<a>html</a>`{=html})

maelle commented 4 years ago

is the gain not having to remember the syntax?

hadley commented 4 years ago

I think the advantage is that hugodown could provide wrappers for common shortcodes, and they just work: https://github.com/r-lib/hugodown/pull/54/files#diff-9b4ee5398562b8355d3176408452cfb6R45

I think the advantage of an R function here is:

jemus42 commented 4 years ago

Ohhh, the inline-variant is exactly what I was missing, nice! I'll give it a go when I'm home, thanks the both of you for not giving up on shortcodes :sob:

hadley commented 4 years ago

Closing in favour of #54. Thanks for discovering this @maelle!