Converting ″Straight Quotes″ to “Curly Quotes”

后端 未结 7 1070
旧时难觅i
旧时难觅i 2020-12-13 19:53

I have an application which uses a Javascript-based rules engine. I need a way to convert regular straight quotes into curly (or smart) quotes. It’d be easy to just do a <

相关标签:
7条回答
  • 2020-12-13 20:35

    I don't think something like that in general is easy at all, because you'd have to interpret exactly what each double-quote character in your content means. That said, what I'd do is collect all the text nodes I was interested in, and then go through and keep track of the "on/off" (or "odd/even"; whatever) nature of each double quote instance. Then you can know which replacement entity to use.

    0 讨论(0)
提交回复
热议问题