Updated creation script and README to match generation script

This commit is contained in:
Logan Saso 2020-10-10 12:24:21 -07:00 committed by David Peter
parent f3c760c25f
commit 6c68198d19
2 changed files with 14 additions and 13 deletions

View File

@ -23,9 +23,14 @@ SKIP_FILENAMES = [
] ]
def get_extra_options(source): def get_options(source):
with open(path.join(source, "bat_options"), "r") as f: source_dirpath = path.dirname(source)
return list(map(lambda x: x.rstrip(), f.readlines())) 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): def create_highlighted_versions(output_basepath):
@ -42,20 +47,14 @@ def create_highlighted_versions(output_basepath):
env.pop("BAT_TABS", None) env.pop("BAT_TABS", None)
env["COLORTERM"] = "truecolor" # make sure to output 24bit colors env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
source_dirpath = path.dirname(source) source_dirname = path.basename(path.dirname(source))
source_dirname = path.basename(source_dirpath)
source_filename = path.basename(source) source_filename = path.basename(source)
if source_filename in SKIP_FILENAMES: if source_filename in SKIP_FILENAMES:
continue 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_output = subprocess.check_output(
["bat"] + options + [source], ["bat"] + get_options(source) + [source],
stderr=subprocess.PIPE, env=env, stderr=subprocess.PIPE, env=env,
) )

View File

@ -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 ```python
with open("plaintext.txt", "w"): with open("plaintext.txt", "w"):
for i in range(0x10FFFF): for i in range(176):
try: try:
f.write(chr(i) + "\n") f.write(chr(i) + "\n")
except: except:
pass pass
f.write("\n")
f.write("Here is a line with multiple characters")
``` ```