Skip to content

Commit 6f381ac

Browse files
authored
Explain save_order more clearly (#157)
1 parent 872b375 commit 6f381ac

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def slugify(
5656
:param hexadecimal (bool): converts html hexadecimal to unicode (Ž -> Ž -> z)
5757
:param max_length (int): output string length
5858
:param word_boundary (bool): truncates to end of full words (length may be shorter than max_length)
59-
:param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order
59+
:param save_order (bool): when set, does not include shorter subsequent words even if they fit
6060
:param separator (str): separator between words
6161
:param stopwords (iterable): words to discount
6262
:param regex_pattern (str): regex pattern for disallowed characters
@@ -108,9 +108,13 @@ txt = 'jaja---lol-méméméoo--a'
108108
r = slugify(txt, max_length=20, word_boundary=True, separator=".")
109109
self.assertEqual(r, "jaja.lol.mememeoo.a")
110110

111-
txt = 'one two three four five'
112-
r = slugify(txt, max_length=13, word_boundary=True, save_order=True)
113-
self.assertEqual(r, "one-two-three")
111+
txt = 'one two three four'
112+
r = slugify(txt, max_length=12, word_boundary=True, save_order=False)
113+
self.assertEqual(r, "one-two-four")
114+
115+
txt = 'one two three four'
116+
r = slugify(txt, max_length=12, word_boundary=True, save_order=True)
117+
self.assertEqual(r, "one-two")
114118

115119
txt = 'the quick brown fox jumps over the lazy dog'
116120
r = slugify(txt, stopwords=['the'])

slugify/slugify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def slugify(
9595
:param hexadecimal (bool): converts html hexadecimal to unicode
9696
:param max_length (int): output string length
9797
:param word_boundary (bool): truncates to complete word even if length ends up shorter than max_length
98-
:param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order
98+
:param save_order (bool): when set, does not include shorter subsequent words even if they fit
9999
:param separator (str): separator between words
100100
:param stopwords (iterable): words to discount
101101
:param regex_pattern (str): regex pattern for disallowed characters

0 commit comments

Comments
 (0)