Python: Replace typographical quotes, dashes, etc. with their ascii counterparts

后端 未结 5 1783
梦如初夏
梦如初夏 2020-12-31 00:57

On my website people can post news and quite a few editors use MS word and similar tools to write the text and then copy&paste into my site\'s editor (simple textarea, n

5条回答
  •  -上瘾入骨i
    2020-12-31 01:52

    This tool will normalize punctuation in markdown: http://johnmacfarlane.net/pandoc/README.html

    -S, --smart Produce typographically correct output, converting straight quotes to curly quotes, --- to em-dashes, -- to en-dashes, and ... to ellipses. Nonbreaking spaces are inserted after certain abbreviations, such as “Mr.” (Note: This option is significant only when the input format is markdown or textile. It is selected automatically when the input format is textile or the output format is latex or context.)

    It's haskell, so you'd have to figure out the interface.

提交回复
热议问题