@@ -45,131 +45,25 @@ From sources:
4545 How to use
4646----------
4747
48+ **In code: **
49+
4850.. code :: python
4951
5052 from slugify import slugify
5153
52- txt = " This is a test ---"
53- r = slugify(txt)
54- self .assertEqual(r, " this-is-a-test" )
55-
56- txt = " ___This is a test ---"
57- r = slugify(txt)
58- self .assertEqual(r, " this-is-a-test" )
59-
60- txt = " ___This is a test___"
61- r = slugify(txt)
62- self .assertEqual(r, " this-is-a-test" )
63-
64- txt = " This -- is a ## test ---"
65- r = slugify(txt)
66- self .assertEqual(r, " this-is-a-test" )
67-
68- txt = ' 影師嗎'
69- r = slugify(txt)
70- self .assertEqual(r, " ying-shi-ma" )
71-
72- txt = ' C\' est déjà l\' été.'
73- r = slugify(txt)
74- self .assertEqual(r, " c-est-deja-l-ete" )
75-
76- txt = ' Nín hǎo. Wǒ shì zhōng guó rén'
77- r = slugify(txt)
78- self .assertEqual(r, " nin-hao-wo-shi-zhong-guo-ren" )
79-
80- txt = ' jaja---lol-méméméoo--a'
81- r = slugify(txt)
82- self .assertEqual(r, " jaja-lol-mememeoo-a" )
83-
84- txt = ' Компьютер'
85- r = slugify(txt)
86- self .assertEqual(r, " kompiuter" )
87-
88- txt = ' jaja---lol-méméméoo--a'
89- r = slugify(txt, max_length = 9 )
90- self .assertEqual(r, " jaja-lol" )
91-
92- txt = ' jaja---lol-méméméoo--a'
93- r = slugify(txt, max_length = 15 )
94- self .assertEqual(r, " jaja-lol-mememe" )
95-
96- txt = ' jaja---lol-méméméoo--a'
97- r = slugify(txt, max_length = 50 )
98- self .assertEqual(r, " jaja-lol-mememeoo-a" )
99-
100- txt = ' jaja---lol-méméméoo--a'
101- r = slugify(txt, max_length = 15 , word_boundary = True )
102- self .assertEqual(r, " jaja-lol-a" )
54+ slug = slugify(" C'est déjà l'été." )
55+ self .assertEqual(slug, " c-est-deja-l-ete" )
10356
104- txt = ' jaja---lol-méméméoo--a'
105- r = slugify(txt, max_length = 17 , word_boundary = True )
106- self .assertEqual(r, " jaja-lol-mememeoo" )
57+ See further examples and optional arguments in (`test.py `_).
10758
108- txt = ' jaja---lol-méméméoo--a'
109- r = slugify(txt, max_length = 18 , word_boundary = True )
110- self .assertEqual(r, " jaja-lol-mememeoo" )
11159
112- txt = ' jaja---lol-méméméoo--a'
113- r = slugify(txt, max_length = 19 , word_boundary = True )
114- self .assertEqual(r, " jaja-lol-mememeoo-a" )
60+ **On the command line: **
11561
116- txt = ' jaja---lol-méméméoo--a'
117- r = slugify(txt, max_length = 20 , word_boundary = True , separator = " ." )
118- self .assertEqual(r, " jaja.lol.mememeoo.a" )
119-
120- txt = ' jaja---lol-méméméoo--a'
121- r = slugify(txt, max_length = 20 , word_boundary = True , separator = " ZZZZZZ" )
122- self .assertEqual(r, " jajaZZZZZZlolZZZZZZmememeooZZZZZZa" )
123-
124- txt = ' one two three four five'
125- r = slugify(txt, max_length = 13 , word_boundary = True , save_order = True )
126- self .assertEqual(r, " one-two-three" )
127-
128- txt = ' one two three four five'
129- r = slugify(txt, max_length = 13 , word_boundary = True , save_order = False )
130- self .assertEqual(r, " one-two-three" )
131-
132- txt = ' one two three four five'
133- r = slugify(txt, max_length = 12 , word_boundary = True , save_order = False )
134- self .assertEqual(r, " one-two-four" )
135-
136- txt = ' one two three four five'
137- r = slugify(txt, max_length = 12 , word_boundary = True , save_order = True )
138- self .assertEqual(r, " one-two" )
139-
140- txt = ' this has a stopword'
141- r = slugify(txt, stopwords = [' stopword' ])
142- self .assertEqual(r, ' this-has-a' )
143-
144- txt = ' the quick brown fox jumps over the lazy dog'
145- r = slugify(txt, stopwords = [' the' ])
146- self .assertEqual(r, ' quick-brown-fox-jumps-over-lazy-dog' )
147-
148- txt = ' Foo A FOO B foo C'
149- r = slugify(txt, stopwords = [' foo' ])
150- self .assertEqual(r, ' a-b-c' )
151-
152- txt = ' Foo A FOO B foo C'
153- r = slugify(txt, stopwords = [' FOO' ])
154- self .assertEqual(r, ' a-b-c' )
155-
156- txt = ' the quick brown fox jumps over the lazy dog in a hurry'
157- r = slugify(txt, stopwords = [' the' , ' in' , ' a' , ' hurry' ])
158- self .assertEqual(r, ' quick-brown-fox-jumps-over-lazy-dog' )
159-
160- txt = ' foo & bar'
161- r = slugify(txt)
162- self .assertEqual(r, ' foo-bar' )
62+ .. code :: bash
16363
164- txt = " ___This is a test___"
165- regex_pattern = r ' [^ -a-z0-9_ ]+ '
166- r = slugify(txt, regex_pattern = regex_pattern)
167- self .assertEqual(r, " ___this-is-a-test___" )
64+ $ slugify " C'est déjà l'été."
65+ c-est-deja-l-ete
16866
169- txt = " ___This is a test___"
170- regex_pattern = r ' [^ -a-z0-9_ ]+ '
171- r = slugify(txt, separator = ' _' , regex_pattern = regex_pattern)
172- self .assertNotEqual(r, " _this_is_a_test_" )
17367
17468 Running the tests
17569-----------------
@@ -210,4 +104,6 @@ X.Y.Z Version
210104.. |download-image | image :: https://img.shields.io/pypi/dm/python-slugify.svg
211105 :target: https://pypi.python.org/pypi/python-slugify
212106
107+ .. _test.py : test.py
108+
213109.. _MIT : https://github.com/un33k/python-slugify/blob/master/LICENSE
0 commit comments