dominch / redmine_highlightjs

A redmine plugin to highlight code blocks much better than coderay!
Other
22 stars 10 forks source link

No highlight in view-source mode #3

Open dominch opened 9 years ago

dominch commented 9 years ago

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

dominch commented 8 years ago

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?

Krakozaber commented 8 years ago

It work, thanks.

But not always correctly determines the language

dominch commented 8 years ago

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.

aliramw commented 8 years ago

is this bug fixed?

dominch commented 8 years ago

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

dominch commented 8 years ago

@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

Krakozaber commented 8 years ago

unchanged

dominch commented 8 years ago

Any example to check?

dominch commented 8 years ago

Both changes were released into 1.0.2 (master)

jwalkerbg commented 8 years ago

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.

aliramw commented 8 years ago

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

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

jwalkerbg commented 8 years ago

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.

dominch commented 8 years ago

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 :)