Is it possible to embed code snippets on Medium?
You can add a code block by using Ctrl + Alt + 6 (or ⌘ + Alt + 6 on Mac)
Medium also supports github gists which include syntax highlighting.
A lot of folks have asked for GitHub gist support. Now we have it. Simply paste your gist URL into your Medium story and hit return.
You can still also highlight text and hit command-6 for code snippets. Ctrl-6 on Windows.
I found the help article here: https://help.medium.com/hc/en-us/articles/224550008-Code-blocks-inline-code
- type ``` or ` (triple or single backtick) in new line will trigger code block or inline code accordingly. (the keyboard shortcut mentioned by others works too)
- For syntax highlighting, it suggests Github Gists, Codepen.io, or JSfiddle
If you want to embed full working code, you can use https://www.codiva.io. Codiva is registered as an embedly provider, so just paste the project URL, medium-embedly-codiva will do the remaining magic. Codiva supports Java, C and C++. For example, https://medium.com/@jayaprabhakar/poorly-researched-clickbait-articles-in-dzone-cca19d1d0999
You can also add a code block by typing ``` (three backticks) on a new line, or create an inline bit of code by typing a single backtick at the beginning and end of the code. (Or select the text, and type a single backtick).