on master help sign in
Updated creation script and README to match generation script
6c68198Logan Saso
tests/syntax-tests/create_highlighted_versions.py+10−11
@@ -23,9 +23,14 @@ SKIP_FILENAMES = [
23]
23]
24
24
25
25
26−def get_extra_options(source):
26+def get_options(source):
27+ source_dirpath = path.dirname(source)
28+ options = BAT_OPTIONS.copy()
29+ if path.exists(path.join(source_dirpath, "bat_options")):
27− with open(path.join(source, "bat_options"), "r") as f:
30+ with open(path.join(source, "bat_options"), "r") as f:
28− return list(map(lambda x: x.rstrip(), f.readlines()))
31+ options += list(map(lambda x: x.rstrip(), f.readlines()))
32+ return options
33+
29
34
30
35
31def create_highlighted_versions(output_basepath):
36def create_highlighted_versions(output_basepath):
@@ -42,20 +47,14 @@ def create_highlighted_versions(output_basepath):
42 env.pop("BAT_TABS", None)
47 env.pop("BAT_TABS", None)
43 env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
48 env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
44
49
45− source_dirpath = path.dirname(source)
46− source_dirname = path.basename(source_dirpath)
50+ source_dirname = path.basename(path.dirname(source))
47 source_filename = path.basename(source)
51 source_filename = path.basename(source)
48
52
49 if source_filename in SKIP_FILENAMES:
53 if source_filename in SKIP_FILENAMES:
50 continue
54 continue
51
55
52− options = BAT_OPTIONS.copy()
53− # If a directory is empty, `files` could possibly be 0-length
54− if path.exists(path.join(source_dirpath, "bat_options")):
55− options += get_extra_options(source_dirpath)
56−
57 bat_output = subprocess.check_output(
56 bat_output = subprocess.check_output(
58− ["bat"] + options + [source],
57+ ["bat"] + get_options(source) + [source],
59 stderr=subprocess.PIPE, env=env,
58 stderr=subprocess.PIPE, env=env,
60 )
59 )
61
60
tests/syntax-tests/source/Plaintext/README.md+4−2
@@ -1,10 +1,12 @@
1−This text file was generated with the following script. Certain invalid characters were removed manually:
1+This text file was generated with the following script.
2
2
3```python
3```python
4with open("plaintext.txt", "w"):
4with open("plaintext.txt", "w"):
5− for i in range(0x10FFFF):
5+ for i in range(176):
6 try:
6 try:
7 f.write(chr(i) + "\n")
7 f.write(chr(i) + "\n")
8 except:
8 except:
9 pass
9 pass
10+ f.write("\n")
11+ f.write("Here is a line with multiple characters")
10```
12```