import re,html,sys
s=open(sys.argv[1],encoding='utf-8',errors='replace').read()
t=re.sub(r'<(script|style|nav|footer)[^>]*>.*?\1>','',s,flags=re.S)
t=re.sub(r']*>',r'\n\n#\1# ',t); t=re.sub(r'<(br|/p|/li|/tr|/pre|/div|/h\d)[^>]*>','\n',t)
t=re.sub(r'',' | ',t)
t=re.sub(r'
]*src="([^"]+)"[^>]*>',r'[IMG \1]',t)
t=html.unescape(re.sub(r'<[^>]+>','',t))
t=re.sub(r'[ \t]+\n','\n',t); t=re.sub(r'\n{3,}','\n\n',t)
sys.stdout.write(t)