1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-07-03 13:43:19 +01:00

Use [].copy and path.exists instead of more cumbersome solutions

 Slightly optimized create_highlighted_versions.py so that it won't walk the source path when it should be skipping the file

 Updated README.md in plaintext source folder

 Added extra option loading from `bat_options` file in directory and significantly reduced size of plaintext source

 Updated create_highlighted_versions.py to ignore README.md files and use the --show-all option for manually-defined binary files

 Updated plaintext file with command

bat -A --no-config --style=plain --color=always --theme='1337' --italic-text=always src/Plaintext/plaintext.txt > highlighted/Plaintext/plaintext.txt

 Added example plaintext file
This commit is contained in:
Logan Saso
2020-10-04 15:29:20 -07:00
committed by David Peter
parent 24fe946c06
commit f3c760c25f
5 changed files with 213 additions and 6 deletions
tests/syntax-tests

@ -16,6 +16,17 @@ BAT_OPTIONS = [
"--italic-text=always",
]
SKIP_FILENAMES = [
"LICENSE.md",
"README.md",
"bat_options",
]
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 create_highlighted_versions(output_basepath):
root = os.path.dirname(os.path.abspath(__file__))
@ -31,16 +42,23 @@ def create_highlighted_versions(output_basepath):
env.pop("BAT_TABS", None)
env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
bat_output = subprocess.check_output(
["bat"] + BAT_OPTIONS + [source], stderr=subprocess.PIPE, env=env,
)
source_dirname = path.basename(path.dirname(source))
source_dirpath = path.dirname(source)
source_dirname = path.basename(source_dirpath)
source_filename = path.basename(source)
if source_filename == "LICENSE.md":
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],
stderr=subprocess.PIPE, env=env,
)
output_dir = path.join(output_basepath, source_dirname)
output_path = path.join(output_dir, source_filename)