forked from jaysan0/obsidian-sandstorm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcss2yaml.py
executable file
·58 lines (52 loc) · 2.26 KB
/
css2yaml.py
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
52
53
54
55
56
57
58
#!/usr/bin/env python3
import re
import argparse
# Function to extract colors from CSS
def extract_colors(css_file):
colors = {}
with open(css_file, 'r') as file:
content = file.read()
# Use regular expressions to find color definitions
matches = re.findall(r'([a-zA-Z-]+):\s*#([0-9a-fA-F]{6})', content)
for match in matches:
colors[match[0]] = match[1]
return colors
# Function to create Warp YAML theme file
def create_warp_theme(colors, output_file):
with open(output_file, 'w') as file:
# Write the color scheme in Warp YAML format
file.write('name: Custom Theme\n')
file.write(f'accent: #{colors["accent"]}\n')
file.write(f'cursor: #{colors["cursor"]}\n')
file.write(f'background: #{colors["background"]}\n')
file.write(f'foreground: #{colors["foreground"]}\n')
file.write('details: darker\n')
file.write('terminal_colors:\n')
file.write(' bright:\n')
file.write(f' black: #{colors["black"]}\n')
file.write(f' blue: #{colors["blue"]}\n')
file.write(f' cyan: #{colors["cyan"]}\n')
file.write(f' green: #{colors["green"]}\n')
file.write(f' magenta: #{colors["magenta"]}\n')
file.write(f' red: #{colors["red"]}\n')
file.write(f' white: #{colors["white"]}\n')
file.write(f' yellow: #{colors["yellow"]}\n')
file.write(' normal:\n')
file.write(f' black: #{colors["black"]}\n')
file.write(f' blue: #{colors["blue"]}\n')
file.write(f' cyan: #{colors["cyan"]}\n')
file.write(f' green: #{colors["green"]}\n')
file.write(f' magenta: #{colors["magenta"]}\n')
file.write(f' red: #{colors["red"]}\n')
file.write(f' white: #{colors["white"]}\n')
file.write(f' yellow: #{colors["yellow"]}\n')
# Main function
def main():
parser = argparse.ArgumentParser(description='Convert CSS to Warp YAML theme')
parser.add_argument('css_file', help='Path to the CSS file')
parser.add_argument('output_file', help='Path to the output YAML file')
args = parser.parse_args()
colors = extract_colors(args.css_file)
create_warp_theme(colors, args.output_file)
if __name__ == '__main__':
main()