he/they
Codeblock rendering (script de python)
Odio python esto debería ser un programita en C pero bueno...
1import sys
2
3if len(sys.argv) < 2:
4 print("File not provided", file=sys.stderr)
5 sys.exit(1)
6
7try:
8 in_file = open(sys.argv[1])
9except FileNotFoundError:
10 print(f"File '{sys.argv[1]}' not found", file=sys.stderr)
11 sys.exit(1)
12
13linen = 0
14print("<div class=\"code-block\">")
15for line in in_file:
16 linen += 1
17 line = line.replace('<', "<")
18 line = line.replace('>', ">")
19 print(f"\t<div class=\"code-line\"><span class=\"line-number\">{linen}</span>", end="")
20 print(line.strip('\n'), end="")
21 print("</div>")
22
23print("</div>")
more at tw/dauthubleis and m/dauthubleis