lib.text¶
Text related utilities for Django Docutils.
- django_docutils.lib.text.is_uncapitalized_word(value)[source]¶
Return True if term/word segment is special uncap term (e.g. “django-“).
- Parameters:
value (str) – string value from template
- Returns:
True if term or word is uncapitalized.
- Return type:
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' ] }