slugify_batch()
slugany.slugify_batch ¶
slugify_batch(texts: Iterable[str], *, separator: str | None = None, lowercase: bool | None = None, max_length: int = 0, word_boundary: bool = False, stopwords: Iterable[str] | None = None, allow_unicode: bool = False, replacements: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, style: str | None = None, lang: str = 'auto', fallback: str = '', emoji_mode: str = 'strip', css_safe: bool = False, html_entities: bool = True, smart_punctuation: bool = True) -> list[str]
Slugify multiple texts in a single call.
The configuration is built and validated once, so invalid keyword arguments raise before any text is processed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
Iterable[str]
|
Iterable of strings to slugify. A bare string is rejected;
wrap it in a list ( |
required |
separator
|
str | None
|
Separator between words. Defaults to |
None
|
lowercase
|
bool | None
|
Whether to lowercase the output. Defaults to |
None
|
max_length
|
int
|
Maximum slug length. |
0
|
word_boundary
|
bool
|
Truncate at the last word boundary within |
False
|
stopwords
|
Iterable[str] | None
|
Iterable of words to remove from the output. |
None
|
allow_unicode
|
bool
|
Preserve Unicode characters instead of transliterating. |
False
|
replacements
|
Mapping[str, str] | Iterable[tuple[str, str]] | None
|
Mapping or iterable of |
None
|
style
|
str | None
|
Case style preset ( |
None
|
lang
|
str
|
Language for transliteration
( |
'auto'
|
fallback
|
str
|
String to use when the slug would be empty. The fallback is normalized through the pipeline (transliterated, lowercased, separators applied), so it does not need to be a valid slug. |
''
|
emoji_mode
|
str
|
How to handle emojis ( |
'strip'
|
css_safe
|
bool
|
Prefix with |
False
|
html_entities
|
bool
|
Decode HTML entities like |
True
|
smart_punctuation
|
bool
|
Normalize smart quotes, dashes, and zero-width characters. |
True
|
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of slugified strings, one per input text. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If an invalid |
Examples:
Source code in slugany/_slugify.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |