Strike through plain text with unicode characters?

后端 未结 3 577
温柔的废话
温柔的废话 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:43

    in an AutoHotkey script:

    <^>!ü::Send {U+0336}
    

    pressing

    AltGr+ü , y , AltGr+ü , e , AltGr+ü , s

    ̶y̶e̶s, I can strikethrough

    0 讨论(0)
  • 2021-02-04 06:44

    There's U+0336, COMBINING LONG STROKE OVERLAY. Googling Unicode strikethough turns up tools to apply it to your text, such as this one. Whether it looks any good will depend on your font; it looks pretty terrible on my environment.

    0 讨论(0)
  • 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̶'
    
    0 讨论(0)
提交回复
热议问题