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

Return type:

bool

Returns:

  • bool – True if term or word is uncapitalized.

  • 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

  • .. code-block:: python

    def handle_uncapped_word(value: str) -> bool:
    if value.startswith(‘django-‘):

    return True

    if ‘vs’ in value:

    return True

    return False

  • In your settings

  • .. code-block:: python

    DJANGO_DOCUTILS_LIB_TEXT = {
    ‘uncapitalized_word_filters’: [

    ‘project.path.to.handle_uncapped_word’

    ]

    }

django_docutils.lib.text.smart_capfirst(value)[source]

Capitalize the first character of the value.

Return type:

str

django_docutils.lib.text.smart_title(value)[source]

Convert a string into titlecase, except for special cases.

Django can still be capitalized, but it must already be like that.

Return type:

str