Permalink
Browse files

why do we compile in release mode anyway?

  • Loading branch information...
1 parent ff3260e commit a9556bbef8245bd1ce849e1bffd175412934ef9d @Xion committed Aug 22, 2016
Showing with 13 additions and 1 deletion.
  1. +13 −1 minify.py
View
@@ -4,6 +4,7 @@
"""
from __future__ import print_function
+import re
import sys
import bs4
@@ -26,7 +27,18 @@ def main(argv):
html = bs4.BeautifulSoup(response.text, 'html.parser')
textarea = [ta for ta in html.find_all('textarea')
if ta.get('name') != 'user_source'][0]
- print(textarea.text)
+ minified = textarea.text
+
+ # fix minifier bugs:
+ # * semicolon before function declaration requires additional whitespace
+ # * ampersand (for background jobs) gets an erroneous semicolon
+ # at the end of a function
+ minified = re .sub(
+ r';(\w+)\(\)', lambda m: '; %s()' % m.group(1), minified)
+ minified = minified.replace('&;}', '&}')
+
+ print("#!/bin/bash")
+ print(minified)
if __name__ == '__main__':

0 comments on commit a9556bb

Please sign in to comment.