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

@Kernix13
Copy link
Owner

Kernix13 commented Feb 1, 2026

I deliberately changed language- to custom- because the list items looked horrible that way. I'm using the list items as quick syntax compares and I do not need a black background for the inline code element.

I'm also seeing This branch has conflicts that must be resolved in the PR. I had no idea you created a PR - I changed changed my file structure so index.js is now in the js folder.

@Kernix13
Copy link
Owner

Kernix13 commented Feb 1, 2026

I forgot about this issue and the fact that the pre code blocks were not showing syntax highlighting.

@Kernix13
Copy link
Owner

Kernix13 commented Feb 1, 2026

I apologize for just noticing your PRs today. I was not getting notifications for this repo - I just changed that. Let me know how you would like to handle your 2 PRs because I do not want to change custom- to language- for the li items, and index.js has been moved.

@developerfred
Copy link
Author

@Kernix13 Thank you for the feedback, I will adapt my pull requests to include your update.

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

2 participants