Skip to content

Commit c2d3b8d

Browse files
committed
Add beautify_html.py script. Uses beautifulsoup4 to prettify a html
document. Usage: ./beatify_html.py <input_file> <output_file>
1 parent 264fbe5 commit c2d3b8d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

util_scripts/beautify_html.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/python
2+
3+
import sys
4+
from bs4 import BeautifulSoup
5+
6+
def transform( input_file, output_file ):
7+
8+
with open( input_file, "r" ) as f:
9+
c = f.read()
10+
soup = BeautifulSoup(c)
11+
with open( output_file, 'w' ) as o:
12+
o.write( soup.prettify() )
13+
14+
def main():
15+
if len(sys.argv) <= 2:
16+
print( "% input_file output_file"%(sys.argv[0]))
17+
return
18+
transform( sys.argv[ 1 ], sys.argv[ 2 ] )
19+
20+
if __name__ == "__main__":
21+
main()
22+
sys.exit()
23+

0 commit comments

Comments
 (0)