]> gitweb.ps.run Git - ps-cgit/blobdiff - filters/syntax-highlighting.py
filters: migrate from luacrypto to luaossl
[ps-cgit] / filters / syntax-highlighting.py
index b5d615e6231c111b18ede6b3c006840aaae45648..e912594c48a71fce1baffb11149ab9b72cc223d4 100755 (executable)
@@ -21,6 +21,7 @@
 
 
 import sys
+import io
 from pygments import highlight
 from pygments.util import ClassNotFound
 from pygments.lexers import TextLexer
@@ -29,9 +30,11 @@ from pygments.lexers import guess_lexer_for_filename
 from pygments.formatters import HtmlFormatter
 
 
+sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='replace')
+sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
 data = sys.stdin.read()
 filename = sys.argv[1]
-formatter = HtmlFormatter(style='pastie')
+formatter = HtmlFormatter(style='pastie', nobackground=True)
 
 try:
        lexer = guess_lexer_for_filename(filename, data)