import os
import re
import datetime

# This script generates the bip39-standalone.html file.

# It removes script and style tags and replaces with the file content.

f = open('src/index.html')
page = f.read()
f.close()


# Script tags

scriptsFinder = re.compile("""<script src="(.*)"></script>""")
scripts = scriptsFinder.findall(page)

for script in scripts:
    filename = os.path.join("src", script)
    s = open(filename)
    scriptContent = "<script>%s</script>" % s.read()
    s.close()
    scriptTag = """<script src="%s"></script>""" % script
    page = page.replace(scriptTag, scriptContent)


# Style tags

stylesFinder = re.compile("""<link rel="stylesheet" href="(.*)">""")
styles = stylesFinder.findall(page)

for style in styles:
    filename = os.path.join("src", style)
    s = open(filename)
    styleContent = "<style>%s</style>" % s.read()
    s.close()
    styleTag = """<link rel="stylesheet" href="%s">""" % style
    page = page.replace(styleTag, styleContent)


# Write the standalone file

f = open('bip39-standalone.html', 'w')
f.write(page)
f.close()

print("%s - DONE" % datetime.datetime.now())

@@ -184,18 +184,41 @@
 ex.html'
+, %22r%22, encoding=%22utf-8%22
 )%0A
-
 page = f
@@ -437,24 +437,47 @@
 pen(filename
+, %22r%22, encoding=%22utf-8%22
 )%0A    script
@@ -847,16 +847,39 @@
 filename
+, %22r%22, encoding=%22utf-8%22
 )%0A    st
@@ -1078,16 +1078,16 @@
 e file%0A%0A
-
 f = open
@@ -1115,16 +1115,34 @@
 ml', 'w'
+, encoding=%22utf-8%22
 )%0Af.writ

Fix compile errors on some systems