MacDownApp / macdown

Open source Markdown editor for macOS.
https://macdown.uranusjr.com/
9.43k stars 1.09k forks source link

Smartypants preference setting is ignored #912

Open C8-DO opened 6 years ago

C8-DO commented 6 years ago

Quotes are always changed into typographer's quotes, no matter whether the Smartypants option is activated or not. I have to change the corresponding settings in the system preferences to get straight quotes, which is quite annoying.

And regardless of the settings, inside of codesections quotes should never be changed. All programming languages (I know) use straight quotes, so this is how code should be rendered. And strings won't be color coded with typographer's quotes, either.

I am using MacDown Version 0.7.2d81 (951) right now. Not sure if this problem occurs in the current stable version, too.

FranklinYu commented 6 years ago

I think you are talking to the editor pane. That is not handled by the preferences. If you enable Smartypants in system preference, MacDown would have already received curly quote as soon as you type the quote character; I don't think there is any way for MacDown to tell whether you intend curly quote or straight quote, since MacDown only sees curly quote in the document.

That checkbox in MacDown preference only matters if you have straight quote in source file (.md file), that is, if macOS doesn't convert them automatically. This way straight quote is preserved in source file, and MacDown has the opportunity to choose to render it as curly quote or straight quote. (Yes, MacDown can render straight quote as curly quote, without changing the source file.)

Speaking of disabling Smartypants in code section, that's a good idea. Need more research about the approach though. #385 is related. In conclusion, Smartypants should be disabled both in code section and in math section.

If you feel good about it, I'm going to change the title to focus on second issue.

C8-DO commented 6 years ago

I don't agree with you here. Straight and curly quotes are two different characters, and you can specifically enter them. On my (German) keyboard, if I type Shift-2, I get straight quotes, if I type Option-Shift-2I get curly quotes. The system settings for typographer's quotes catches the Shift-2 and "translates" it to Option-Shift-2.

I think you should be able to do something similar in the editor pane (but I don't use Xcode, so I might be wrong). If smartypants in turned on, "translate" Shift-2(ASCII 34) into the appropriate character for the user's system language. If it's turned off, don't change the character. Or the other way round, if you receive the character for curly quotes in the system language and smartypants is turned off, translate it to ASCII 34. That's how I would basically go about it.

But nevertheless, smartypants currently does not work how you described. In my system settings typographer's quotes are turned on, in MacDown they're turned off. But the quotes are rendered as curly quotes, regardless.

smartypants

After some more tests it gets even stranger. Even though I have turned off typographer's quotes in the system settings, the result stays the same. Only if I specifically select straight quotes in the "for Double Quotes" popup menu in System Preferences, I get straight quotes (and this time in the editor pane and the preview).

And if I turn on smartypants in MacDown, while in the system settings they're still turned of, straight quotes are not rendered into curly quotes.

EDIT: I meant ASCII 34, of course.

C8-DO commented 6 years ago

So after some more test the bottom line is this: no matter what the system settings are, and no matter what the smartypants settings are, the preview will always show the same quotes that the editor shows.

FranklinYu commented 6 years ago

First of all, you meant smart quote substitution when you talked about the system preference for Smartypants, did you?

Assuming that is true, then the checkbox is not intended to change the behavior in editor pane, but the preview pane: screen-1 screen-2 Note that in both screenshots, the editor pane has straight quotes instead of curly quotes. So the MacDown preference doesn’t override system preference; they are just independent settings, in charge of different behaviors.

If you would like to disable smart quote substitution in MacDown editor, while keep it enabled system-wide, we may add another option for it. (In this case, it belongs to the Editor tab of preference window, not Markdown tab.)

In any case, if there is already curly quote in editor pane, it is expected to be previewed as-is. Smart quote always translate straight quote to curly one, never the other way around. It doesn’t need to be “smart” to translate multiple characters into one…

uranusjr commented 6 years ago

(Not entirely related to this issue, just some rumbling.)

Maybe it’s for the best if we just remove the Smartypants extension. It is hacky to start with, works “meh” at best, and sometimes even causes troubles. macOS handles UTF-8 fine, and we’re always saving to UTF-8 anyway. People should just learn how to type smart quotes.

FranklinYu commented 6 years ago

Then I suggest split this issue into three:

  1. Disable Smartypants in math and code section
  2. Application-wise smart quote substitution setting
  3. [Discussion] Remove Smartypants support

where the 3rd issue may close 1st.