Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing markdown inside shortcodes #5900

Closed
pawelgrzybek opened this issue Apr 25, 2019 · 16 comments
Closed

Parsing markdown inside shortcodes #5900

pawelgrzybek opened this issue Apr 25, 2019 · 16 comments
Labels

Comments

@pawelgrzybek
Copy link

Hi.

$ hugo env
Hugo Static Site Generator v0.55.3/extended darwin/amd64 BuildDate: unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.12.4"

I have a shortcode update.

<p class="update">{{ .Inner  }}</p>

When I use it with some markdown content (link for example).

{{% update %}}This is link to a [google](https://google.com).{{% /update %}}

It is not getting converted to HTML anymore. I am almost sure it used to work just fine on previous versions of Hugo. Currently it outputs a plain text.

Still ❤️ Hugo and thanks for building amazing software!

@bep
Copy link
Member

bep commented Apr 25, 2019

Please use https://discourse.gohugo.io/ for questions/troubleshooting. Also see Hugo Documentation.

@bep bep closed this as completed Apr 25, 2019
@SamWhited
Copy link

SamWhited commented Apr 25, 2019

@bep I'm not sure if this is the same thing, but as of v0.55.3 this behavior has changed for me. That used to render markdown, and now it doesn't. I don't see anything in the documentation that would explain that change. Are you sure this should have been closed? It appears to be a valid bug report.

@pawelgrzybek
Copy link
Author

@SamWhited
Copy link

SamWhited commented Apr 25, 2019

@pawelgrzybek I have read that; I apparently don't understand what it means, because I don't even know what the old or new behavior is. That makes it sound like the new behavior should still be rendering markdown, but I'm not getting any markdown rendered anymore. Is that he cause of this problem? If so, why does it just break every single shortcode I have in my theme and sites and should I be reverting to the old behavior or piping .Inner to markdownify? What are the tradeoffs to doing it one way or the other?

I see a bunch of threads on the mailing list, but I can't sign up to participate and they don't seem to have answers either. It seems like I'm not the only one confused by this and who thought it was a bug that everything suddenly broke.

@pawelgrzybek
Copy link
Author

The solution is mentioned in the docs. This is everything that you have to do.

pawelgrzybek/pawelgrzybek.com@6c0e63e

Hopefully that helps.

@SamWhited
Copy link

SamWhited commented Apr 25, 2019 via email

@SamWhited
Copy link

SamWhited commented Apr 26, 2019

Am I really the only one that thinks that is confusing and doesn't tell me anything? What does it even mean that it is "fully rendered"?

I still have no idea if that's an okay solution, or if it's just going to go away in a few months since apparently whatever the old behavior was is deprecated. Also, what is the difference between doing that and piping to markdownify and why would I use one over the other? The changelog just mentions this but doesn't give you any information about what's happening or what the benefits of doing one or the other might be.

@SamWhited
Copy link

SamWhited commented Apr 26, 2019

I don't want to do better, it might be fine. I just want it documented what the options are and what the benefits and drawbacks are in such away that's understandable to someone who isn't familiar with Hugo's internals and just uses it to build websites.

@fritzmg
Copy link

fritzmg commented May 16, 2019

I agree that the documentation is confusing. It clearly states that, even in 0.55, if you want to use markdown in your shortcodes, you have to use the % delimiter.

However, that is exactly what is not working.

@SamWhited
Copy link

Please listen to @fritzmg and all the other people that opened issues for this. We can't update the docs because no one understands what this means, and I'm still lost as to what actually changed or what solution I should use. Stop blaming your users for being confused and write clearer docs.

@fritzmg
Copy link

fritzmg commented May 19, 2019

I have contributed to this discussion thread here, I think this clears things up a little: https://discourse.gohugo.io/t/misunderstanding-of-shortcode-syntax-in-0-55/18538

@SamWhited
Copy link

That all makes a lot more sense than the documentation; thanks for linking the thread.

@fritzmg
Copy link

fritzmg commented May 19, 2019

Though I discovered that the new approach is not without problems: https://discourse.gohugo.io/t/misunderstanding-of-shortcode-syntax-in-0-55/18538/25

badboy99tw added a commit to APOD-Taigi/apod-taigi.github.io that referenced this issue Feb 13, 2021
@wilitp
Copy link

wilitp commented Feb 16, 2021

For anyone actually looking for a solution...

If you are using your shortcode as

{{ myclosingsc }} 
# heading 
{{ myclosingsc /}}

shotcodes/myclosingsc.html:

{{ .Inner | markdownify}}

this outputs:

<h1>heading</h1>

@kuncevic
Copy link

Got this issue zwbetz-gh/papercss-hugo-theme#8 using #5900 (comment) solution.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants