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:
-
text
–
the text to sanitize
-
safe_chars
–
characters to consider safe and to keep after sanitization
-
emoji
–
whether to also convert emoji to text