Truncate a string after a certain number of words. Strip newlines in the string.
(self, length, truncate)
| 249 | return self._text_words(length, truncate) |
| 250 | |
| 251 | def _text_words(self, length, truncate): |
| 252 | """ |
| 253 | Truncate a string after a certain number of words. |
| 254 | |
| 255 | Strip newlines in the string. |
| 256 | """ |
| 257 | words = self._wrapped.split() |
| 258 | if len(words) > length: |
| 259 | words = words[:length] |
| 260 | return add_truncation_text(" ".join(words), truncate) |
| 261 | return " ".join(words) |
| 262 | |
| 263 | |
| 264 | @keep_lazy_text |
no test coverage detected