diff options
author | Jason A. Donenfeld | 2016-01-18 11:14:06 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2016-01-18 11:14:06 +0100 |
commit | d3756bd7b00f9ad6adede3c7f956a25b22a2254a (patch) | |
tree | 4bbad846fa91d3d6fa6becd197eb405ce6574bde | |
parent | 33bc949a1e927e14479568518bd92e70998e25f8 (diff) | |
download | cgit-d3756bd7b00f9ad6adede3c7f956a25b22a2254a.tar.gz cgit-d3756bd7b00f9ad6adede3c7f956a25b22a2254a.tar.bz2 cgit-d3756bd7b00f9ad6adede3c7f956a25b22a2254a.zip |
syntax-highlighting: always use utf-8 to avoid ascii codec issues
-rwxr-xr-x | filters/syntax-highlighting.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/filters/syntax-highlighting.py b/filters/syntax-highlighting.py index b5d615e..1ca4108 100755 --- a/filters/syntax-highlighting.py +++ b/filters/syntax-highlighting.py | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | 22 | ||
23 | import sys | 23 | import sys |
24 | import io | ||
24 | from pygments import highlight | 25 | from pygments import highlight |
25 | from pygments.util import ClassNotFound | 26 | from pygments.util import ClassNotFound |
26 | from pygments.lexers import TextLexer | 27 | from pygments.lexers import TextLexer |
@@ -29,6 +30,8 @@ from pygments.lexers import guess_lexer_for_filename | |||
29 | from pygments.formatters import HtmlFormatter | 30 | from pygments.formatters import HtmlFormatter |
30 | 31 | ||
31 | 32 | ||
33 | sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') | ||
34 | sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') | ||
32 | data = sys.stdin.read() | 35 | data = sys.stdin.read() |
33 | filename = sys.argv[1] | 36 | filename = sys.argv[1] |
34 | formatter = HtmlFormatter(style='pastie') | 37 | formatter = HtmlFormatter(style='pastie') |