lib.text¶
Text related utilities for Django Docutils.
-
django_docutils.lib.text.is_uncapitalized_word(value)¶
Return True if term/word segment is special uncap term (e.g. “django-“).
Functions can be declared via DJANGO_DOCUTILS_TEXT in django settings via string imports. The filters accept one argument (the word). If you don’t want the word/pattern capitalized, return True. Anything else capitalizes as normal.
How to create filters:
def handle_uncapped_word(value: str) -> bool: if value.startswith('django-'): return True if 'vs' in value: return True return False
In your settings:
DJANGO_DOCUTILS_LIB_TEXT = { 'uncapitalized_word_filters': [ 'project.path.to.handle_uncapped_word' ] }
-
django_docutils.lib.text.smart_capfirst(value)¶
Capitalize the first character of the value.
-
django_docutils.lib.text.smart_title(value)¶
Convert a string into titlecase, except for special cases.
Django can still be capitalized, but it must already be like that.