16 "--italic-text=always",
20def create_highlighted_versions(output_basepath):
21 root = os.path.dirname(os.path.abspath(__file__))
23 for source in glob.glob(path.join(root, "source", "*", "*")):
25 env = os.environ.copy()
26 env.pop("PAGER", None)
27 env.pop("BAT_PAGER", None)
28 env.pop("BAT_CONFIG_PATH", None)
29 env.pop("BAT_STYLE", None)
30 env.pop("BAT_THEME", None)
31 env.pop("BAT_TABS", None)
32 env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
34 bat_output = subprocess.check_output(
35 ["bat"] + BAT_OPTIONS + [source], stderr=subprocess.PIPE, env=env,
38 source_dirname = path.basename(path.dirname(source))
39 source_filename = path.basename(source)
41 if source_filename == "LICENSE.md":
44 output_dir = path.join(output_basepath, source_dirname)
45 output_path = path.join(output_dir, source_filename)
47 os.makedirs(output_dir, exist_ok=True)
49 with open(output_path, "wb") as output_file:
50 output_file.write(bat_output)
52 print("Created '{}'".format(output_path))
53 except subprocess.CalledProcessError as err:
55 "=== Error: Could not highlight source file '{}".format(source),
59 "=== bat stdout:\n{}".format(err.stdout.decode("utf-8")),
63 "=== bat stderr:\n{}".format(err.stderr.decode("utf-8")),
67 except FileNotFoundError:
68 print("Error: Could not execute 'bat'. Please make sure that the executable is available on the PATH.")
72if __name__ == "__main__":
73 parser = argparse.ArgumentParser(
74 description="This script creates syntax-highlighted versions of all "
75 "files in the 'source' directory."
81 help="Output directory",
86 args = parser.parse_args()
88 create_highlighted_versions(output_basepath=args.output)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list