From 72485a38c12e3508af7ccf25b41ce9e9b72dc5b0 Mon Sep 17 00:00:00 2001 From: Aarav Borthakur <69025547+gadhagod@users.noreply.github.com> Date: Fri, 27 Aug 2021 03:34:34 -0700 Subject: [PATCH] docs: Add dynamic code block highlighting documentation (#1626) --- docs/language-highlight.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/language-highlight.md b/docs/language-highlight.md index 1e089c10..1956af71 100644 --- a/docs/language-highlight.md +++ b/docs/language-highlight.md @@ -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); +```