I have simple shortcode for Quizdown.js:
{{ $_hugo_config := `{ "version": 1 }` }}
<div class='quizdown'>
{{ .Inner }}
</div>
And here is simple Quiz:
## Quiz Time!
{{< quizdown >}}
### Where is it recommended to place non-essential internal scripts for optimal page load performance?
- [ ] In the `<head>` section
- [x] At the end of the `<body>` section
- [ ] In an external file
- [ ] In a `<div>` element
> **Explanation:** Placing non-essential scripts at the end of the `<body>` allows the HTML content to load first, improving perceived performance.
{{< /quizdown >}}
Quizdown javaScript library expects uncompressed plain Markdown wrapped in div
.
This shortcode generates unescaped output which breaks the page HTML:
<h2 id="quiz-time">Quiz Time!</h2>
<div class='quizdown'>
### Where is it recommended to place non-essential internal scripts for optimal page load performance?
- [ ] In the `<head>` section
- [x] At the end of the `<body>` section
- [ ] In an external file
- [ ] In a `<div>` element
> **Explanation:** Placing non-essential scripts at the end of the `<body>` allows the HTML content to load first, improving perceived performance.
</div>
However, by just adding fake replace
function, it works:
{{ $_hugo_config := `{ "version": 1 }` }}
<div class='quizdown'>
{{ replace .Inner " " " " }}
</div>
Output:
<h2 id="quiz-time">Quiz Time!</h2>
<div class='quizdown'>
### Where is it recommended to place non-essential internal scripts for optimal page load performance?
- [ ] In the `<head>` section
- [x] At the end of the `<body>` section
- [ ] In an external file
- [ ] In a `<div>` element
> **Explanation:** Placing non-essential scripts at the end of the `<body>` allows the HTML content to load first, improving perceived performance.
</div>