Skip to content

Conversation

@thedevilfish
Copy link

@thedevilfish thedevilfish commented Oct 7, 2025

This is a very quick fix to remove icon shortcodes from rendering as HAHAHUGOSHORTCODExxxx on the table of contents on the right hand side of the page. This PR should temporarily strip this until a better solution to actually render the icon properly is devised.

The fix itself uses replaceRE to sanitize the output and strip out the prefix.

@netlify
Copy link

netlify bot commented Oct 7, 2025

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit 05ce0ae
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/68e469e127296600073b959f
😎 Deploy Preview https://deploy-preview-854--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@thedevilfish
Copy link
Author

This should fix Issue #849

@thedevilfish
Copy link
Author

@imfing kindly review and provide any quick feedback.

<li class="hx:my-2 hx:scroll-my-6 hx:scroll-py-6">
<a class="{{ $class }} hx:inline-block hx:text-gray-500 hx:hover:text-gray-900 hx:dark:text-gray-400 hx:dark:hover:text-gray-300 hx:contrast-more:text-gray-900 hx:contrast-more:underline hx:contrast-more:dark:text-gray-50 hx:w-full hx:break-words" href="#{{ anchorize .ID }}">
{{- .Title | safeHTML | plainify | htmlUnescape }}
{{- replaceRE "HAHAHUGOSHORTCODE[0-9a-zA-Z]+HBHB" "" (.Title | safeHTML | plainify | htmlUnescape) }}gi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why there is a gi at the end?

Copy link
Owner

@imfing imfing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this approach relies on internal Hugo heuristics and string patterns that aren’t part of the public API. If Hugo changes its implementation or the shortcode prefix slightly, this workaround could easily break

The recommended way is to avoid including shortcodes (or any HTML) directly in headings in the first place

@imfing imfing added the wontfix This will not be worked on label Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants