summaryrefslogtreecommitdiff
path: root/doc/_static
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2019-11-24 14:49:02 +0100
committerGeorg Brandl <georg@python.org>2019-11-24 14:49:02 +0100
commit4a6f8b4bc9f9532706a07c899094e30edb093062 (patch)
tree8fb1b9f6cdb61246c1ae7d11339fa7a9c3739c38 /doc/_static
parent99d7a25d63b0a55136570919bd590b80571b91de (diff)
downloadpygments-git-4a6f8b4bc9f9532706a07c899094e30edb093062.tar.gz
add feature to download generated HTML
Diffstat (limited to 'doc/_static')
-rw-r--r--doc/_static/demo.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/_static/demo.js b/doc/_static/demo.js
index db2a8e07..00ed722f 100644
--- a/doc/_static/demo.js
+++ b/doc/_static/demo.js
@@ -78,4 +78,16 @@ function highlight_now() {
var out = document.getElementById("hlcode");
out.innerHTML = pyodide.runPython('pygments.highlight(code, lexer, fmter)');
document.location.hash = "#try";
+ document.getElementById("hlcodedl").style.display = "block";
+}
+
+function download_code() {
+ var element = document.createElement('a');
+ var hlcode = document.getElementById("hlcode").innerHTML;
+ element.setAttribute("href", "data:text/html;charset=utf-8," + encodeURIComponent(hlcode));
+ element.setAttribute("download", "highlighted.html");
+ element.style.display = "none";
+ document.body.appendChild(element);
+ element.click();
+ document.body.removeChild(element);
}