-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Enable syntax highlighting on diff view #2528
Conversation
@@ -830,6 +830,10 @@ $(document).ready(function () { | |||
|
|||
// Highlight JS | |||
if (typeof hljs != 'undefined') { | |||
// creating aliases for languages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is needed?
Highlight.js tries to detect the language automatically. But in this particular case, it didn't work as expected. So, I'm explicity setting the language to Highlight.js, as a language-{{language-extension}}
class. Unfortunally, not all languages are being reconized by its file extension (see). So I manually created aliases to two cases I found, but for most languages it isn't necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can use of this? https://github.com/gogits/gogs/blob/master/modules/template/highlight.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that it was already implemented. ¯_(ツ)_/¯ Updated to use that package, much better.
I also did this patch to Highlight.js, so futures version will have these alises by default: https://github.com/isagalaev/highlight.js/pull/1069/files
There was just a little gotcha: I had to move highlight.go
to its own package, because we got a cycle import, which isn't allowed in Go, on importing template
in models
since models
also import template
.
Any screenshots? |
Takes a bit more time to review |
@@ -7,9 +7,9 @@ github.com style (c) Vasily Polovnyov <vast@whiteants.net> | |||
.hljs { | |||
display: block; | |||
overflow-x: auto; | |||
padding: 0.5em; | |||
/*padding: 0.5em;*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think overwrite this value in _base.less
is better as we can't care very well when upgrading the plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@unknwon Makes sense. Done!
Thanks! |
Enable syntax highlighting on diff view
Closes #733