Skip to content

Instantly share code, notes, and snippets.

@spookylukey
Created June 22, 2017 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spookylukey/614d7aa26a4603ac0494e93be2f4db9e to your computer and use it in GitHub Desktop.
Save spookylukey/614d7aa26a4603ac0494e93be2f4db9e to your computer and use it in GitHub Desktop.
Make source code readable on forums that have poor support
#!/usr/bin/env python3
import sys
def fix_line(l):
if not l:
return l
if l[0] == " ":
# Non breaking: "\u00a0" - but munged by some browsers
# EM space: "\u2003" - not munged by browsers
# EN space: "\u2002" - not munged by browsers, approx normal char width
return "\u2002" + fix_line(l[1:])
else:
return l
if __name__ == '__main__':
for l in sys.stdin.readlines():
sys.stdout.write(fix_line(l))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment