27 lines
603 B
Python
27 lines
603 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import re
|
||
|
import sys
|
||
|
|
||
|
SCRIPTS = r'((<script src="js/\w+\.js"></script>[\s\r\n]+)+)'
|
||
|
MINJS = '<script src="{}"></script>'
|
||
|
|
||
|
LESSJS = '<script src="https://cdn.jsdelivr.net/npm/less"></script>'
|
||
|
STYLES = '<link rel="stylesheet/less" type="text/css" href="styles.less" />'
|
||
|
CSS = '<link rel="stylesheet" href="{}" />'
|
||
|
|
||
|
|
||
|
def main():
|
||
|
|
||
|
stdin = sys.stdin.read()
|
||
|
|
||
|
conv = re.sub(SCRIPTS, MINJS.format(sys.argv[1]), stdin)
|
||
|
conv = conv.replace(LESSJS, '')
|
||
|
conv = conv.replace(STYLES, CSS.format(sys.argv[2]))
|
||
|
|
||
|
sys.stdout.write(conv)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|