Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

markdown github – how to do green code added git and red code deleted in README?

how to do this, coloring lines (like git)?

enter image description here

here is an example where it is used: https://github.com/sveltejs/kit/discussions/7716

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

in markdown, in GitHub readme.

enter image description here

>Solution :

add the symbol + and - (with diff syntax in markdown)

symbol + -
name Addition Deletion
color Green Red
what it does do? code that being added or changed code code that being deleted or removed

how to write it in MD?

“`diff

-hello

+hello world

“`

how it will look?

enter image description here

real example to copy and paste.

-hello
+hello world

see here, I created a gist for you: https://gist.github.com/Laaouatni/1f0825dc0c531eb7cfb49ecc9560094c (click raw to copy code)


by using a diff language name, now you can have this special design.
also, this works only in GitHub, and you can’t color highlight for a specified language like python or javascript for example… so use it when necessary to point a breaking change for example.


now you will be asking me,

why diff in particular?

by just going to google and searching: https://www.google.com/search?q=what+diff+means+linux

enter image description here

the first thing that came to my mind is the command diff, and I tried to search if diff is actually used in markdown, and it turns out that the info is true so it was real.

so use diff instead of javascript/python, or whatever…

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading