mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-31 10:11:07 +00: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:
parent
24fe946c06
commit
f3c760c25f
@ -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)
|
||||
|
||||
|
178
tests/syntax-tests/highlighted/Plaintext/plaintext.txt
Normal file
178
tests/syntax-tests/highlighted/Plaintext/plaintext.txt
Normal file
@ -0,0 +1,178 @@
|
||||
[38;2;166;226;46m␀[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{1}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{2}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{3}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{4}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{5}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{6}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;166;226;46m␇[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;166;226;46m␈[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;190;132;255m├──┤[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;249;38;114m␊[0m
|
||||
[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{b}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{c}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{e}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{f}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{10}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{11}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{12}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{13}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{14}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{15}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{16}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{17}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{18}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{19}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{1a}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;166;226;46m␛[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{1c}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{1d}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{1e}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{1f}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;102;217;239m·[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m![0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m"[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m#[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m$[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m%[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m&[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m'[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m([0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m)[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m*[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m+[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m,[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m-[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m.[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m/[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m0[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m1[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m2[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m3[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m4[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m5[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m6[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m7[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m8[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m9[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m:[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m;[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m<[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m=[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m>[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m?[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m@[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mA[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mB[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mC[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mD[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mE[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mF[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mG[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mH[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mI[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mJ[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mK[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mL[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mM[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mN[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mO[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mP[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mQ[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mR[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mS[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mT[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mU[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mV[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mW[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mX[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mY[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mZ[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m[[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m\[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m][0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m^[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m_[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m`[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242ma[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mb[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mc[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242md[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242me[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mf[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mg[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mh[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mi[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mj[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mk[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242ml[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mm[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mn[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mo[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mp[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mq[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mr[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242ms[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mt[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mu[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mv[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mw[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mx[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242my[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mz[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m{[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m|[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242m~[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{7f}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{80}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{81}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{82}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{83}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{84}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{85}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{86}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{87}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{88}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{89}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{8a}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{8b}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{8c}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{8d}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{8e}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{8f}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{90}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{91}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{92}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{93}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{94}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{95}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{96}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{97}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{98}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{99}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{9a}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{9b}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{9c}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{9d}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{9e}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{9f}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a0}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a1}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a2}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a3}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a4}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a5}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a6}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a7}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a8}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{a9}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{aa}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{ab}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{ac}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{ad}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;117;113;94m\u{ae}[0m[38;2;249;38;114m␊[0m
|
||||
[38;2;249;38;114m␊[0m
|
||||
[38;2;248;248;242mHere's[0m[38;2;102;217;239m·[0m[38;2;248;248;242ma[0m[38;2;102;217;239m·[0m[38;2;248;248;242mline[0m[38;2;102;217;239m·[0m[38;2;248;248;242mwith[0m[38;2;102;217;239m·[0m[38;2;248;248;242mmultiple[0m[38;2;102;217;239m·[0m[38;2;248;248;242mcharacters.[0m
|
10
tests/syntax-tests/source/Plaintext/README.md
Normal file
10
tests/syntax-tests/source/Plaintext/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
This text file was generated with the following script. Certain invalid characters were removed manually:
|
||||
|
||||
```python
|
||||
with open("plaintext.txt", "w"):
|
||||
for i in range(0x10FFFF):
|
||||
try:
|
||||
f.write(chr(i) + "\n")
|
||||
except:
|
||||
pass
|
||||
```
|
1
tests/syntax-tests/source/Plaintext/bat_options
Normal file
1
tests/syntax-tests/source/Plaintext/bat_options
Normal file
@ -0,0 +1 @@
|
||||
--show-all
|
BIN
tests/syntax-tests/source/Plaintext/plaintext.txt
Normal file
BIN
tests/syntax-tests/source/Plaintext/plaintext.txt
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user