summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Peveler <matt.peveler@gmail.com>2020-06-26 20:06:47 +0300
committerGitHub <noreply@github.com>2020-06-26 20:06:47 +0300
commit334b4aed32f5e1b0952445b3b4e6b3e133063565 (patch)
tree08364947610f84150c8e701478b94461acfb39b9
parentd104c91373704d98f53d12a07ae8290e58cbac48 (diff)
downloadasciidoc-py3-334b4aed32f5e1b0952445b3b4e6b3e133063565.tar.gz
fix a2x failing on parsing encoding of html files (#125)
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
-rwxr-xr-xa2x.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/a2x.py b/a2x.py
index 4fabbbc..7709743 100755
--- a/a2x.py
+++ b/a2x.py
@@ -303,6 +303,8 @@ def find_resources(files, tagname, attrname, filter=None):
with open(filename, 'rb') as open_file:
contents = open_file.read()
mo = re.search(b'\A<\?xml.* encoding="(.*?)"', contents)
+ if mo is None:
+ mo = re.search(br'<meta http\-equiv="Content\-Type" content="text\/html; charset=(.*?)">', contents)
contents = contents.decode(mo.group(1).decode('utf-8') if mo else 'utf-8')
parser.feed(contents)
parser.close()