File: fixhtml.py

package info (click to toggle)
kid3 3.9.6-3
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,212 kB
  • sloc: cpp: 67,855; sh: 1,966; python: 1,648; ansic: 762; xml: 558; java: 164; makefile: 37
file content (30 lines) | stat: -rwxr-xr-x 1,182 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python3

import fileinput
import sys
import os


def fix_html():
    for line in fileinput.input(mode='rb'):
        if line.lower() == b'><title\n':
            line = b'><meta http-equiv="content-type" content="text/html; charset=UTF-8"\n><title\n'
        line = line.replace(b'</TITLE', b'</title').replace(b'</title',
b"""</title>
<style type="text/css">
body { font-family: Arial, Helvetica, sans-serif; color: #000000; background: #ffffff; }
h1, h2, h3, h4 { text-align: left; font-weight: bold; color: #f7800a; background: transparent; }
a:link { color: #0057ae; }
pre { display: block; color: #000000; background: #f9f9f9; border: #2f6fab dashed; border-width: 1px; overflow: auto; line-height: 1.1em; }
dt { font-weight: bold; color: #0057ae; }
p { text-align: justify; }
li { text-align: left; }
.guibutton, .guilabel, .guimenu, .guimenuitem { font-family: Arial, Helvetica, sans-serif; color: #000000; background: #dcdcdc; }
.application { font-weight: bold; }
.command { font-family: "Courier New", Courier, monospace; }
.filename { font-style: italic; }
</style""")
        os.write(sys.stdout.fileno(), line)

if __name__ == '__main__':
    fix_html()