zephyr_mirror: Also linewrap with extremely long strings.

(imported from commit cffa80f283fdac341942beb56ada9013cb8f7c39)
This commit is contained in:
Tim Abbott 2012-11-05 15:44:08 -05:00
parent 42e94b2684
commit a70fc5c5c1

View file

@ -104,10 +104,13 @@ def to_zephyr_username(humbug_username):
# in the same paragraph, should have been wrapped in a way consistent # in the same paragraph, should have been wrapped in a way consistent
# with how the previous line was wrapped) or (2) shorter than 60 # with how the previous line was wrapped) or (2) shorter than 60
# characters (our assumed minimum linewrapping threshhold for Zephyr) # characters (our assumed minimum linewrapping threshhold for Zephyr)
# or (3) the first word of the next line is longer than this entire
# line.
def different_paragraph(line, next_line): def different_paragraph(line, next_line):
words = next_line.split() words = next_line.split()
return (len(line + " " + words[0]) < len(next_line) * 0.8 or return (len(line + " " + words[0]) < len(next_line) * 0.8 or
len(line + " " + words[0]) < 60) len(line + " " + words[0]) < 60 or
len(line) < len(words[0]))
# Linewrapping algorithm based on: # Linewrapping algorithm based on:
# http://gcbenison.wordpress.com/2011/07/03/a-program-to-intelligently-remove-carriage-returns-so-you-can-paste-text-without-having-it-look-awful/ # http://gcbenison.wordpress.com/2011/07/03/a-program-to-intelligently-remove-carriage-returns-so-you-can-paste-text-without-having-it-look-awful/