mirror of
https://github.com/sharkdp/bat.git
synced 2025-07-03 13:43:19 +01:00
#1244 Use [].copy and path.exists instead of more cumbersome solutions
#1244 Slightly optimized create_highlighted_versions.py so that it won't walk the source path when it should be skipping the file #1244 Updated README.md in plaintext source folder #1244 Added extra option loading from `bat_options` file in directory and significantly reduced size of plaintext source #1244 Updated create_highlighted_versions.py to ignore README.md files and use the --show-all option for manually-defined binary files #1244 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 #1244 Added example plaintext file
This commit is contained in:
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)
|
||||
|
||||
|
Reference in New Issue
Block a user