C# scanner file for CodeRay
Added by percy li almost 15 years ago
I'm a C# programmer and don't have much knowledge on RoR.
When I came to Remine, the code highlighting tool "CodeRay" doesn't support C# right now. So I think I need to replace it with another highlighting tool, or make an extension for CodeRay.
There is already a Java scanner file in the current CodeRay library. So I tried to write a C# one according to the Java one. Fortunately, it went smoothly.
The attachment file is the C# scanner I made. It is a temporary solution, because I wrote it just for CodeRay 0.7.6.227, which is also the version Remine is currently using, although there seems to be some improvements in the newer versions of CodeRay. According to the CodeRay roadmap, C# support will be added in version 1.1.
Steps
Put the csharp.rb in <redmine folder>vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners
And then you may use <pre><code class="csharp">.... block now.
(Optional) You may add aliases in the file <redmine folder>vendor/plugins/coderay-0.7.6.227/lib/coderay/_map.rb
(Optional) You may add file extensions' mappings in the file <redmine folder>vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/file_type.rb. And following is my settings:
'cs' => :csharp,
'config' => :xml,
'aspx' => :html,
'resx' => :xml,
'asax' => :html,
'ashx' => :html,
'xaml' => :xml,
'csproj' => :xml,
'xsd' => :xml,
'xsc' => :xml,
'xss' => :xml,
'settings' => :xml,
Replies (8)
RE: C# scanner file for CodeRay - Added by Steven Pardo over 14 years ago
Thanks for the c# scanner. It makes our code snippets much easier to read.
RE: C# scanner file for CodeRay - Added by Josh Galvez over 14 years ago
RE: C# scanner file for CodeRay - Added by Dmitry Popov over 11 years ago
I've created a C# scanner for CodeRay 1.0.9 based on C++.
csharp.gif (15.8 KB) csharp.gif | A test | ||
csharp-vscolors.gif (14.7 KB) csharp-vscolors.gif | A test in Visual Studio default colors | ||
csharp.rb (6.36 KB) csharp.rb | C# scanner | ||
_map.rb (531 Bytes) _map.rb | Scanners map | ||
coderay_vscolors.css (4.56 KB) coderay_vscolors.css | CSS file for Visual Studio default colors |
RE: C# scanner file for CodeRay - Added by Mr. DTTH over 11 years ago
Please update to redmine 2.3.x
In new version redmine, don't found path "redmine folder>vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners"
Thanks.
RE: C# scanner file for CodeRay - Added by Dmitry Popov over 11 years ago
I put it in Coderay directory:
path\to\ruby\lib\ruby\gems\1.9.1\gems\coderay-1.0.9\lib\coderay\scanners
RE: C# scanner file for CodeRay - Added by Tide _ over 11 years ago
Where did you put coderay_vscolors.css or what did you do with it?
RE: C# scanner file for CodeRay - Added by Dmitry Popov over 11 years ago
Append it to Redmine stylesheet by copying its contents or using @import
directive:
path\to\redmine\public\stylesheets\application.css
Or:
path\to\redmine\public\themes\theme_you_wish_to_modify\stylesheets\application.css
RE: C# scanner file for CodeRay - Added by Nayuta Taga over 9 years ago
I have wrote another C# scanner https://github.com/ganaware/coderay/commit/ed8360837166b9f06cc60a86ffba0e776c74d43b .
It is based on coderay 1.1.1.rc1 (not yet released), and tested on redmine-3.1.0 .
1. how to install my patched coderay¶
Download,
$ git clone https://github.com/ganaware/coderay.git
build and
$ cd coderay $ git checkout csharp-scanner $ gem build coderay.gemspec
install.
$ sudo gem install ./coderay-1.1.1.rc1.gem $ gem list coderay *** LOCAL GEMS *** coderay (1.1.1.rc1, 1.1.0)
2. setup your redmine¶
Edit redmine's Gemfile,
--- /your-redmine-directory/Gemfile~ 2015-07-26 16:11:01.000000000 +0900
+++ /your-redmine-directory/Gemfile 2015-08-17 17:23:54.000000000 +0900
@@ -6,7 +6,8 @@
gem "rails", "4.2.3"
gem "jquery-rails", "~> 3.1.3"
-gem "coderay", "~> 1.1.0"
+#gem "coderay", "~> 1.1.0"
+gem "coderay", "=1.1.1.rc1"
gem "builder", ">= 3.0.4"
gem "request_store", "1.0.5"
gem "mime-types"
run bundler and then restart your web server.
$ cd /your-redmine-directory/ $ bundle install $ <restart-your-web-server>
A. uninstall¶
If newer coderay will be released, you should uninstall my patched coderay.
$ sudo gem uninstall coderay -v 1.1.1.rc1
Restore redmine's original Gemfile,
run bundler again
and then restart your web server.