1

I'm using the medium blogging system and I need to insert some code (cli commands, scripts in JS, ...)

I'm using the Keyboard shortcuts but when I press Ctr + Alt + 6 the selected code dissapears.

Is there any other way to insert any code (single or multiline) or some code snippets in our medium publishing process?

frankfullstack
  • 498
  • 5
  • 18
  • 1
    Were you able to figure this out? Whatever (and however) I paste gist urls to Medium, the "magic" just never happens. Whenever I copy gist urls from other posts, they do get formatted though... – toraritte Jul 07 '17 at 12:35
  • Related: [How to retrieve Medium stories for a user from the API?](https://stackoverflow.com/q/36097527) – VLAZ Nov 28 '22 at 20:12

3 Answers3

8

For embedding scripts/snippets in JS in my Medium blog, I use gist. After you create the gist, select “clone via HTTPS” and get the .git link (e.g https://gist.github.com/ab056e7d7d521b5e90b6747bbfd8bac4.git).

Then in Medium blog page, just paste that .git URL from Gist and press Enter. Wait a second or so and the code will appear, perfectly formatted.

Rohan_Paul
  • 1,504
  • 3
  • 29
  • 36
1

As mentioned by @Rohan Paul you can use gist for adding code snippets and the Steps for Adding Gist is as follows:

Step 1:Click on the + button on the left side and select Add Embed

Step 2:Simply copy the link of the gist from the browser

Step 3:Paste the link inside the Add Embed Cheers its done

Jose Kj
  • 2,912
  • 2
  • 28
  • 40
0

Both answers are given above direct us to embed gist but the question itself said he needs to add some CLI commands. So there is no point of using gist for just for simple CLI command. I also came across this issue with my Windows PC ctrl + alt + 6 short key is not worked as expected. This might happen because of some cashing problem in the browser. but refresh the page also doesn't work. So just open a new incognito window and try the same short key ctrl + alt + 6 and it worked for me. enter image description here

Note: Short key for windows: ctrl + alt + 6 Short key for Mac: command + option + 6

INDRAJITH EKANAYAKE
  • 3,894
  • 11
  • 41
  • 63