diff options
author | Lars Thorsén <[email protected]> | 2017-04-26 14:42:31 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-04-26 14:42:31 +0200 |
commit | 157317c25b20e8af3d61fa833fa9554ceb9bb968 (patch) | |
tree | d81659e077eed0c353bd4dd435846ffd545a123e /lib/erl_docgen/priv/js/highlight.js | |
parent | b1df6219d51a56cb934d91225af9d8f78931c3ce (diff) | |
parent | 7bbfffcef7b7c81d1797a0d66c0fdfd3a646f5a9 (diff) | |
download | otp-157317c25b20e8af3d61fa833fa9554ceb9bb968.tar.gz otp-157317c25b20e8af3d61fa833fa9554ceb9bb968.tar.bz2 otp-157317c25b20e8af3d61fa833fa9554ceb9bb968.zip |
Merge pull request #1215 from marianoguerra/improve-docs-style
Merge PR-1215 from 'marianoguerra/improve-docs-style'
OTP-14371
Improve Documentation Style
Diffstat (limited to 'lib/erl_docgen/priv/js/highlight.js')
-rw-r--r-- | lib/erl_docgen/priv/js/highlight.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/erl_docgen/priv/js/highlight.js b/lib/erl_docgen/priv/js/highlight.js new file mode 100644 index 0000000000..0594b42aa3 --- /dev/null +++ b/lib/erl_docgen/priv/js/highlight.js @@ -0,0 +1,39 @@ +/*globals document, window*/ +window.addEventListener("load", function () { + "use strict"; + var body = document.body, + base = window.__otpTopDocDir || "/doc/js/", + cssLink = document.createElement('link'), + script = document.createElement('script'), + intervalId, attempts = 0; + + cssLink.rel = "stylesheet"; + cssLink.href = base + "../highlight.css"; + script.src = base + "highlight.pack.js"; + + body.appendChild(cssLink); + body.appendChild(script); + + function doHighlight() { + attempts += 1; + + if (attempts > 20) { + window.clearInterval(intervalId); + return; + } + + if (!window.hljs) { + return; + } + + window.clearInterval(intervalId); + + var i, len, nodes = document.querySelectorAll('.example'); + for (i = 0, len = nodes.length; i < len; i += 1) { + window.hljs.highlightBlock(nodes[i]); + } + + } + + intervalId = window.setInterval(doHighlight, 50); +}); |