Code in Medium Posts
The different ways that you can display code in Medium.com Posts to help write more useful software related content.
There are several viable ways to display code in your Medium posts which suit different goals.
Medium code blocks
Create a code block by typing 3 backticks (```). Or highlight a section and hit the following keyboard shortcut (hit again to toggle).
MacOS: Command + Option + 6.
Windows: Ctrl + Alt + 6.
print("Hello World")
Medium inline code
Create inline code print("Hello World")
by typing 1 backtick (`). Or highlight some text and hit the backtick (hit again to toggle).
Images
You can add an image of the code by taking a screenshot and using the Medium Editor functionality to upload the screenshot to your post.
Embeds
You can use an external program to host the code and embed the content into the article. This option enables you to use the functionality and features of the other site.
Medium References
The following Medium Help Article on Text Formatting provides information on how to use Medium code formatting features including keyboard shortcuts:
https://help.medium.com/hc/en-us/articles/215194537-Format-text
This Medium Help Article goes into a bit more detail about Embedding code: