import emoji def replace_emojis(input_text): ''' Replaces emojis in text with a custom LaTeX sequence. :param input_text: :return: ''' for char in input_text: if emoji.is_emoji(char): input_text = input_text.replace(char, f"\\emoji{{{char}}}") return input_text