Code syntax highlighting javascript (code-prettify) is executed twice (original) (raw)

From #17887 (comment)

Context

Currently, the website uses JavaScript to provide syntax highlighting. This is done via the code-prettify library. The highlighting is provided on runtime (when you open the page in the browser.

The prettifier comes from the Apache Maven Fludio Skin plugin that we use. You can see it in the plugin's GitHub repository here - src/main/resources/js/prettify.js

Problem

The prettifier is executed twice:

  1. Once in the Maven Fluido Skin src/main/resources/fluido.js script
  2. And then again by this line in checkstyle.js

Proof that the execution happens twice

You can actually see that on the website (for example at https://checkstyle.org/writingjavadocchecks.html). If you inspect one of the code blocks, you will see that for each token, there is a <span> within a <span>:

java ...

But if we remove prettyPrint(); from checkstyle.js, then we get:

java ...