Home > Blockchain >  markdown github - how to do green code added git and red code deleted in README?
markdown github - how to do green code added git and red code deleted in README?

Time:11-21

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

enter image description here

here is an example where it is used: enter image description here

CodePudding user response:

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.

    ```diff
    -hello
     hello world
    ```

see here, I created a gist for you: 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...

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.


  • Related