Skip to content

Instantly share code, notes, and snippets.

@TheNeuralBit
Created January 15, 2014 01:47
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 TheNeuralBit/8429347 to your computer and use it in GitHub Desktop.
Save TheNeuralBit/8429347 to your computer and use it in GitHub Desktop.
Simple script for taking a file with a bunch of long lines and breaking it into 80 character lines - I use it to fix the output of http://fuckyeahmarkdown.com
import sys
infile = open(sys.argv[1], 'r')
outfile = open(sys.argv[2], 'w')
for line in infile.read().split('\n'):
while len(line) > 80:
idx = line[:80].rfind(' ')
outfile.write('%s\n' % line[:idx])
line = line[idx + 1:]
outfile.write('%s\n' % line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment