gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.15k stars 7.48k forks source link

Shortcode not rendering raw html #262

Closed lucdew closed 9 years ago

lucdew commented 10 years ago

Hi Steve, I am using latest hugo built from the source. Shortcode feature does not seem to work as (I) expected. I wanted to create a gist shortcode like your speakerdeck shortcode of spf13.com but it seems that markdown sanitizes the html and removes it completely.

Here's an example

<script async src="https://gist.github.com/{{index .Params 0}}.js{{if isset index .Params 1}}{{index .Params 1}}{{end}}"> </script>

The output is empty when used.

I thought of shortcodes as a way to escape markdown (but it seems that it is not the case when I read https://github.com/spf13/hugo/issues/185)

It seems that even your speakerdeck shortcode in https://raw.githubusercontent.com/spf13/spf13.com/master/content/presentation/mongodb-e-commerce-and-transactions.md does not work either because if i go to http://spf13.com/presentation/mongodb-e-commerce-and-transactions I don't see any trace of speakerdeck script element in the source.

lucdew commented 10 years ago

Ok i had a look at hugo's source code (site.go and page.go) and shortcodes are first parsed then the page is converted to html using the page's renderer (markdown in my case). As for my <script> element it seems normal that it is replaced to a single line feed by blackfriday's markdown library (after having seen the blackfriday inline tests https://github.com/russross/blackfriday/blob/master/inline_test.go).

I am little surprise by this behavior after reading hugo's doc (shortcodes are presented as a way to escape markdown for html), maybe it could be an enhancement for shortcodes to not have them parsed by markdown (it could be if the shortcode is in a layout/raw or layout/raw_short_codes directory)

chaseadamsio commented 10 years ago

does #305 close this bug?

lucdew commented 10 years ago

Yes it does, thanks !

On Sun, Sep 14, 2014 at 11:07 PM, Chase Adams notifications@github.com wrote:

does #305 https://github.com/spf13/hugo/pull/305 close this bug?

— Reply to this email directly or view it on GitHub https://github.com/spf13/hugo/issues/262#issuecomment-55539580.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.