Skip to content

Conversation

@developerfred
Copy link

Summary

Fixes #8 - Prism.js styles not applying on form submit.

When users change secondary languages and click Compare, the syntax highlighting styles were not applied until page reload.

Changes

  • Changed code element classes from custom-${lang} to language-${lang} to match Prism.js expected pattern
  • Added Prism.highlightAllUnder(section) in createLiSection() to apply highlighting to dynamically created elements
  • Optimized to apply highlighting only to specific sections instead of re-highlighting the entire page

Technical Details

The fix addresses two issues:

  1. Prism.js only recognizes classes matching the pattern language-xxxx, not custom-xxxx
  2. Prism.highlightAll() was not being called after dynamic element creation

By using Prism.highlightAllUnder(section) within createLiSection(), highlighting is applied efficiently to newly created elements only, improving performance.

Closes #8

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.

Bug: Prism.js styles not applying on form submit

1 participant