using Pygments as highlight tool for repository files
Added by Jiongliang Zhang over 15 years ago
Requirements¶
- Python version: 2.3 or higher
Install¶
- Unzip redmine_repo_pygments.zip file
- Copy redmine_repo_pygments to #{RAILS_ROOT}/vendor/plugins/
- It contains pygments version 1.0
Descriptions:¶
- Support file types: most of all Pygments support excpet "Filename patterns" is None
- It changes redmine core founction ApplicationHelper#syntax_highlight
- It changes two view files: views/common/_file.rhtml, views/repositories/annotate.rhtml
- Its highlight css file is assets/stylesheets/highlight.css, if you want to upgrade the Pygments to support more file types, you need upgrade the css file too
- python code is:
print HtmlFormatter().get_style_defs('.highlight')
get css styles. - You can also define your ower style css file following the highlight.css file.
- python code is:
- Main file: pyscm.py, read ruby IO pipe as stdin, write stdout to ruby IO pipe.
redmine_repo_pygments.zip (288 KB) redmine_repo_pygments.zip | redmine_repo_pygments plugin (contain pygments) |
Replies (10)
RE: using Pygments as highlight tool for repository files - Added by Jiongliang Zhang over 15 years ago
- If you find any problems, please reply.
RE: using Pygments as highlight tool for repository files - Added by Jiongliang Zhang over 15 years ago
It's in plugin board, http://www.redmine.org/boards/3/topics/6890.
some examples:
1. makefle:
2. python:
3. bash:
4. tcl:
5. asm:
6. perl:
7. java:
8. c:
9. c++:
and so on.
makefile.jpg (24.9 KB) makefile.jpg | makefile | ||
perl.jpg (34 KB) perl.jpg | perl | ||
python.jpg (25 KB) python.jpg | python | ||
tcl.jpg (31.7 KB) tcl.jpg | tcl | ||
asm.jpg (37.1 KB) asm.jpg | asm | ||
bash.jpg (20.6 KB) bash.jpg | bash | ||
c.jpg (27.4 KB) c.jpg | c | ||
cpp.jpg (25.9 KB) cpp.jpg | cpp | ||
java.jpg (25 KB) java.jpg | java |
RE: using Pygments as highlight tool for repository files - Added by Chris Miller over 15 years ago
Awesome!
I just installed it, and it didn't make my site explode! \o/
I run a real tiny server, so these kinds of things excite me. Anyways...
How would I change the theme? I also don't think it's properly detecting Objective-C syntax - how would I do that?
Just as a wee suggestion, if you could somehow add a conf directory or file so that people could easily change those kinds of things, you'd be even more "da bomb!"
This is absolutely fantastic, I've been waiting for Pygments and Redmine for so long now... you rock.
RE: using Pygments as highlight tool for repository files - Added by Jiongliang Zhang over 15 years ago
change the highlight.css file, can change the theme.
RE: using Pygments as highlight tool for repository files - Added by Chris Miller over 15 years ago
jongliang zhang wrote:
change the highlight.css file, can change the theme.
So, I took a look at it and didn't see anything I knew how to do. Something about running a command in Python I think.
Call me dense, but I'm not a Ruby programmer, if you could elaborate I'd really appreciate it!
RE: using Pygments as highlight tool for repository files - Added by Pablo Ruiz over 15 years ago
I have installed it in order to highlight c# code, but it is still not highlited..
Do I need to modify any file?
RE: using Pygments as highlight tool for repository files - Added by Pablo Ruiz over 15 years ago
Ok, I found it..
My current python version (2.4.3) seems to not like --version argument. So I had to modify repo_pygments_application_helper_patch.rb from:
if system("python --version")
To become:
if system("python -V")
RE: using Pygments as highlight tool for repository files - Added by Tomas Åberg over 14 years ago
Thank you for this plugin.
Also, Pablo's fix worked for me. Using CentOS with the redmine stack from bitnami.
RE: using Pygments as highlight tool for repository files - Added by Samuel Carrière over 14 years ago
Hello,
Thank's for this plugin.
With redmine 0.9.3 in CentOS, I had to modify repo_pygments_application_helper_patch.rb from:
cmd_str = "python vendor/plugins/redmine_repo_pygments/lib/python_code/pyscm.py"
To become:
cmd_str = "python /my/absolut/path/vendor/plugins/redmine_repo_pygments/lib/python_code/pyscm.py"
RE: using Pygments as highlight tool for repository files - Added by Fabien C over 14 years ago
Hi,
I also had to copy:vendor/plugins/redmine_repo_pygments/assets/stylesheets/highlight.css
to:public/plugin_assets/redmine_repo_pygments/stylesheets/highlight.css
The Samuel Carrière tip made all my repository files blank, the highlight.css link was incorrect in the html source.