From ae51965ec49159364be94b21e54e6bf100d4f7d0 Mon Sep 17 00:00:00 2001 From: Aarav Borthakur <69025547+gadhagod@users.noreply.github.com> Date: Wed, 18 Aug 2021 17:54:31 -0700 Subject: [PATCH 1/2] Add dynamic code block highlighting documentation --- docs/language-highlight.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/language-highlight.md b/docs/language-highlight.md index 1e089c10d..3337b4f92 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 = "echo 'Hello World!'" +code.setAttribute("class", "lang-bash"); +Prism.highlightElement(code); +``` From 94ea16ed70f62b567deb7ec30f0eeb2314d2848e Mon Sep 17 00:00:00 2001 From: Aarav Borthakur <69025547+gadhagod@users.noreply.github.com> Date: Fri, 20 Aug 2021 21:27:11 -0700 Subject: [PATCH 2/2] Change "Highlighting Dynamic Content" section example to javascript --- docs/language-highlight.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/language-highlight.md b/docs/language-highlight.md index 3337b4f92..1956af71f 100644 --- a/docs/language-highlight.md +++ b/docs/language-highlight.md @@ -57,7 +57,7 @@ Code blocks [dynamically created from javascript](https://docsify.js.org/#/confi ```javascript var code = document.createElement("code"); -code.innerHTML = "echo 'Hello World!'" -code.setAttribute("class", "lang-bash"); +code.innerHTML = "console.log('Hello World!')"; +code.setAttribute("class", "lang-javascript"); Prism.highlightElement(code); ```