Closed gruber closed 10 years ago
That's an OvershareKit bug. Nice catch. I'll get it fixed.
Fixed?
I'm going to mark this one as closed for now. Quotes respect opening brackets now (on the dev branch, will push to master soon).
There are still some edge cases not accounted for that I might tackle later, e.g. abbreviated decades. OSK puts an opening single quote in front of the ’90s instead of a closing single quote.
On 22 Jan 2014, at 9:57pm, Jared Sinclair notifications@github.com wrote:
Fixed?
I think so. What a weird font though. The opening single quote for Helvetica should look like this:
One thing you might find useful is the attached text file. I just opened TextEdit, turned on Cocoa’s smart quotes, and typed a bunch of punctuation characters followed by a quote. Some of these make sense to me, others I can’t figure out. But I suspect there’s a reason for each.
—J.G.
On 23 Jan 2014, at 5:07pm, Jared Sinclair notifications@github.com wrote:
There are still some edge cases not accounted for that I might tackle later, e.g. abbreviated decades. OSK puts an opening single quote in front of the ’90s instead of a closing single quote.
That’s a tough one. I’m not sure I’ve ever seen a smart quotes engine get that right.
My SmartyPants algorithm does, but SmartyPants has the advantage of not being an as-you-type engine. It has the whole string to examine, so it can look behind and ahead.
What about dash-dash for an em-dash?
—J.G.
The opening single quote for Helvetica should look like this:
Whoa. My TextExpander snippets for smart opening double and single quotes have been wrong for a long time.
What about dash-dash for an em-dash?
Of course. And three periods for an ellipsis.
I pushed the fix for the single opening quote to dev and to master. The ellipses and em-dashes will require a little more forethought.
Okay, how about this:
I pushed a major refactor to the dev branch. Same smart quote behavior as before, with new additions:
All of this happens as you type. It also only processes the text (roughly) around the area you’re editing, so it should work well with really long documents.
Looks good! Would also be nice to have a list of words in the device’s current language that start with ’ (like ’em, ’tis, etc.) so that ‘ isn’t used inadvertently.
That would be a cool improvement.
One of the reasons this is so hard on iOS is that NSString “is UTF-16.” In order to look ahead or behind by a specific number of characters I have to parse each character individually with the block enumeration method of NSString.
If you want to see how it's working, see the OSKSmartPunctuation
utility class on the dev branch. All this stuff is emoji-safe and sensitive to writing direction. The decades correction is tucked into the single-quote method near the bottom of the .m file.
God, how I wish Apple would add an "NSComposedCharacterString" class or something to that effect. It would simplify so much.
Tried out the as-you-type quote smartener in Sunlit. Please forgive me if the following is a bug only in Sunlit but not in OvershareKit.
If you type an "opening" punctuation character -- think: ( { [ -- and then type a single or double quote, OSK will give you a closing quote, but clearly should give you an opening quote.
In the case where you type a quote immediately after a quote: