如何在 GitHub 评论中正确设置代码格式

问题描述 投票:0回答:1

我很难尝试在 GitHub 评论中插入代码。

这个:

变成这样:

还有这个:

变成这样:

我很惊讶在一个专门协作(从而讨论)编程代码的网站上出现这样的问题。

解决办法是什么?

github
1个回答
3
投票

您一直尝试使用单行(也称为内联)Markdown 代码语法:

my code is `print("hello, world")`

虽然您应该使用多行变体:

my code is:
```
def foo():
   print("hello, world")
```

在此处阅读有关 Markdown 的信息。

© www.soinside.com 2019 - 2024. All rights reserved.