Writing on Medium is a great experience that many people love. However, if you are writing code heavy articles pasting in code blocks sort of stinks.

By default, a rendered article doesn’t include syntax highlighting and if you are sharing more than a few lines of code it’s not that easy to follow. Here is an example of a default code block:

class Demo 
  public function doSomething() 
    return 'I did it!';

Jacob Bennett created a new app called MarkdownToMedium that will allow you to write in Markdown, which is converted to a Gist, then any code blocks are then automatically extracted into their own Gist’s and embedded into your article.

Here is how it works. First, authorize with your GitHub account and then paste your markdown in.

Next, continue to step 2 to name your code blocks.

Finally, copy and paste the URL it provides and import into a Medium article. Note: You will need to put your cursor after the included Gist link and hit enter. This is so it will automatically expand and leave you with a nice looking embed like this:

If you enjoy writing in Markdown or are posting a lot of code blocks give Markdown to Medium a try!