[Tools MarkDown] Create a Diff in Markdown to Show What Has Changed in a Code Snippet

ou can create diffs in markdown to show what has changed in a code snippet. I use this in blog posts to highlight changed lines for readers. This works for code snippets in most markdown packages and on Dev.to.

To show a line of code changing in a function, you can do this:

```diff
function addTwoNumbers (num1, num2) {
-  return 1 + 2
+  return num1 + num2
}
```

 

posted @ 2020-11-04 01:13  Zhentiw  阅读(68)  评论(0编辑  收藏  举报