Skip to content

Instantly share code, notes, and snippets.

@akshaykarnawat
Last active February 2, 2019 16:10
Show Gist options
  • Save akshaykarnawat/cccf27be2f5310a1c7420363f7b61ec4 to your computer and use it in GitHub Desktop.
Save akshaykarnawat/cccf27be2f5310a1c7420363f7b61ec4 to your computer and use it in GitHub Desktop.
Comment block generator (beta)
def commentGenerator(comment, length=80):
commentList = comment.split(' ')
breakBy = int(len(commentList) / ((len(comment)+len(commentList)) / length))
body = ''.join(['# {0} \n'.format(' '.join(commentList[i: i+breakBy])) for i in range(0, len(commentList), breakBy)])
box = '#+{0}+\n'.format(''.join(['=' for i in range(length-3)]))
return box + body + box
/dev/python > python comment_generator.py "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." 80
#+=============================================================================+
# Lorem Ipsum is simply dummy text of the printing and
# typesetting industry. Lorem Ipsum has been the industry's standard dummy
# text ever since the 1500s, when an unknown printer took
# a galley of type and scrambled it to make a
# type specimen book. It has survived not only five centuries,
# but also the leap into electronic typesetting, remaining essentially unchanged.
# It was popularised in the 1960s with the release of
# Letraset sheets containing Lorem Ipsum passages, and more recently with
# desktop publishing software like Aldus PageMaker including versions of Lorem
# Ipsum.
#+=============================================================================+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment