Run markdown code blocks in Atom?



I quite enjoy the ability to run code blocks in a .jmd file directly inside atom. Would it somehow be possible to configure atom to run a


block in a regular markdown file (like in the same way?



Yes. :slight_smile:

So by default you can use Julia: Run Block, Julia: Run Cell, and Julia: Run File in any file, but the keybindings are only set in Julia files (or Weave files if you have language-weave installed).
With this commit the Run Cell command will behave the same in all non-Julia files.

If you want keybindings for e.g. markdown files then you’ll need to copy the following code block into your keymap (open with Application: Open your Keymap):

'.platform-win32 .item-views > atom-text-editor[data-grammar="text md"],
 .platform-linux .item-views > atom-text-editor[data-grammar="text md"]':
  'ctrl-enter': 'julia-client:run-block'
  'shift-enter': 'julia-client:run-and-move'
  'ctrl-shift-enter': 'julia-client:run-file'
  'alt-enter': 'julia-client:run-cell'
  'alt-shift-enter': 'julia-client:run-cell-and-move'
  'alt-down': 'julia-client:next-cell'
  'alt-up': 'julia-client:prev-cell'
  'ctrl-j ctrl-m': 'julia-client:set-working-module'
  'ctrl-shift-c': 'julia-client:interrupt-julia'
  'ctrl-j ctrl-d': 'julia-client:show-documentation'
  'ctrl-j ctrl-g': 'julia-client:goto-symbol'


'.platform-darwin .item-views > atom-text-editor[data-grammar="text md"]':
  'cmd-enter': 'julia-client:run-block'
  'shift-enter': 'julia-client:run-and-move'
  'cmd-shift-enter': 'julia-client:run-file'
  'alt-enter': 'julia-client:run-cell'
  'alt-shift-enter': 'julia-client:run-cell-and-move'
  'alt-down': 'julia-client:next-cell'
  'alt-up': 'julia-client:prev-cell'
  'cmd-j cmd-d': 'julia-client:show-documentation'
  'cmd-shift-a': 'julia:select-block'
  'cmd-j cmd-g': 'julia-client:goto-symbol'

For others you’ll need to adapt the [data-grammar="text md"] part to whatever language you’re using at the time.


Wonderful! Thanks :smiley:


You can also just change the language on a file-by-file basis to be weave markdown. But this solution is probably better :grinning: