Skip to content

fix: re-highlight Prism code blocks after a language toggle - #12

Merged
gabrielfins merged 1 commit into
masterfrom
dev
Sep 18, 2026
Merged

gabrielfins merged 1 commit into
masterfrom
dev

Conversation

@gabrielfins

@gabrielfins gabrielfins commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Three example snippets in the "How to use" section carry both a Prism language class and data-i18n-html on the same <code> element.
  • Toggling the page language overwrote Prism's highlighted markup with plain translated text, and nothing re-triggered highlighting since Prism only runs its automatic pass once on page load.
  • docs/js/i18n.js now calls Prism.highlightElement() on any affected code block right after its translated content is set.

Test plan

  • Verified node --check docs/js/i18n.js passes
  • Toggle PT/EN a few times on the live site and confirm the three "Usage" example snippets stay syntax-highlighted

Three example snippets carry both a Prism language class and
data-i18n-html on the same <code> element. Swapping the translation
overwrote Prism's highlighted markup with plain text, and nothing
re-triggered highlighting since Prism only runs its automatic pass
once on page load. Now re-highlights just the affected blocks right
after their translated content is set.
@gabrielfins
gabrielfins merged commit 217c574 into master Sep 18, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

1 participant