images/image are malformed inside of other shortcode
#112
-
|
I've created two shortcodes that relies on
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
|
Could you please provide a minimal reproduce repo contains the shortcodes and example, it would be easy to help with. |
Beta Was this translation helpful? Give feedback.
-
$ git diff
diff --git a/layouts/shortcodes/collapse.html b/layouts/shortcodes/collapse.html
index 066af26..45e3adc 100644
--- a/layouts/shortcodes/collapse.html
+++ b/layouts/shortcodes/collapse.html
@@ -27,5 +27,5 @@
<a type="button" class="collapse-toggle text-decoration-none text-bg-{{ $style }} py-1 px-2" data-bs-toggle="collapse" href="#{{ $id }}" aria-expanded="{{ cond $expand `true` `false` }}" aria-controls="{{ $id }}" style="">
{{- $heading | safeHTML | markdownify -}}
</a>
- <div class="collapse{{ cond $border ` border` `` }}{{ cond $rounded ` rounded-bottom rounded-end` `` }} px-2 pt-2 pb-1 mb-3{{ cond $expand ` show` `` }}" id="{{ $id }}" >{{- trim .Inner "\r\n" | .Page.RenderString -}}</div>
+ <div class="collapse{{ cond $border ` border` `` }}{{ cond $rounded ` rounded-bottom rounded-end` `` }} px-2 pt-2 pb-1 mb-3{{ cond $expand ` show` `` }}" id="{{ $id }}" >{{ .Inner }}</div>
</div>
~Just use |
Beta Was this translation helpful? Give feedback.






After some trials, I've figured out I've asked this kind of question, rendering both HTML and Markdown content in shortcode before (and you've answered it!)
The solution was to remove some line breaks in original source code.
images/imageshortcode callsimages/picturein my case. It has this codeIf there is no
.wrapperClassand.attrs, it will produce this HTML code.While this is valid HTML, Hugo doesn't seem to think it as valid HTML code. That's why I've got
<p><picture</p>when the content ofcollapseis rendered.So I copied
images/pictureto local and modified…