-
Notifications
You must be signed in to change notification settings - Fork 0
/
MeltLEGACY.py
170 lines (170 loc) · 4.49 KB
/
MeltLEGACY.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
f = open("./flake.smd", "r")
endlines = []
lines = []
mode = ""
hrefed=""
classed=""
for x in f:
lines.append(x)
def header(l):
mode = "h1"
# print(lines[l])
# dsus = lines[l].strip("$#")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$#")
endlines.append(f"<h1>{store}</h1>")
def breakln():
endlines.append("<br/>")
def divStart(l):
mode = "divS"
# dsus = lines[l].strip("$%")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$%")
endlines.append(f"<div class=\"{store}\">")
def title(l):
mode = "divS"
# dsus = lines[l].strip("$t")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$t")
endlines.append(f"<title>{store}</title>")
def divEnd(l):
mode = "divS"
# dsus = lines[l].strip("$%")
# lines[l] = dsus
endlines.append("</div>")
def styles(l):
mode = "style"
# dsus = lines[l].strip("$=")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$=")
endlines.append(f"<link rel=\"stylesheet\" href=\"{store}\"/>")
def textfr(l):
mode = "text"
# dsus = lines[l].strip("$!")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$!")
endlines.append(f"{store}")
def atag(l,hrf):
mode = "a"
# dsus = lines[l].strip("$a")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$a")
endlines.append(f"<a href=\"{hrf}\">{store}</a>")
def span(l,hrf):
mode = "span"
# dsus = lines[l].strip("$-")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$-")
endlines.append(f"<span class=\"{hrf}\">{store}</span>")
def hehepp(l,hrf):
mode = "p"
# dsus = lines[l].strip("$p")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$p")
endlines.append(f"<p class=\"{hrf}\">{store}</p>")
def img(l,hrf):
mode = "img"
# dsus = lines[l].strip("$+")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$+")
endlines.append(f"<img class=\"{hrf}\" src=\"{store}\" alt=\"nobody\"/>")
def bgcolor(l):
mode = "+"
# dsus = lines[l].strip("$|")
# lines[l] = dsus
endlines.append("<style>body{background-color:"+(lines[l].rstrip("\n")).lstrip("$|")+";}</style>")
def insert(l):
mode = "i"
# dsus = lines[l].strip("$i")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$i")
endlines.append(f"<i class=\"{store}\"></i>")
def favico(l):
mode = "f"
# dsus = lines[l].strip("$i")
# lines[l] = dsus
store=(lines[l].rstrip("\n")).lstrip("$f")
endlines.append("<link rel=\"icon\" type=\"image/x-icon\" href=\""+store+"\"/>")
def generate():
dolla = 0
bolla = 0
i=0
subi=0
for line in lines:
for elem in line:
if elem == "*" and subi == 0:
print("comment")
if elem == "$" and subi==0:
dolla = 1
if elem == "#" and dolla == 1:
header(i)
dolla = 0
if elem == "b" and dolla == 1:
breakln()
dolla = 0
if elem == "%" and dolla == 1:
divStart(i)
dolla = 0
if elem == "^" and dolla == 1:
divEnd(i)
dolla == 0
if elem == "=" and dolla == 1:
styles(i)
dolla = 0
if elem == "t" and dolla == 1:
dolla= 0
title(i)
if elem == "." and dolla == 1:
dolla=0
dsus = lines[i].strip("$.")
lines[i] = dsus
hrefed = (lines[i].rstrip("\n")).lstrip("$.")
if elem == "a" and dolla ==1:
dolla = 0
atag(i,hrefed)
if elem == "-" and dolla ==1:
dolla = 0
span(i,classed)
if elem == "|" and dolla ==1:
dolla = 0
bgcolor(i)
if elem == "i" and dolla ==1:
dolla = 0
insert(i)
if elem == "p" and dolla ==1:
dolla = 0
hehepp(i,classed)
if elem == "l" and dolla == 1:
dolla=0
dsus = lines[i].strip("$l")
lines[i] = dsus
classed = (lines[i].rstrip("\n")).lstrip("$l")
if elem == "!" and dolla == 1:
textfr(i)
dolla = 0
if elem == "+" and dolla == 1:
dolla = 0
img(i,classed)
subi +=1
if elem == "f" and dolla == 1:
dolla = 0
favico(i)
i+=1
subi=0
z = 0
for lo in endlines:
if z==1:
endlines.append("<head>")
endlines.append("<meta charset=\"UTF-8\">")
endlines.append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">")
x = open("./flake.html", "a+")
x.write(lo+"\n")
z+=1
endlines.append("</head>")
else:
x = open("./flake.html", "a+")
x.write(lo+"\n")
z+=1
# print(lo)
print("CONVERSION COMPLETE .smd => .html")
generate()