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

Left-side navigation broken #859

Closed
FuadEfendi opened this issue Oct 27, 2024 · 11 comments
Closed

Left-side navigation broken #859

FuadEfendi opened this issue Oct 27, 2024 · 11 comments

Comments

@FuadEfendi
Copy link

Hi Razon, I am not sure if this is correct "module" to report the issue.

On this page, https://javascripttypescriptbooks.com/2/4/2/1/ I have 4.2.2 and 4.2.3 items. When I click on it, "menu" collapses. 4.2.3 has `<script>` Tag words, but why 4.2.2 has same behavior, unclear. I can only guess "script" is reserved keyword and Menu breaks if it has this word... I encountered very similar issue in past when I tried to have content/terms folder, it breaks too, "terms" is reserved. Thanks,

@FuadEfendi
Copy link
Author

On this page too: https://javascripttypescriptbooks.com/2/2/8/
Try to click 2.8.1 The `<form>` Element on left-side menu

@razonyang
Copy link
Member

razonyang commented Oct 27, 2024

Something is wrong on your content, which cause the <script> tag was imcomplete, and the footer is also missing.

Please check if there is raw HTML in the content that disrupts the HTML markup, as the image below shown, the script tag was broken on a specific page, which should be highlighting as the second script.

image

A common case is that there is some invalid raw HTML inside content, for example.

<div>FOOBAR</div>
</div>

The example above has a extra </div> which may close parent element early, and breaks rest of HTML markup entirely.

@razonyang
Copy link
Member

Please also check the Quiz Time! section, seems all the broken pages have this section.

@FuadEfendi
Copy link
Author

Thank you Razon,

I can see it now too, it is Quiz section which is not HTML-escaped; "HTML injection"

### 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.

@FuadEfendi
Copy link
Author

Reported to "Quizdown", bonartm/quizdown-js#55

@razonyang
Copy link
Member

OK, I'm closing this because it's not a matter of theme.

@FuadEfendi
Copy link
Author

Yes, "user error"; thank you for the help!
I need to use escaped &lt;head&gt; in Markdown.

@FuadEfendi
Copy link
Author

Finally I reported this bug and workaround to Hugo:
https://discourse.gohugo.io/t/fake-replace-fixes-possible-bug-with-shortcodes/52155

@razonyang
Copy link
Member

razonyang commented Oct 27, 2024

I don't think it would be considered a bug, it's the responsibility of users to escape their customized HTML content.

By the way, there is a htmlEscape function that might be helpful.

@FuadEfendi
Copy link
Author

No, it is bug in Hugo: {{ replace .Inner " " " " }} will escape, and {{ .Inner }} won't. htmlEscape will output &amp;lt; instead of &lt;.

@FuadEfendi
Copy link
Author

Yes perhaps not a bug (really?): {{ replace .Inner " " " " }} will escape, and {{ .Inner }} won't.

This does work, as suggested by @jmooring at Hugo:

<div class='quizdown'>
  {{ .Inner | htmlEscape | safeHTML }}
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants