0

I want to apply syntax highlighting to git bash code like this:

Please click this image link

I'm using this following code:


    ```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

```ㅤ

not working for use keyword such as github, Github, vim, diff, bash, etc. instead of git.

How can I do this?

example: if python, instead of git:

print('hello world!')

this method is not working for git-code.

kostix
  • 51,517
  • 14
  • 93
  • 176
Iwon J
  • 1
  • 3
  • hi @Iwon J, welcome to stackoverflow! have you read this https://stackoverflow.com/questions/14049896/setting-colors-for-ls-in-git-bash-on-windows ? – mike May 27 '20 at 13:18
  • Can you elaborate? There's no such thing as a "git bash code", so we need to try to understand what you're talking about. What you have shown is a (colored) output produced by `git diff` — on of the Git commands. Now what exactly is your problem? _Where_ do you want to have "syntax highlighting"? There are so many contexts such a diff output may be displayed… – kostix May 27 '20 at 14:43
  • Or, you may be you wanted to say something like "The output of `git` commands is colored when it's rendered in a Git Bash window. I would like the output of other random commands to be colored as well"? – kostix May 27 '20 at 14:44
  • Hello, I want to apply syntax highlighting(color..ing) to my code in jekyll-themed blog, but not working for git-code, unlike python or javascript, etc. – Iwon J May 28 '20 at 04:12
  • Thanks. While I still have no idea what you call "git-code" (I'm not sure such thing exists) at least I've managed to retag your question properly. Hope you'll get help from Jekyll users. – kostix May 28 '20 at 11:16
  • Have you tried ```shell? – Brad West May 28 '20 at 23:27
  • Of course, (bash = zsh = sh = shell have same effects) but it's not working.. – Iwon J May 30 '20 at 02:00

1 Answers1

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.