DEV Community

Cover image for How to add color to your Dev.to article’s code snippets

How to add color to your Dev.to article’s code snippets

Christine Belzie on March 15, 2024

Table of Contents Flashback Method #1: Using backticks Method #2: Use CodeSnap Explore more Flashback When I was in co...
Collapse
 
anmolbaranwal profile image
Anmol Baranwal

Why didn't I know about Codesnap 😶
I remember designing the whole thing in Adobe XD for pasting the workflow code.

There is one more thing possible on DEV, it's just that I can't find the article that used it. It was a while ago, similar to the effect of the highlighter.

Between, Awesome article :)

Collapse
 
terabytetiger profile image
Tyler V. (he/him)

Are you maybe referring to setting the language to diff for a triple tick block, then adding a + or - to the beginning of the line to highlight which lines are added/removed?

+ Added this line
-  Removed this line
Enter fullscreen mode Exit fullscreen mode
Collapse
 
cbid2 profile image
Christine Belzie

Was this question for me @terabytetiger? :)

Thread Thread
 
terabytetiger profile image
Tyler V. (he/him)

Sorry for the confusion- no, it's for Anmol regarding this line:

similar to the effect of the highlighter

Collapse
 
anmolbaranwal profile image
Anmol Baranwal

Nope, didn't knew this at all.
I was refering to this type of hightlighting.

But thanks for telling the diff type, I wasn't aware of that :)
Image description

Thread Thread
 
terabytetiger profile image
Tyler V. (he/him) • Edited

Oh, interesting - I don't think I've ever seen that in a post before!

According to this post you can do it with <mark> tags:

Thread Thread
 
anmolbaranwal profile image
Anmol Baranwal

Thank you for sharing :)
I think the list of options should be there in devto editor guide as well.

Collapse
 
jitendrachoudhary profile image
Jitendra Choudhary

I recently got to know to about this Carbon.now.sh but Codesnap seems more efficient. before this I used design the whole thing in figma or would prefer posting a screenshot.

Anyway, Nice article @cbid2 !!

Collapse
 
greenteaisgreat profile image
Nathan G Bornstein

Oh my HECK, I really wish I would've known about this sooner. I've always been posting screenshots of the code I want to share and then posting

let = 'this as my code';
let = 'if anyone wanted to copy/paste it';
Enter fullscreen mode Exit fullscreen mode

But now I know I can just do

const = 'this as my code snippets instead';
Enter fullscreen mode Exit fullscreen mode

So incredibly cool! Thank you so much!

Collapse
 
get_pieces profile image
Pieces 🌟

Awesome article! 🔥 And thanks for the mention ☺️

You can check out our official website at pieces.app/

Collapse
 
posandu profile image
Posandu

While CodeSnap has cool features like backgrounds, I suggest using code blocks instead of images of code because it's easy to copy-paste.

Collapse
 
cbid2 profile image
Christine Belzie

Good point there @posandu! 😊

Collapse
 
zeeshanali0704 profile image
ZeeshanAli-0704

Image description
How to create link like this to navigate to other post
Image description

Also how to create link like these?

Collapse
 
cherryramatis profile image
Cherry Ramatis

Most of my comments with the new articles here is about the syntax highlighting in code blocks, thanks for explaining it so well and also presenting the code snap extension, I didn’t know about 🫶

Collapse
 
abhi_1631 profile image
Abhijeet

Learnt a new stuff today . Thanks Christine :))

Collapse
 
_ndeyefatoudiop profile image
Ndeye Fatou Diop

Such a nice post !! Definitely hope it gets more traction because I have seen posts that would have benefited from it

Collapse
 
bcostaaa01 profile image
Bruno

Omg thank you so much for this!!🙏I will surely have a usage for this stuff in my future articles 👍 great article, Christine! 🙌

Collapse
 
bennyfmo_237 profile image
benny fmo

amazing, i am new to dev and markdown, your post just makes sense, i will do well to refer to them when writing my next article

Collapse
 
cbid2 profile image
Christine Belzie • Edited
Collapse
 
insideee_dev profile image
insideee.dev • Edited

Awesome!
I usually use Carbon to create and beautiful images of your source code.
Everyone can try

Collapse
 
karsten_biedermann profile image
Karsten Biedermann • Edited

Method #1 is just simple markdown syntax and not specific to dev.to 😎

markdownguide.org/extended-syntax/

Collapse
 
cbid2 profile image
Christine Belzie • Edited

Thanks for the guide @karsten_biedermann. 😊
I just wanted a more detailed explanation of method 1, especially for people unfamiliar with Markdown. Also, based on the responses, a lot of people seemed to have not known that they could use this technique to make their code snippets colorful, so sometimes the simplest thing is not always obvious. 😉

Collapse
 
karsten_biedermann profile image
Karsten Biedermann

It's great that you were able to bring some light into the darkness for many people 😊.

Thread Thread
 
cbid2 profile image
Christine Belzie

Absolutely! :)

Collapse
 
prahalad profile image
Prahalad S • Edited

I'm still unable to get this. Can someone help me out. I am getting in black background with white text only. If I use codesnap I'm getting image instead of code.

Collapse
 
gokayburuc profile image
gokayburuc.dev

Carbon.now.sh

Collapse
 
sabeerjuniad profile image
Sabeer Junaid

❤️