0

我想将语法突出显示应用于 git bash 代码,如下所示:

请点击此图片链接

我正在使用以下代码:


    ```gitㅤ
    diff --git a/fourth.py b/fourth.py
    index 13cc618..4c8cfb6 100644
    --- a/fourth.py
    +++ b/fourth.py
    @@ -1,5 +1,5 @@
     print('hello')
    +print('git')

    -print(1)
    -
    -print('bye')
    \ No newline at end of file
    +print('bye')
    +print('20000')
    \ No newline at end of file

```ㅤ

不适用于使用 github、Github、vim、diff、bash 等关键字,而不是git.

我怎样才能做到这一点?

示例:如果是 python,而不是 git:

print('hello world!')

此方法不适用于 git 代码。

4

1 回答 1

0

In Markdown, when you want to specify a code block (as you have done), you will use the triple backticks (```) to start and end the string you wish formatted as "code." In many Markdown renderers (notably, those following GitHub's implementation of Markdown), you may provide a string ("js", "c++", "html") which represents a language, granting syntax highlighting to the code block.

"git" is not a language, nor an option which works with the above-mentioned syntax highlighting feature. There is no syntax highlighting feature, that I'm aware of, for git diff's format.

You could use triple-backticks followed by "python" (```python). This will provide syntax highlighting to the Python portion but it will be polluted by parsing the non-Python at the top and in the middle of git diff's output text.

于 2020-07-07T13:15:18.347 回答