Strike through plain text with unicode characters?

后端 未结 3 576
温柔的废话
温柔的废话 2021-02-04 06:07

Is it possible to strike through unwanted revised words in your code comments? Since developers still code in the dark ages a simpler time of

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-04 06:44

    You can also use this function in Python 3+ to generate it on the fly:

    def striken(text):
        return ''.join(t+chr(822) for t in text)
    

    Example output

    >>> def striken(text):
    ...   return ''.join(t+chr(822) for t in text)
    ... 
    >>> striken("hello")
    'h̶e̶l̶l̶o̶'
    >>> striken("hello darkness my old friend")
    'h̶e̶l̶l̶o̶ ̶d̶a̶r̶k̶n̶e̶s̶s̶ ̶m̶y̶ ̶o̶l̶d̶ ̶f̶r̶i̶e̶n̶d̶'
    

提交回复
热议问题