@@ -14,28 +14,30 @@ def get_last_statement(code): return ast.unparse(ast.parse(code).body[-1])
14
14
from pathlib import Path
15
15
16
16
17
- hjs = (Style ('html.dark .hljs-copy-button {background-color: #e0e0e0; color: #2d2b57;}' ),
17
+ hjs = (Style (''' .hljs-copy-button {background-color: #2d2b57;}
18
+ html.dark .hljs-copy-button {background-color: #e0e0e0; color: #2d2b57;}''' ),
18
19
Link (rel = 'stylesheet' , href = 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/atom-one-dark.css' , disabled = True ),
19
20
Link (rel = 'stylesheet' , href = 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/atom-one-light.css' , disabled = True ),
20
21
Script (src = 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js' ),
21
22
Script (src = 'https://cdn.jsdelivr.net/gh/arronhunt/highlightjs-copy/dist/highlightjs-copy.min.js' ),
22
23
Link (rel = 'stylesheet' , href = 'https://cdn.jsdelivr.net/gh/arronhunt/highlightjs-copy/dist/highlightjs-copy.min.css' ),
23
- Style ('.hljs-copy-button {background-color: #2d2b57;}' ),
24
24
Script (src = 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/languages/python.min.js' ),
25
- Script ("hljs.addPlugin(new CopyButtonPlugin());\r \n hljs.configure({'cssSelector': 'pre code'});\r \n htmx.onLoad(hljs.highlightAll);" , type = 'module' ),
26
- Script ('''htmx.on("htmx:beforeHistorySave", () => {document.querySelectorAll("uk-icon").forEach((elt) => {elt.innerHTML = '';});});''' ),
27
-
28
- Script ('''hljs.configure({
29
- ignoreUnescapedHTML: true
30
- });''' ),
31
- Script ('''const observer = new MutationObserver(mutations => {
32
- mutations.forEach(mutation => {
33
- if (mutation.target.tagName === 'HTML' && mutation.attributeName === 'class') {
34
- const isDark = mutation.target.classList.contains('dark');
35
- document.querySelector('link[href*="atom-one-dark.css"]').disabled = !isDark;
36
- document.querySelector('link[href*="atom-one-light.css"]').disabled = isDark;
37
- }
38
- });
25
+ Script ('''
26
+ hljs.addPlugin(new CopyButtonPlugin());
27
+ hljs.configure({
28
+ cssSelector: 'pre code',
29
+ ignoreUnescapedHTML: true
30
+ });
31
+ htmx.onLoad(hljs.highlightAll);
32
+
33
+ const observer = new MutationObserver(mutations => {
34
+ mutations.forEach(mutation => {
35
+ if (mutation.target.tagName === 'HTML' && mutation.attributeName === 'class') {
36
+ const isDark = mutation.target.classList.contains('dark');
37
+ document.querySelector('link[href*="atom-one-dark.css"]').disabled = !isDark;
38
+ document.querySelector('link[href*="atom-one-light.css"]').disabled = isDark;
39
+ }
40
+ });
39
41
});
40
42
41
43
observer.observe(document.documentElement, { attributes: true });
@@ -44,7 +46,7 @@ def get_last_statement(code): return ast.unparse(ast.parse(code).body[-1])
44
46
const isDark = document.documentElement.classList.contains('dark');
45
47
document.querySelector('link[href*="atom-one-dark.css"]').disabled = !isDark;
46
48
document.querySelector('link[href*="atom-one-light.css"]').disabled = isDark;
47
- '' ' ))
49
+ ''' , type = 'module ' ))
48
50
49
51
def create_flippable_card (content , source_code , extra_cls = None ):
50
52
"Creates a card that flips between content and source code"
@@ -57,7 +59,7 @@ def create_flippable_card(content, source_code, extra_cls=None):
57
59
DivFullySpaced (UkIcon ('corner-down-right' , 20 , 20 , 3 ),"See Output" ),
58
60
uk_toggle = f"target: #{ _id } " , id = _id , cls = ButtonT .primary , hidden = True ),
59
61
Div (content , id = _id ),
60
- Div (Pre (Code (source_code , cls = "hljs language-python" )), id = _id , hidden = True , cls = "mockup-code" ),
62
+ Div (Pre (Code (source_code , cls = "hljs language-python" )), id = _id , hidden = True ), #, cls="mockup-code"
61
63
cls = 'my-8' )
62
64
return Div (_card , cls = extra_cls ) if extra_cls else _card
63
65
0 commit comments