Skip to content

Commit b7e771b

Browse files
committed
Deployed e306425 with MkDocs version: 1.6.1
1 parent 8e87807 commit b7e771b

75 files changed

Lines changed: 1422 additions & 19288 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404.html

Lines changed: 1 addition & 710 deletions
Large diffs are not rendered by default.

assets/_markdown_exec_pyodide.css

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
html[data-theme="light"] {
2+
@import "https://cdn.jsdelivr.net/npm/highlightjs-themes@1.0.0/tomorrow.css"
3+
}
4+
5+
html[data-theme="dark"] {
6+
@import "https://cdn.jsdelivr.net/npm/highlightjs-themes@1.0.0/tomorrow-night-blue.min.css"
7+
}
8+
9+
10+
.ace_gutter {
11+
z-index: 1;
12+
}
13+
14+
.pyodide-editor {
15+
width: 100%;
16+
min-height: 200px;
17+
max-height: 400px;
18+
font-size: .85em;
19+
}
20+
21+
.pyodide-editor-bar {
22+
color: var(--md-primary-bg-color);
23+
background-color: var(--md-primary-fg-color);
24+
width: 100%;
25+
font: monospace;
26+
font-size: 0.75em;
27+
padding: 2px 0 2px;
28+
}
29+
30+
.pyodide-bar-item {
31+
padding: 0 18px 0;
32+
display: inline-block;
33+
width: 50%;
34+
}
35+
36+
.pyodide pre {
37+
margin: 0;
38+
}
39+
40+
.pyodide-output {
41+
width: 100%;
42+
margin-bottom: -15px;
43+
min-height: 46px;
44+
max-height: 400px
45+
}
46+
47+
.pyodide-clickable {
48+
cursor: pointer;
49+
text-align: right;
50+
}

assets/_markdown_exec_pyodide.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
var _sessions = {};
2+
3+
function getSession(name, pyodide) {
4+
if (!(name in _sessions)) {
5+
_sessions[name] = pyodide.globals.get("dict")();
6+
}
7+
return _sessions[name];
8+
}
9+
10+
function writeOutput(element, string) {
11+
element.innerHTML += string + '\n';
12+
}
13+
14+
function clearOutput(element) {
15+
element.innerHTML = '';
16+
}
17+
18+
async function evaluatePython(pyodide, editor, output, session) {
19+
pyodide.setStdout({ batched: (string) => { writeOutput(output, string); } });
20+
let result, code = editor.getValue();
21+
clearOutput(output);
22+
try {
23+
result = await pyodide.runPythonAsync(code, { globals: getSession(session, pyodide) });
24+
} catch (error) {
25+
writeOutput(output, error);
26+
}
27+
if (result) writeOutput(output, result);
28+
hljs.highlightElement(output);
29+
}
30+
31+
async function initPyodide() {
32+
try {
33+
let pyodide = await loadPyodide();
34+
await pyodide.loadPackage("micropip");
35+
return pyodide;
36+
} catch(error) {
37+
return null;
38+
}
39+
}
40+
41+
function getTheme() {
42+
return document.body.getAttribute('data-md-color-scheme');
43+
}
44+
45+
function setTheme(editor, currentTheme, light, dark) {
46+
// https://gist.github.com/RyanNutt/cb8d60997d97905f0b2aea6c3b5c8ee0
47+
if (currentTheme === "default") {
48+
editor.setTheme("ace/theme/" + light);
49+
document.querySelector(`link[title="light"]`).removeAttribute("disabled");
50+
document.querySelector(`link[title="dark"]`).setAttribute("disabled", "disabled");
51+
} else if (currentTheme === "slate") {
52+
editor.setTheme("ace/theme/" + dark);
53+
document.querySelector(`link[title="dark"]`).removeAttribute("disabled");
54+
document.querySelector(`link[title="light"]`).setAttribute("disabled", "disabled");
55+
}
56+
}
57+
58+
function updateTheme(editor, light, dark) {
59+
// Create a new MutationObserver instance
60+
const observer = new MutationObserver((mutations) => {
61+
// Loop through the mutations that occurred
62+
mutations.forEach((mutation) => {
63+
// Check if the mutation was a change to the data-md-color-scheme attribute
64+
if (mutation.attributeName === 'data-md-color-scheme') {
65+
// Get the new value of the attribute
66+
const newColorScheme = mutation.target.getAttribute('data-md-color-scheme');
67+
// Update the editor theme
68+
setTheme(editor, newColorScheme, light, dark);
69+
}
70+
});
71+
});
72+
73+
// Configure the observer to watch for changes to the data-md-color-scheme attribute
74+
observer.observe(document.body, {
75+
attributes: true,
76+
attributeFilter: ['data-md-color-scheme'],
77+
});
78+
}
79+
80+
async function setupPyodide(idPrefix, install = null, themeLight = 'tomorrow', themeDark = 'tomorrow_night', session = null) {
81+
const editor = ace.edit(idPrefix + "editor");
82+
const run = document.getElementById(idPrefix + "run");
83+
const clear = document.getElementById(idPrefix + "clear");
84+
const output = document.getElementById(idPrefix + "output");
85+
86+
updateTheme(editor, themeLight, themeDark);
87+
88+
editor.session.setMode("ace/mode/python");
89+
setTheme(editor, getTheme(), themeLight, themeDark);
90+
91+
writeOutput(output, "Initializing...");
92+
let pyodide = await pyodidePromise;
93+
if (install && install.length) {
94+
micropip = pyodide.pyimport("micropip");
95+
for (const package of install)
96+
await micropip.install(package);
97+
}
98+
clearOutput(output);
99+
run.onclick = () => evaluatePython(pyodide, editor, output, session);
100+
clear.onclick = () => clearOutput(output);
101+
output.parentElement.parentElement.addEventListener("keydown", (event) => {
102+
if (event.ctrlKey && event.key.toLowerCase() === 'enter') {
103+
event.preventDefault();
104+
run.click();
105+
}
106+
});
107+
}
108+
109+
var pyodidePromise = initPyodide();

assets/javascripts/bundle.a59f24f2.min.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/javascripts/bundle.c44cc438.min.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

assets/javascripts/bundle.c44cc438.min.js.map

Lines changed: 0 additions & 8 deletions
This file was deleted.

assets/javascripts/lunr/min/lunr.ar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/javascripts/lunr/min/lunr.el.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)