diff --git a/tests/syntax-tests/create_highlighted_versions.py b/tests/syntax-tests/create_highlighted_versions.py index b82cc8cd..75278197 100755 --- a/tests/syntax-tests/create_highlighted_versions.py +++ b/tests/syntax-tests/create_highlighted_versions.py @@ -23,9 +23,14 @@ SKIP_FILENAMES = [ ] -def get_extra_options(source): - with open(path.join(source, "bat_options"), "r") as f: - return list(map(lambda x: x.rstrip(), f.readlines())) +def get_options(source): + source_dirpath = path.dirname(source) + options = BAT_OPTIONS.copy() + if path.exists(path.join(source_dirpath, "bat_options")): + with open(path.join(source, "bat_options"), "r") as f: + options += list(map(lambda x: x.rstrip(), f.readlines())) + return options + def create_highlighted_versions(output_basepath): @@ -42,20 +47,14 @@ def create_highlighted_versions(output_basepath): env.pop("BAT_TABS", None) env["COLORTERM"] = "truecolor" # make sure to output 24bit colors - source_dirpath = path.dirname(source) - source_dirname = path.basename(source_dirpath) + source_dirname = path.basename(path.dirname(source)) source_filename = path.basename(source) if source_filename in SKIP_FILENAMES: continue - options = BAT_OPTIONS.copy() - # If a directory is empty, `files` could possibly be 0-length - if path.exists(path.join(source_dirpath, "bat_options")): - options += get_extra_options(source_dirpath) - bat_output = subprocess.check_output( - ["bat"] + options + [source], + ["bat"] + get_options(source) + [source], stderr=subprocess.PIPE, env=env, ) diff --git a/tests/syntax-tests/source/Plaintext/README.md b/tests/syntax-tests/source/Plaintext/README.md index 95679324..59c0065e 100644 --- a/tests/syntax-tests/source/Plaintext/README.md +++ b/tests/syntax-tests/source/Plaintext/README.md @@ -1,10 +1,12 @@ -This text file was generated with the following script. Certain invalid characters were removed manually: +This text file was generated with the following script. ```python with open("plaintext.txt", "w"): - for i in range(0x10FFFF): + for i in range(176): try: f.write(chr(i) + "\n") except: pass + f.write("\n") + f.write("Here is a line with multiple characters") ```