-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLink_Format.py
More file actions
46 lines (46 loc) · 1.65 KB
/
Link_Format.py
File metadata and controls
46 lines (46 loc) · 1.65 KB
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
with open("mark1.txt", "r", encoding="utf-8") as f:
lines = f.readlines()
lines_list = []
for i in lines:
temp = i.replace("\n", "").strip()
lines_list.insert(0, temp)
sorted_line_list = sorted(set(lines_list))
with open("mark1.txt", "w", encoding="utf-8") as r:
for a in sorted_line_list:
print(str(a).encode("utf-8").decode("utf-8"), file=r)
r = open("Links_formatted.html", "w", encoding="utf-8")
print(str('''<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Read Laters</title>
</head>
<style>
body {
margin: 10px 10%;
}
a {
text-decoration: none;
display: block;
margin: 2%;
font-size: 20px;
padding: 20px;
background-color: black;
color: white;
border-radius: 20px;
word-wrap: break-word;
text-transform: capitalize;
}
a:hover {
background-color: rgb(218, 218, 218);
color: black;
}
</style>
<body>'''), file=r)
x = 1
for j in sorted_line_list:
print(
f'<a href="{j}" target="_blank"><p>{x}. {j}</p></a>'.encode("utf-8").decode("utf-8"), file=r)
x = x+1
print(str('''</body></html>'''), file=r)