17 lines
463 B
Python
17 lines
463 B
Python
|
|
import re
|
|
|
|
with open("/home/mark/prosberry/js/main.js", "r") as f:
|
|
js_content = f.read()
|
|
|
|
# Remove single-line comments
|
|
js_content = re.sub(r"//.*", "", js_content)
|
|
# Remove multi-line comments
|
|
js_content = re.sub(r"/\*.*?\*/", "", js_content, flags=re.DOTALL)
|
|
# Remove newlines and extra whitespace
|
|
js_content = re.sub(r"\s+", " ", js_content)
|
|
js_content = js_content.strip()
|
|
|
|
with open("/home/mark/prosberry/js/main.js", "w") as f:
|
|
f.write(js_content)
|