docs: Add dynamic code block highlighting documentation (#1626)

This commit is contained in:
Aarav Borthakur 2021-08-27 03:34:34 -07:00 committed by GitHub
parent 66303fec4c
commit 72485a38c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,3 +51,13 @@ function getAdder(int $x): int
return 123;
}
```
## Highlighting Dynamic Content
Code blocks [dynamically created from javascript](https://docsify.js.org/#/configuration?id=executescript) can be highlighted using the method `Prism.highlightElement` like so:
```javascript
var code = document.createElement("code");
code.innerHTML = "console.log('Hello World!')";
code.setAttribute("class", "lang-javascript");
Prism.highlightElement(code);
```