Closed FIGBERT closed 2 years ago
Hm I didn't think anyone was using shortcodes in code blocks...
I believe for now you can fix it by not using a markdown code block:
<pre>
{{ audio(sources=["example.wav", "example.ogg", "example.mp3"]) }}
</pre>
(or whatever combination of pre
/code
you get with the Zola code blocks).
This doesn't appear to work – instead, it renders the shortcode within the pre
tag. I've tried several different combinations of pre
, code
, and span
, as well as several different browsers.
ah yes it will not be escaped... I guess it needs to handle shortcodes in codeblocks too. If anyone wants to try, it should be self-contained to components/rendering/src/markdown.rs
except for tests
Hm I didn't think anyone was using shortcodes in code blocks...
But it's interesting idea, isn't it?! I'd definitely like to see this working too, please.
I think this issue could be closed now? It's been fixed in #1720.
I usually close on release to avoid duplicate issues. I put the Done tag to try to remember to close it at that point ;)
Fixed in release 0.15.3! What a great community we've got here - thanks everyone for the quick patch.
This still appears to be happening for me with zola 0.17.2
```text
{{example()}}
```
Results in
Error: Reason: Found usage of a shortcode named `example` but we do not know about. Make sure it's not a typo and that a field name `example.{html,md} exists in the `templates/shortcodes` directory.
Update: Hmm, perhaps this is actually working as intended.
In my case, I just want to display the literal text, not trigger a shortcode. Is there a way for me to escape this so that I just get the literal {{example()}}
?
Update 2: 🤦 it's right there in the docs
Note that if you want to have some content that looks like a shortcode but not have Zola try to render it, you will need to escape it by using {{/ and /}} instead of {{ and }}.
Sorry for the noise, please ignore this comment.
It does not happen only in code blocks. I used to have
<a name="contact-me" href="mailto:{{ email() }}">{{ email() }}</a>
where email
is a shortcode, which used to work but the latest versions have broken it and it simply outputs @@ZOLA_SC_PLACEHOLDER@@
Bug Report
Environment
Zola version: 0.15.2
Expected Behavior
Tell us what should have happened.
In previous versions of Zola, I was able to put shortcodes in fenced code blocks in order to give the viewer an idea of what the generated HTML of the shortcode would look like when used.
This is useful, for example, when giving examples of custom shortcodes in Zola themes.
Current Behavior
Tell us what happens instead of the expected behavior. If you are seeing an error, please include the full error message and stack trace. You can get the stacktrace of a panic by adding
RUST_BACKTRACE=1
when running azola
command.In the current version of Zola, these shortcodes just output
@@ZOLA_SC_PLACEHOLDER@@
.Step to reproduce
Please provide the steps to reproduce the issue. If the issue is hard to reproduce, please provide a sample repository or sample that triggers the bug.
To view this in action, clone figbert/d3c3nt and run
zola serve
in the root directory. From there, navigate to/posts/rich-content/
and scroll around.