First cookbook example for the docs: Hello World in C.
This commit is contained in:
parent
d664099c9d
commit
d663c9b67d
10 changed files with 216 additions and 2 deletions
25
Documentation/fetchcode.js
Normal file
25
Documentation/fetchcode.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
async function fetchCode(e, lang, src) {
|
||||
const resp = await fetch(src);
|
||||
const t = await resp.text();
|
||||
e.innerHTML = hljs.highlight(lang, t).value;
|
||||
}
|
||||
|
||||
function fetchAndHighlightAll() {
|
||||
const el = document.getElementsByTagName('code');
|
||||
for (const e of el) {
|
||||
const src = e.getAttribute('src');
|
||||
if (!src) continue;
|
||||
const lang = e.getAttribute('lang');
|
||||
const title = document.createElement('b');
|
||||
title.innerText = src;
|
||||
title.style.textAlign = 'center';
|
||||
title.style.display = 'block';
|
||||
e.parentElement.insertBefore(title, e);
|
||||
fetchCode(e, lang, src);
|
||||
console.log('found', lang, src);
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(fetchAndHighlightAll, 0);
|
||||
Loading…
Add table
Add a link
Reference in a new issue