forked from xavierleroy/coq2html
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcoq2html.js
49 lines (44 loc) · 1.22 KB
/
coq2html.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function renderMarkdowns()
{
const md = markdownit({html:true})
.use(texmath, { engine: katex,
delimiters: 'dollars'} );
const elements = document.querySelectorAll('.markdown,.md');
for (let elem of elements) {
elem.innerHTML = md.render(elem.textContent);
}
}
function showDarkmodeWidget()
{
new Darkmode({
time: '0.1s',
label: '🌓',
}).showWidget();
}
function setUpSavingDetails() {
$('details').on('toggle', function(event) {
var id = $(this).attr('id')
var isOpen = $(this).attr('open')
window.localStorage.setItem('details-'+id, isOpen)
})
function setDetailOpenStatus(item) {
if (item.includes('details-')) {
var id = item.split('details-')[1];
var status = window.localStorage.getItem(item)
if (status == 'open' || status == 'undefined'){
$("#"+CSS.escape(id)).attr('open',true)
}
}
}
$( document ).ready(function() {
for (var i = 0; i < localStorage.length; i++) {
setDetailOpenStatus(localStorage.key(i));
}
});
}
function init()
{
renderMarkdowns();
showDarkmodeWidget();
setUpSavingDetails();
}