Skip to content

Commit

Permalink
BibConvert: fix for formatting option WORDS
Browse files Browse the repository at this point in the history
* Fixes an error caused by FormatField when using formatting
  option WORDS on a string with less words then the specified
  number of words to keep.
  • Loading branch information
jalavik authored and tiborsimko committed Mar 28, 2011
1 parent 55ae1db commit 56d46d5
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions modules/bibconvert/lib/bibconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,25 +1005,18 @@ def FormatField(value, fn):
out = value

elif (fn == "WORDS"):
tmp2 = [value]
wordlist = [value]
par = set_par_defaults(par, ",")
max_num_words = int(par[0])
if (par[1] == "R"):
tmp = value.split(" ")
tmp2 = []
i = 0
while (i < string.atoi(par[0])):
tmp2.append(tmp[i])
i = i + 1
words = value.split(" ")
wordlist = words[:max_num_words]
if (par[1] == "L"):
tmp = value.split(" ")
tmp.reverse()
tmp2 = []
i = 0
while (i < string.atoi(par[0])):
tmp2.append(tmp[i])
i = i + 1
tmp2.reverse()
out = string.join(tmp2, " ")
words = value.split(" ")
words.reverse()
wordlist = words[:max_num_words]
wordlist.reverse()
out = " ".join(wordlist)

elif (fn == "MINL"):

Expand Down

0 comments on commit 56d46d5

Please sign in to comment.