-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy paththemes.sh
executable file
·51 lines (40 loc) · 1.53 KB
/
themes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Directory containing the .css files
source_dir="./node_modules/highlight.js/styles"
# Directory where the modified .css files will be saved
target_dir="./resources/css/themes"
# Function to check if the line contains specified selectors
contains_selectors() {
local line=$1
[[ $line =~ ^[[:space:]]*pre[[:space:]]+code\.hljs ]] || [[ $line =~ ^[[:space:]]*code\.hljs ]]
}
# Find and process .css files, excluding .min.css
for file in "$source_dir"/*.css; do
if [[ ! $file =~ \.min\.css$ ]]; then
# Extract filename without the path and extension
filename=$(basename -- "$file" .css)
# Prepare the full path for the output file
output_file="$target_dir/$filename.css"
# Start the wrapper with correct indentation
echo ".syntax-entry-theme-$filename {" > "$output_file"
# Initialize flag to skip lines
skip_block=0
# Process each line
while IFS= read -r line || [ -n "$line" ]; do
if contains_selectors "$line"; then
skip_block=1
continue
fi
if [[ $skip_block -eq 1 ]]; then
if [[ $line =~ ^[[:space:]]*\} ]]; then
skip_block=0
fi
continue
fi
# Apply 4 space indentation to each line of original CSS
echo " $line"
done < "$file" >> "$output_file"
# Correctly close the wrapper with a brace
echo "}" >> "$output_file"
fi
done