diff --git a/golden-files/results/pdf2txt-standard_pdf b/golden-files/results/pdf2txt-standard_pdf index be97bed..cbc5f8c 100644 --- a/golden-files/results/pdf2txt-standard_pdf +++ b/golden-files/results/pdf2txt-standard_pdf @@ -1,3 +1,3 @@ Cover Page - \ No newline at end of file +# \ No newline at end of file diff --git a/golden-files/results/perl6_syntax-perl6_p6 b/golden-files/results/perl6_syntax-perl6_p6 index 032e5f9..a8583b5 100644 --- a/golden-files/results/perl6_syntax-perl6_p6 +++ b/golden-files/results/perl6_syntax-perl6_p6 @@ -1,7 +1,7 @@ -===SORRY!=== +#[31m===#[0mSORRY!#[31m===#[0m Two terms in a row across lines (missing semicolon or comma?) at /tmp/vigil/golden-files/./input/perl6.p6:30 -------> say 'Hello from Perl 6!'⏏ +------> #[32msay 'Hello from Perl 6!'#[33m⏏#[31m#[0m expecting any of: infix infix stopper @@ -12,5 +12,5 @@ at /tmp/vigil/golden-files/./input/perl6.p6:30 Other potential difficulties: Useless declaration of a has-scoped method in mainline (did you mean 'my regex http-verb'?) at /tmp/vigil/golden-files/./input/perl6.p6:11 - ------> regex ⏏http-verb { + ------> #[32mregex #[33m⏏#[31mhttp-verb {#[0m \ No newline at end of file diff --git a/golden-files/results/perl_syntax-perl6_pl b/golden-files/results/perl_syntax-perl6_pl index faa0933..0a1bb85 100644 --- a/golden-files/results/perl_syntax-perl6_pl +++ b/golden-files/results/perl_syntax-perl6_pl @@ -1,7 +1,7 @@ -===SORRY!=== +#[31m===#[0mSORRY!#[31m===#[0m Two terms in a row across lines (missing semicolon or comma?) at /tmp/vigil/golden-files/./input/perl6.pl:30 -------> say 'Hello from Perl 6!'⏏ +------> #[32msay 'Hello from Perl 6!'#[33m⏏#[31m#[0m expecting any of: infix infix stopper @@ -12,5 +12,5 @@ at /tmp/vigil/golden-files/./input/perl6.pl:30 Other potential difficulties: Useless declaration of a has-scoped method in mainline (did you mean 'my regex http-verb'?) at /tmp/vigil/golden-files/./input/perl6.pl:11 - ------> regex ⏏http-verb { + ------> #[32mregex #[33m⏏#[31mhttp-verb {#[0m \ No newline at end of file diff --git a/tools.py b/tools.py index 84cb6ea..0a482fc 100644 --- a/tools.py +++ b/tools.py @@ -18,6 +18,7 @@ import os.path import pickle import pwd import stat +import string import subprocess import tempfile import time @@ -84,9 +85,14 @@ _LS_COLOR_CODES = get_ls_color_codes() TIMEOUT = 60 +def _printable(text): + return "".join(char if ord(char) > 31 or char in ["\n", "\t"] else "#" + for char in text) + + def _fix_input(input_): input_str = input_.decode("utf-8") if isinstance(input_, bytes) else input_ - return input_str.expandtabs(tabsize=4) + return _printable(input_str).expandtabs(tabsize=4) def _do_command(command, timeout=None, **kwargs): @@ -248,7 +254,7 @@ def contents(path): root, ext = splitext(path) if ext == "": with open(path) as file_: - return Status.normal, fill3.Text(file_.read()) + return Status.normal, fill3.Text(_fix_input(file_.read())) else: return pygments_(path) contents.dependencies = {"python3-pygments"}