Upload / Up1

Client-side encrypted image host web server
MIT License
811 stars 98 forks source link

syntax highlighting for diff #42

Open rhd opened 8 years ago

rhd commented 8 years ago

Hi, it would be great if syntax highlighting worked for diffs (git diff). It seems to detect the python code, but not the fact it's an actual diff and I don't see a way to force it.

Thanks!

andre-d commented 8 years ago

The system used is highlight.js which is meant to have diff support On Jan 19, 2016 5:44 PM, "rhd" notifications@github.com wrote:

Hi, it would be great if syntax highlighting worked for diffs (git diff) It seems to detect the python code, but not the fact it's an actual diff and I don't see a way to force it

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/Upload/Up1/issues/42.

rhd commented 8 years ago

Hmm, it kind of works. For some reason this is being detected as python (I'm assuming) instead of diff. Thoughts?

diff --git a/libs/python/a/a.py b/libs/python/a/a.py
index 8cc7156..2bb880b 100644
--- a/libs/python/a/a.py
+++ b/libs/python/a/a.py
@@ -1033,12 +1033,13 @@ def aa(options):
     """Yaaaa"""
     # aaat
     bbb = 0
-    if options.seek:
-        bbb = f(options.indir, options.a, options.b, options.c, options.d)

     # aaaaaa
     closeHook = xTimeCloseHook(deleteIt=options.a, flagIt=options.b, closeCount=3)
Zegnat commented 8 years ago

Highlight.js uses a concept called relevance to auto-detect languages. Their diff parser only adds relevance for lines wrapped in @@, ***, and ---. There are none of those in your example, so it would never be matched as a diff.

Nothing that can be done other than getting the diff parser improved or waiting for #33 so you can force diff highlighting.