![]() |
VOOZH | about |
|
👁 CodeRay logo 1.1.2 |
Try it!paste to highlight |
DownloadSource | Bugtracker |
Documentationin autumnal colors |
👁 Why
|
Fast and easy syntax highlighting for selected languages.
input languages
output formats
tools
coderay
executable
license
basic features
The latest stable version is 1.1.2. More features are planned for 1.2.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# output as HTML div (using inline CSS styles)CodeRay.scan('puts "Hello, world!"',:ruby).div# ...with line numbersCodeRay.scan("5.times do\n puts 'Hello, world!'\nend",:ruby).div(:line_numbers=>:table)# output as standalone HTML page (using CSS classes)CodeRay.scan('puts "Hello, world!"',:ruby).page# keep scanned tokens for later usetokens=CodeRay.scan('{ "just": "an", "example": 42 }',:json)# produce a token statistictokens.statistic# count LoC (lines of code)CodeRay.scan("# comment\nputs 'Hello, world!'",:ruby).loc# => 1# produce a HTML div, but with CSS classestokens.div(:css=>:class)# highlight a file (to HTML div); guess the file type base on the extensionCodeRay.highlight_file(__FILE__)# re-using scanner and encoder with DuoCodeRay::Duo[:ruby,:div].encode('puts "Hello, world!"') |
More documentation is also available.