Skip to content

Commit 069e5a2

Browse files
committed
Deployed 45f8904 with MkDocs version: 1.4.3
1 parent bfbd6b7 commit 069e5a2

File tree

74 files changed

+4137
-35342
lines changed

Some content is hidden

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

74 files changed

+4137
-35342
lines changed

404.html

+1-971
Large diffs are not rendered by default.

assets/_markdown_exec_pyodide.css

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
max-height: 400px
44+
}
45+
46+
.pyodide-clickable {
47+
cursor: pointer;
48+
text-align: right;
49+
}

assets/_markdown_exec_pyodide.js

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
let pyodide = await loadPyodide();
33+
await pyodide.loadPackage("micropip");
34+
return pyodide;
35+
}
36+
37+
function getTheme() {
38+
return document.body.getAttribute('data-md-color-scheme');
39+
}
40+
41+
function setTheme(editor, currentTheme, light, dark) {
42+
// https://gist.github.com/RyanNutt/cb8d60997d97905f0b2aea6c3b5c8ee0
43+
if (currentTheme === "default") {
44+
editor.setTheme("ace/theme/" + light);
45+
document.querySelector(`link[title="light"]`).removeAttribute("disabled");
46+
document.querySelector(`link[title="dark"]`).setAttribute("disabled", "disabled");
47+
} else if (currentTheme === "slate") {
48+
editor.setTheme("ace/theme/" + dark);
49+
document.querySelector(`link[title="dark"]`).removeAttribute("disabled");
50+
document.querySelector(`link[title="light"]`).setAttribute("disabled", "disabled");
51+
}
52+
}
53+
54+
function updateTheme(editor, light, dark) {
55+
// Create a new MutationObserver instance
56+
const observer = new MutationObserver((mutations) => {
57+
// Loop through the mutations that occurred
58+
mutations.forEach((mutation) => {
59+
// Check if the mutation was a change to the data-md-color-scheme attribute
60+
if (mutation.attributeName === 'data-md-color-scheme') {
61+
// Get the new value of the attribute
62+
const newColorScheme = mutation.target.getAttribute('data-md-color-scheme');
63+
// Update the editor theme
64+
setTheme(editor, newColorScheme, light, dark);
65+
}
66+
});
67+
});
68+
69+
// Configure the observer to watch for changes to the data-md-color-scheme attribute
70+
observer.observe(document.body, {
71+
attributes: true,
72+
attributeFilter: ['data-md-color-scheme'],
73+
});
74+
}
75+
76+
async function setupPyodide(idPrefix, install = null, themeLight = 'tomorrow', themeDark = 'tomorrow_night', session = null) {
77+
const editor = ace.edit(idPrefix + "editor");
78+
const run = document.getElementById(idPrefix + "run");
79+
const clear = document.getElementById(idPrefix + "clear");
80+
const output = document.getElementById(idPrefix + "output");
81+
82+
updateTheme(editor, themeLight, themeDark);
83+
84+
editor.session.setMode("ace/mode/python");
85+
setTheme(editor, getTheme(), themeLight, themeDark);
86+
87+
writeOutput(output, "Initializing...");
88+
let pyodide = await pyodidePromise;
89+
if (install && install.length) {
90+
micropip = pyodide.pyimport("micropip");
91+
for (const package of install)
92+
await micropip.install(package);
93+
}
94+
clearOutput(output);
95+
run.onclick = () => evaluatePython(pyodide, editor, output, session);
96+
clear.onclick = () => clearOutput(output);
97+
output.parentElement.parentElement.addEventListener("keydown", (event) => {
98+
if (event.ctrlKey && event.key.toLowerCase() === 'enter') {
99+
event.preventDefault();
100+
run.click();
101+
}
102+
});
103+
}
104+
105+
var pyodidePromise = initPyodide();

assets/javascripts/bundle.2047e101.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/javascripts/bundle.407015b8.min.js

-29
This file was deleted.

assets/javascripts/bundle.407015b8.min.js.map

-8
This file was deleted.

assets/javascripts/lunr/min/lunr.hy.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)