From 436e798c6069adffcbd9c4d8688a142215033870 Mon Sep 17 00:00:00 2001 From: Mark Steward Date: Fri, 22 Aug 2025 03:34:41 +0100 Subject: [PATCH] Explain `save_order` more clearly --- README.md | 12 ++++++++---- slugify/slugify.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0dfbd92..c796aa4 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ def slugify( :param hexadecimal (bool): converts html hexadecimal to unicode (Ž -> Ž -> z) :param max_length (int): output string length :param word_boundary (bool): truncates to end of full words (length may be shorter than max_length) - :param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order + :param save_order (bool): when set, does not include shorter subsequent words even if they fit :param separator (str): separator between words :param stopwords (iterable): words to discount :param regex_pattern (str): regex pattern for disallowed characters @@ -108,9 +108,13 @@ txt = 'jaja---lol-méméméoo--a' r = slugify(txt, max_length=20, word_boundary=True, separator=".") self.assertEqual(r, "jaja.lol.mememeoo.a") -txt = 'one two three four five' -r = slugify(txt, max_length=13, word_boundary=True, save_order=True) -self.assertEqual(r, "one-two-three") +txt = 'one two three four' +r = slugify(txt, max_length=12, word_boundary=True, save_order=False) +self.assertEqual(r, "one-two-four") + +txt = 'one two three four' +r = slugify(txt, max_length=12, word_boundary=True, save_order=True) +self.assertEqual(r, "one-two") txt = 'the quick brown fox jumps over the lazy dog' r = slugify(txt, stopwords=['the']) diff --git a/slugify/slugify.py b/slugify/slugify.py index 09c7e07..67b31c8 100644 --- a/slugify/slugify.py +++ b/slugify/slugify.py @@ -95,7 +95,7 @@ def slugify( :param hexadecimal (bool): converts html hexadecimal to unicode :param max_length (int): output string length :param word_boundary (bool): truncates to complete word even if length ends up shorter than max_length - :param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order + :param save_order (bool): when set, does not include shorter subsequent words even if they fit :param separator (str): separator between words :param stopwords (iterable): words to discount :param regex_pattern (str): regex pattern for disallowed characters