knative / website

Hugo templates for the Knative website.
https://knative.dev
Other
23 stars 70 forks source link

shortcodes with HTML in {{< tab >}} are stripped #131

Open mattmoor opened 4 years ago

mattmoor commented 4 years ago

So I hit this trying to use https://github.com/knative/website/issues/126 from within a tab...

Basically, unless I flip the switch to allow HTML through from markdown (even though the HTML is coming from a shortcode!) the HTML generated by my feature-state is scrubbed 😢

I suspect that this is a problem with tab, not the new stuff, but I don't speak this stuff well enough to meaningfully debug (it's all trial and error).

cc @RichieEscarez in case he has any quick insights 🙏

RichieEscarez commented 4 years ago

@mattmoor, each shortcode gets sent to the markdown processor by default but there are ways to indicate not to process (ie. just copy content). Hugo gets unhappy we you nest shortcodes (one calls the other, etc.).

Sorry i dont have time to dig in but i describe some of this here in the readfile shortcode.

In short {{%... goes to processor, {{<.... skips it. There is also {{-... that removes whitespace (example in version shortcode). Another helpful method is Scratch (examples in both shortcodes), which allows you to use a single variable which you can then set a specific value (ie. if this, then that).

mattmoor commented 4 years ago

@RichieEscarez that's super helpful, I will dig into that some more :)

mattmoor commented 4 years ago

I think that this is essentially what the tabs are hitting:

IMPORTANT: You cannot nest shortcodes. When the Hugo build runs on a file,
any shortcodes within that file are processed. For example, if you use `readFile`
to include a source file, and that source file contains another shortcode,
none of those "nested shortcodes" are processed. Nesting a shortcode within another
shortcode results in incorrectly rendered content
(ie. `{{% the short code syntax shows in the HTML of the parent file %}}`).
RichieEscarez commented 4 years ago

Known Hugo limitation: https://discourse.gohugo.io/t/call-shortcodes-in-markdownified-text/21189

RichieEscarez commented 3 years ago

Looks like there might be a path to fixing this but some investigation and testing needs to be done: https://github.com/knative/website/issues/227