McShelby / hugo-theme-relearn

A theme for Hugo designed for documentation
https://mcshelby.github.io/hugo-theme-relearn/
MIT License
440 stars 191 forks source link

allow markdown in notice content #559

Closed ChristopherBarrington closed 1 year ago

ChristopherBarrington commented 1 year ago

It would be nice to be able to include markdown in the notices, in my case backticked code was rendered as plain text with backticks. Modifying the below to include a pass through markdownify seemed to work for me using a site-level partial rather than theme-level.

Maybe it would be useful for others or is there a better way to achieve the same?

https://github.com/McShelby/hugo-theme-relearn/blob/df374637892b22e3f7199c69845aa935485def13/layouts/partials/shortcodes/notice.html#L23

Could this be safe to use: $content | markdownify | safeHTML

McShelby commented 1 year ago

Are you sure? https://mcshelby.github.io/hugo-theme-relearn/shortcodes/notice/index.html#info-with-markup works just fine in the live view.

If you are using the theme directly from the main branch of this repo, you may experiencing issues. These are fixed in the current head, so I expect your example to work with either 5.15.x or the latest head of this repo.

If not, at least your used Hugo and theme version is required but a better way would be to share your code.

McShelby commented 1 year ago

Anyways: Thanks for reporting as bugs sometimes slip thru.

ChristopherBarrington commented 1 year ago

Thanks for the quick reply, I have updated the submodule with git submodule update --remote so should be on the newest commit.

The example shortcode on the docs does work as expected and I added an inline code that worked too.

The code I had that was not working:

{{< notice style="warning" title=" " icon=" " >}}
`$variable`
{{< /notice >}}

If I switch to {{% syntax it works as expected. I will read up on the difference.

McShelby commented 1 year ago

Why is my comment above yours - although I typed it after yours. GitHub also has bugs ;-)

Duplicate of #555

ChristopherBarrington commented 1 year ago

sorry - this was me replying before checking thoroughly. I deleted my comment rather than editing it. sorry for that, you were too fast!

McShelby commented 1 year ago

Yeah, #555 came also because of Hugos different handling of < vs. % (and there is a third, hidden variant when writing shortcodes - also different)