Limit line lengths
This commit is contained in:
@@ -124,6 +124,25 @@ def jargonSaneTitle(title):
|
||||
title = title.replace('/','-')
|
||||
return title
|
||||
|
||||
# limit line lengths so that entries are more readable
|
||||
def jargonPageColumns(text, columns):
|
||||
words = text.split(' ')
|
||||
lineLen = 0
|
||||
line = ''
|
||||
result = ''
|
||||
for word in words:
|
||||
if lineLen + len(word) + 1 >= columns:
|
||||
result = result + line + '\n'
|
||||
line = ''
|
||||
lineLen = 0
|
||||
lineLen = lineLen + len(word) + 1
|
||||
if line == '':
|
||||
line = word
|
||||
else:
|
||||
line = line + ' ' + word
|
||||
|
||||
return result + line + '\n'
|
||||
|
||||
def jargonCreateEntry(title, text, outputDir):
|
||||
# create the filename for the entry
|
||||
filename = outputDir
|
||||
@@ -135,6 +154,8 @@ def jargonCreateEntry(title, text, outputDir):
|
||||
if os.path.isfile(filename):
|
||||
return ''
|
||||
|
||||
text = jargonPageColumns(text, 78)
|
||||
|
||||
fp = open(filename, 'w')
|
||||
fp.write(title + '\n\n' + text + '\n')
|
||||
fp.close
|
||||
|
Reference in New Issue
Block a user