Spaces:
Running
Running
Commit
·
ee8109d
1
Parent(s):
212b55d
Refactor post generation to streamline Markmap integration and enhance styling in post_blog.py
Browse files- post_blog.py +11 -27
post_blog.py
CHANGED
@@ -23,9 +23,7 @@ def generate_post_html(title, summary, mindmap, citation):
|
|
23 |
html_summary = mistune.html(summary)
|
24 |
post = f"""
|
25 |
<div id="paper_post">
|
26 |
-
<link href="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.18.4/dist/index.min.js" rel="preload" as="script">
|
27 |
<script src="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.18.4/dist/index.min.js"></script>
|
28 |
-
<link href="https://cdn.jsdelivr.net/npm/markmap-autoloader@latest" rel="preload" as="script">
|
29 |
<script src="https://cdn.jsdelivr.net/npm/markmap-autoloader@latest"></script>
|
30 |
<script>
|
31 |
window.markmap = {{
|
@@ -36,14 +34,12 @@ def generate_post_html(title, summary, mindmap, citation):
|
|
36 |
</script>
|
37 |
<script>
|
38 |
window.addEventListener('load', function() {{
|
39 |
-
setTimeout(function() {{
|
40 |
const element = document.querySelector('div.mm-toolbar-item[title="Fit window size"]');
|
41 |
if (element) {{
|
42 |
element.click();
|
43 |
}} else {{
|
44 |
console.log('Element not found');
|
45 |
}}
|
46 |
-
}}, 500);
|
47 |
}});
|
48 |
</script>
|
49 |
<style>
|
@@ -56,6 +52,16 @@ def generate_post_html(title, summary, mindmap, citation):
|
|
56 |
height: 80dvh;
|
57 |
}}
|
58 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
<img style="display:block; width:100%; height:100%;" id="paper_image" src="{image}" alt="{title}">
|
60 |
<br>
|
61 |
<b>{{getToc}} $title={{Table of Contents}}</b>
|
@@ -68,7 +74,7 @@ def generate_post_html(title, summary, mindmap, citation):
|
|
68 |
<p><small><em>If MindMap doesn't load, please refresh the page.</em></small></p>
|
69 |
<div class="markmap" id="paper_mindmap">
|
70 |
<script type="text/template">
|
71 |
-
{
|
72 |
</script>
|
73 |
</div>
|
74 |
<br>
|
@@ -76,29 +82,7 @@ def generate_post_html(title, summary, mindmap, citation):
|
|
76 |
<div id="paper_citation">
|
77 |
{mistune.html(citation.replace("&", "&"))}
|
78 |
</div>
|
79 |
-
<script src="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.18.4/dist/index.min.js"></script>
|
80 |
-
<script src="https://cdn.jsdelivr.net/npm/markmap-autoloader@latest"></script>
|
81 |
-
<script>
|
82 |
-
window.markmap = {{
|
83 |
-
autoLoader: {{
|
84 |
-
toolbar: true,
|
85 |
-
}},
|
86 |
-
}};
|
87 |
-
</script>
|
88 |
-
<script>
|
89 |
-
window.addEventListener('load', function() {{
|
90 |
-
setTimeout(function() {{
|
91 |
-
const element = document.querySelector('div.mm-toolbar-item[title="Fit window size"]');
|
92 |
-
if (element) {{
|
93 |
-
element.click();
|
94 |
-
}} else {{
|
95 |
-
console.log('Element not found');
|
96 |
-
}}
|
97 |
-
}}, 500);
|
98 |
-
}});
|
99 |
-
</script>
|
100 |
</div>
|
101 |
-
|
102 |
"""
|
103 |
return post, image
|
104 |
|
|
|
23 |
html_summary = mistune.html(summary)
|
24 |
post = f"""
|
25 |
<div id="paper_post">
|
|
|
26 |
<script src="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.18.4/dist/index.min.js"></script>
|
|
|
27 |
<script src="https://cdn.jsdelivr.net/npm/markmap-autoloader@latest"></script>
|
28 |
<script>
|
29 |
window.markmap = {{
|
|
|
34 |
</script>
|
35 |
<script>
|
36 |
window.addEventListener('load', function() {{
|
|
|
37 |
const element = document.querySelector('div.mm-toolbar-item[title="Fit window size"]');
|
38 |
if (element) {{
|
39 |
element.click();
|
40 |
}} else {{
|
41 |
console.log('Element not found');
|
42 |
}}
|
|
|
43 |
}});
|
44 |
</script>
|
45 |
<style>
|
|
|
52 |
height: 80dvh;
|
53 |
}}
|
54 |
</style>
|
55 |
+
<style>
|
56 |
+
.markmap {{
|
57 |
+
position: relative;
|
58 |
+
}}
|
59 |
+
.markmap > svg {{
|
60 |
+
width: 100%;
|
61 |
+
border: 2px solid #000;
|
62 |
+
height: 80dvh;
|
63 |
+
}}
|
64 |
+
</style>
|
65 |
<img style="display:block; width:100%; height:100%;" id="paper_image" src="{image}" alt="{title}">
|
66 |
<br>
|
67 |
<b>{{getToc}} $title={{Table of Contents}}</b>
|
|
|
74 |
<p><small><em>If MindMap doesn't load, please refresh the page.</em></small></p>
|
75 |
<div class="markmap" id="paper_mindmap">
|
76 |
<script type="text/template">
|
77 |
+
{mindmap.replace("&", "&").replace(":", "=>")}
|
78 |
</script>
|
79 |
</div>
|
80 |
<br>
|
|
|
82 |
<div id="paper_citation">
|
83 |
{mistune.html(citation.replace("&", "&"))}
|
84 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
</div>
|
|
|
86 |
"""
|
87 |
return post, image
|
88 |
|