redmine_highlightjs icon indicating copy to clipboard operation
redmine_highlightjs copied to clipboard

No highlight in view-source mode

Open dominch opened this issue 9 years ago • 13 comments

This mode is not regular code block, has table all over screen. Let's see if there is a way to improve that.

dominch avatar Sep 09 '15 13:09 dominch

I just commited into dev branch one approach to get this working in files view. There are no line numbers and it's still slow, but those files are usually big to highlight. @jwalkerbg @Krakozaber let me know if that helps?

dominch avatar Sep 12 '15 13:09 dominch

It work, thanks.

But not always correctly determines the language

Krakozaber avatar Sep 14 '15 03:09 Krakozaber

Language autodetection depends on content and highlightJS lib, I hope they will improve that feature soon. If You don't use so much languages You can compile limited version of lib including only few selected languages, then chances will be higher to get the one You need. You can report in highlightjs support this piece of code - they will have example to improve. I'll take a look at this later and maybe try to add language by extension, this may help. In editor You can always specify right language if autodetection is wrong. For popular languages it usually works.

dominch avatar Sep 14 '15 09:09 dominch

is this bug fixed?

aliramw avatar Sep 14 '15 13:09 aliramw

It is fixed, but not yet complete. I need to add:

  • code class depending on file extension
  • links to line numbers (this is missing now)

dominch avatar Sep 14 '15 14:09 dominch

@Krakozaber: please try dev version now, hope autodetection now gets good clue about file highlighting. Let me know if that helped.

File highlighting is based on aliases from highlightJS, it was discussed here: https://github.com/isagalaev/highlight.js/issues/324

dominch avatar Sep 15 '15 10:09 dominch

unchanged

Krakozaber avatar Sep 16 '15 07:09 Krakozaber

Any example to check?

dominch avatar Sep 16 '15 08:09 dominch

Both changes were released into 1.0.2 (master)

dominch avatar Sep 16 '15 14:09 dominch

Tested version 1.0.2. It works for repository files.However, there is another incompatibility - between this plugin and Redmine Code Review plugin (http://www.redmine.org/plugins/redmine_code_review). Scenario to show bad behaviour:

Installed both plugins.

View some source file from a repository (I tried with a C file) The file appears in the selected theme, well formatted Press link 'Add new review' that is above the file contents. Expected to happen: the page to refresh, add line numbers to the left of each line and next to each line number to appear a small icon (pencil). This icon is a link to create new task (code review) linked to this file and line. What happened: the page refreshed, but line numbers and pencils did not appear. As a result: code review cannot be created.

jwalkerbg avatar Sep 16 '15 19:09 jwalkerbg

I have installed the code review plugin too... +1

now the new version makes line numbers removed, so code reviewing won't work anymore...

aliramw avatar Sep 17 '15 05:09 aliramw

marilawang , Line numbers are stripped off by highlightjs (http://highlightjs.readthedocs.org/en/latest/line-numbers.html) - this is by design. It seems that codereview and redmine_highlightjs will remain incompatible.

jwalkerbg avatar Sep 17 '15 06:09 jwalkerbg

They are stripped by this plugin, not main lib. The reason is that highlightJS lib works with <pre><code>... block. Redmine by default render this as huge table which I needed to convert into single block. It seems that CodeRay is ready to divide everything into lines, when highlightJS is not. I checked few things and it is not easy to divide nested tags with colors by highlightJS.

Stay cool, I still have some ideas how to merge those. Thanks for raport, at the moment I'm not using code_review plugin, I need to install it and I hope I'll come up with some solution :)

dominch avatar Sep 17 '15 07:09 dominch