Skip to content

Commit

Permalink
Fix compile process for python3 on Windows
Browse files Browse the repository at this point in the history
As it stands python3 will fail to read in the input xhtml files
because they contain bytes that are not valid using the default
codepage on Windows (in English at least). Loading those files
as utf-8 explicitly resolves this issue and is correct as long
as all the xhtml files are utf-8 encoded.
  • Loading branch information
jacquesh committed Jul 29, 2022
1 parent 836ec3c commit 2ebd0cf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import argparse
import re
import zipfile
import codecs

import opengl
import glsl
Expand Down Expand Up @@ -824,9 +825,8 @@ def spew_category(name, commands, current_command, api):
if command_file == False:
raise IOError("Couldn't find page for command " + command + " (" + version + ")")

fp = open(command_file)
command_html = fp.read()
fp.close()
with codecs.open(command_file, mode="r", encoding="utf-8") as fp:
command_html = fp.read()

if args.buildmode == 'full':
command_html = command_html
Expand Down Expand Up @@ -942,12 +942,12 @@ def replace_alias(matchobj):

output_html = header_for_command + command_html + footer_for_command

output = open(output_dir + version_dir + "/" + command, "w")
output_string = output_html
if args.buildmode == 'full':
output_string = htmlmin.minify(output_html, remove_comments=True, reduce_boolean_attributes=True, remove_optional_attribute_quotes=False).encode('ascii', 'xmlcharrefreplace').decode('ascii')
output.write(output_string)
output.close()
output_path = output_dir + version_dir + "/" + command
with codecs.open(output_path, mode="w", encoding="utf-8") as output:
output_string = output_html
if args.buildmode == 'full':
output_string = htmlmin.minify(output_html, remove_comments=True, reduce_boolean_attributes=True, remove_optional_attribute_quotes=False).encode('ascii', 'xmlcharrefreplace').decode('ascii')
output.write(output_string)

written += 1

Expand Down

0 comments on commit 2ebd0cf

Please sign in to comment.