-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathxword2html.py
executable file
·54 lines (41 loc) · 1.29 KB
/
xword2html.py
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
50
51
52
53
54
#!/usr/bin/env python3
# DEPRECATED: we now use xword2jsonhtml.py
from tabulate import tabulate
import json, re
from sys import argv
''' Hallo I generate an html with buttons for letters to std
input xwordspine.json
this = argv[1]'''
try:
with open(argv[1]) as ok: this = json.loads(ok.read())
except:
this = json.loads(argv[1])
#with open('xwordspine.json') as ok: this = json.loads(ok.read())
#for each in enumerate(this):
# for every in enumerate(each[1]):
# if every[1] != ' ':
# this[each[0]][every[0]] = "<button type='button'>"+every[1]+"</button>"
header = '''
<!DOCTYPE html>
<html>
<body>
<script>
function siblingCount(node) {
return [...node.parentElement.childNodes].indexOf(node);
}
function klik(btn) {
const x = siblingCount(btn.parentElement.parentElement);
const y = siblingCount(btn.parentElement);
document.location = `/cluez/lukifer/usufruct?action=click&x=${x}&y=${y}`;
}
</script>
'''
footer = '</html>\n</body>'
#with open('xword.html','w') as writor:
# writor.write(header)
# writor.write(tabulate(this, tablefmt='html'))
# writor.write(footer)
print(header)
#print(tabulate(this, tablefmt='html'))
print(re.sub('>([\S\s])<', r'><button onclick=crystalization(spine,wordbones)>\1</button><',tabulate(this, tablefmt='html')))
print(footer)