atom-community / markdown-preview-plus

Markdown Preview + Community Features
https://atom.io/packages/markdown-preview-plus
Other
370 stars 88 forks source link

toggle github style in the ctrl-shift-p menu #507

Closed vogu66 closed 3 years ago

vogu66 commented 3 years ago

Hello,

I used to use the native "markdown preview" package but then needed use math so I switched. In the end there is just one thing that bugs me a little bit: the option to "toggle github style" appears in the ctrl-shift-p menu in the native package, but for this package I need to open the settings and check/un-check the box.

So, since I used the option pretty often, I was wondering if it would be possible to add it back? Not especially with a keybinding, but just in the menu. I don't know if it would be a lot of work, but I would guess no?

Now I suppose I may be the only one changing the style for every document to see which goes better, or whether it goes better with the ambient lighting, so I'd understand if it were a choice not to implement it.

Thanks for reading

lierdakil commented 3 years ago

Hi. I'm not entirely sure about the exact behaviour you expect from such a command, but it's easy enough to add a command to toggle an option on your end. Just add the following to your init script (application: open your init script command in the palette):

atom.commands.add("atom-workspace", {
  "markdown-preview-plus:toggle-github-style": () => {
    const style = atom.config.get('markdown-preview-plus.useGitHubStyle')
    atom.config.set('markdown-preview-plus.useGitHubStyle', !style)
  }
})

Then restart Atom or run window: reload command from the palette. Now you have markdown-preview-plus:toggle-github-style command which will toggle the tick in the settings.

And you can also bind whatever keys you want to it in your keymap (application: open your keymap). See https://flight-manual.atom.io/behind-atom/sections/keymaps-in-depth/ for more info.

vogu66 commented 3 years ago

Huh, I guess I never did dig into how Atom works. Well, ignore I said anything then, thanks a lot !