Skip to content

octoprint.util.text#

sanitize(text, safe_chars='-_.', demoji=True) #

Sanitizes text by running it through slugify and optionally emoji translating.

Examples:

sanitize("Hello World!") 'Hello-World' sanitize("Hello World!", safe_chars="-_. ") 'Hello World' sanitize("❤") 'red_heart' sanitize("❤︀") 'red_heart' sanitize("❤", demoji=False) ''

Parameters:

Name Type Description Default
text

the text to sanitize

required
safe_chars

characters to consider safe and to keep after sanitization

'-_.'
emoji

whether to also convert emoji to text

required
Back to top