For example, segmentfault editor. . . . .
The code block is not highlighted, the content found by Baidu
hljs.initHighlightingOnLoad();
Rendering is executed during onload, that is to say, any changes to the document after that will not be executed. So obviously this cannot highlight the code of the document retrieved from the interface.
Note that I am talking about newly generated content, code highlighting is invalid, only pre code, no class. . .
There is more than one way to highlight code.
hljs.initHighlightingOnLoad()
just binds the highlighting operation to the document loading event.hljs.initHighlightingOnLoad()
Code:You can see the official documentation of HLJS:
https://highlightjs.org/usage/
There is a code example in the Custom Initialization section:
Example 1:
Example 2
So, if you only need to highlight a single area, just
Language-related configuration is configured through
.configure
. For configuration items, please refer to: http://highlightjs.readthedoc...