Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Incorrect syntax-highlight with comment tag "#" #1668

Open
louis-hsu opened this issue Apr 1, 2024 · 0 comments
Open

🐛 Incorrect syntax-highlight with comment tag "#" #1668

louis-hsu opened this issue Apr 1, 2024 · 0 comments

Comments

@louis-hsu
Copy link

Environment

  • OS: macOS 14.3.1
  • zsh: zsh 5.9 (arm-apple-darwin21.3.0)
  • delta: delta 0.17.0
  • ripgrep: ripgrep 14.1.0

Test steps

  1. Prepare test.py as below:
num = 407

# To take input from the user
#num = int(input("Enter a number: "))

if num == 1:
    print(num, "is not a prime number")
elif num > 1:
   # check for factors
   for i in range(2,num):
       if (num % i) == 0:
           print(num,"is not a prime number")
           print(i,"times",num//i,"is",num)
           break
   else:
       print(num,"is a prime number")
       
# if input number is less than
# or equal to 1, it is not prime
else:
   print(num,"is not a prime number")        
  1. Run command:
command rg --no-config -C 2 print ./test.py --json | delta --syntax-theme="Nord" 

Expected result

  1. Keyword 'print' should be highlighted
  2. Python syntax should be identified and highlighted correctly

Actual result
Syntax highlighting is not correct:
ScreenShot 2024-04-01 at 13 27 02 

The code after comment tag "#" is treated as comment as well

Others

  1. It seems shell script which uses "#" for comment as Python has the same issue
  2. As for other comment tag ("//", e.g.), works correctly

Please let me know if more verifications required and thanks for the assistance.

louis-hsu added a commit to louis-hsu/dotfiles that referenced this issue Apr 9, 2024
1. 'ripgrep' + 'delta' has some issues when parsing shell script/python,
   which both use '#' as comment tag
2. 'delta' issue filed: dandavison/delta#1668
3. Also check following possible candidates:
   https://github.com/banga/git-split-diffs?tab=readme-ov-file
   https://github.com/shikijs/shiki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant