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

Nested shortcodes get rendered as Markdown #2173

Closed
mitchchn opened this issue May 27, 2016 · 9 comments
Closed

Nested shortcodes get rendered as Markdown #2173

mitchchn opened this issue May 27, 2016 · 9 comments

Comments

@mitchchn
Copy link
Contributor

mitchchn commented May 27, 2016

Version: Hugo Static Site Generator v0.16-DEV BuildDate: 2016-05-27T20:32:19+02:00.

My post has two shortcodes, one that is nested:

{{% wrapper %}}

## Some Markdown goes here.

This paragraph invokes a shortcode for retina images: {{< retina src="image.png" >}}

{{% /wrapper %}}

The issue is that retina.html is rendered as Markdown. Line breaks in the template code are treated as <p> tags, and other accidental Markdown syntax is parsed.

I get that the % sign means "render the insides as Markdown," but it shouldn't apply to internal shortcodes, which are HTML files and usually treated as such, even when they're invoked from Markdown content.

Otherwise, it's very difficult to mix Markdown and shortcodes inside another shortcode without running into formatting glitches.

@bep
Copy link
Member

bep commented May 27, 2016

I don't have the implementation details in my head now, but if you say this is how it is, then this is by design. Your obvious workaround here is to not use markdown in the outer wrapper.

@bep bep added the Wish label May 27, 2016
@bep
Copy link
Member

bep commented May 27, 2016

OK, this was it:

#797

I guess it is hard to make everyone happy.

@mitchchn
Copy link
Contributor Author

Could < and % perhaps be overloaded to determine this behaviour? If I have an internal {{% shortcode %}}, it would be passed through the Markdown renderer, but {{< shortcode >}} wouldn't.

It seems to me like that wouldn't conflict with the normal behaviour of those symbols. < would just be extended to mean "treat everything about this shortcode as HTML, always."

@bep
Copy link
Member

bep commented May 27, 2016

Could < and % perhaps be overloaded to determine this behaviour?

No idea what you mean here, but the current definition of:

{{<: The Inner content will not be passed through the markdown (or whatever) rendering engine
{{%: The Inner content will be passed through the markdown (or whatever) rendering engine

This is how it behaves today. I understand what you want, but you haven't presented a solution to it, at least not one that I understand.

@mitchchn
Copy link
Contributor Author

You're right. It doesn't make sense. I mixed up inner content (which this particular shortcode) doesn't have) with the HTML output of the shortcode itself.

It just goes to show that it's unintuitive for a shortcode to ever be rendered as anything but HTML. I do understand why you did it from your linked use case above. But I wish there were a way to avoid it.

@bep
Copy link
Member

bep commented May 27, 2016

But I wish there were a way to avoid it.

Me, too. And I will think about it. If you have any simple and good idea, please chime in.

@bep bep added the Stale label Feb 28, 2017
@bep
Copy link
Member

bep commented Mar 1, 2017

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

@bep bep closed this as completed Mar 27, 2017
@vai0
Copy link

vai0 commented Dec 13, 2018

I may be running into a similar situation: #5516

Would a reasonable solution be to add an option to Black Friday in the config to not pass nested shortcodes through the parser?

@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 Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants