Is it possible to embed code snippets on Medium?
8 Answers
You can add a code block by using Ctrl + Alt + 6 (or ⌘ + Alt + 6 on Mac)
Source: https://medium.com/help-center/writing-128f049a7ad#b41a
-
3Is there a way to enable syntax highlighting when inserting code like this?– DASKAjAMar 20, 2015 at 15:46
-
2I've only looked briefly, but it doesn't look like it. You might be better off asking in a separate question rather than here though.– John CMar 21, 2015 at 3:00
-
1@Anwar Medium has no support for inline code at this time unfortunately– John CMay 8, 2016 at 12:55
-
1
-
2why the hell something used a lot by coders around there doesn't sport a simple freaking button for this formatting option? Why's it a hidden feature? What other hidden features are there? :thinking_face: Dec 24, 2016 at 3:10
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.
just use the ``` to create a new code block.
I found the help article here: https://help.medium.com/hc/en-us/articles/224550008-Code-blocks-inline-code
Basically:
- 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
Yes. You can also go to gist.github.com . Type/paste your code there and paste the link in Medium, then press enter.
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
Copy/paste code from editors like Webstorm or VS Code. It should create a code block.
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).
Source: https://help.medium.com/hc/en-us/articles/225168768-Write-post