5 ms·
Curling smart quotes correctly is a deceptively hard problem. I implemented a basic natural language parser that does a decent job. However, straight quotes are
by thangalin 4y ago
Curling smart quotes correctly is a deceptively hard problem. I implemented a basic natural language parser that does a decent job. However, straight quotes are ambiguous. Compounding the problem is that curled apostrophes and right single quotes are indistinguishable, which is an oversight in Unicode, IMO, because they are semantically different.
Here's my swat at the puzzle:
https://whitemagicsoftware.com/keenquotes/ https://whitemagicsoftware.com/keenquotes/
When exporting Markdown documents to HTML or PDF, my text editor uses KeenQuotes to curl straight quotes to their most likely candidate:
https://github.com/DaveJarvis/keenwrite#download https://github.com/DaveJarvis/keenwrite#download
- GolDDranks 4y agoMakes it even harder that some languages use straigth quotes as the gold standard – so whether to curve them or not is language dependent.
- zokier 4y agoWhich languages prefer straight quotes? Wikipedia doesn't mention any: https://en.wikipedia.org/wiki/Quotation_mark https://en.wikipedia.org/wiki/Quotation_mark
- GoblinSlayer 4y agoLooks like hair splitting to me, they are all interchangeable. Apparently I used Dutch an Danish variants and nobody ever batted an eye. Cursive quotes look like just cursive version of straight quotes, you can't possibly differentiate them.
- bloak 4y agoQuotation marks arguably depend on the country more than on the language, so Switzerland quotes like «this» in French, German and Italian, while the Germans, at least, don't quote like that. It seems that Sweden and Finland use the same character for opening and closing quotes, like ”this”, which is similar to using straight quotes.
- GolDDranks 4y agoI was going to say "Finnish" (that's my native language), but to my surprise, after checking it, we use "”" after all. (We use that both as the opening and closing quotation mark.)
- jeroenhd 4y agoWhile I don't blame you or anything, this only works for English conventions. Dutch quotation marks are different, at least if you try to do smart quotes correctly. Expected output: „Goedemorgen,” zei hij. Returned output: “Goedemorgen,” zei hij. And that's just language to take care of! Smart quotes for computers are hell and there should be a library to do all this so everyone doesn't need to reinvent the wheel.