Questions tagged [coderay]

CodeRay is a library for syntax highlighting, written in Ruby, and running on Ruby implementations.

CodeRay is a library for syntax highlighting, written in Ruby, and running on Ruby implementations.

The Coderay library provides the option to display the code colored by having keywords, strings, floats, comments and other language elements in different colors. Additionally, the line numbers are shown at the beginning of each line.

34 questions
7
votes
1 answer

How do I get Haml to stop from evaluating #{var} values inside
  tags?

I'm using CodeRay and Haml to do syntax highlighting on some pages, and I write a lot of Ruby code. The problem is when I have something like this: %pre %code.language-ruby :preserve def hello(name) puts "Hello #{name}!" …
Phrozen
  • 538
  • 4
  • 13
7
votes
3 answers

CodeRay throws error in Rails console

I'm running Rails 4 and whenever I try running anything in the rails console, I get the following error: 2.0.0 (main):0 > User.first CodeRay::Scanners::Scanner::ScanError: ***ERROR in scanner.rb:333:in `raise_inspect': no implicit conversion of…
silasjmatson
  • 1,774
  • 17
  • 36
6
votes
1 answer

Markdown live preview like stackoverflow for redcarpet on rails

I'm using Redcarpet as markdown tool and coderay for syntax highlighting in my rails app. What I want is a preview of what is being written in markdown format before posting it in database. A far better option is a live preview of what's being…
Shuvro
  • 1,444
  • 4
  • 14
  • 33
5
votes
2 answers

Is it possible to use CodeRay in github pages?

I'm using Jekyll-Bootstrap now. In my local environment, I can enable CodeRay in jekyll's _config.yml and use it in my posts without any problem. But the same code cannot work on github. My _config.yml (jekyll-bootstrap configs are omitted): # Use…
huandu
  • 128
  • 6
4
votes
1 answer

Syntax highlighting with CodeRay and Markdown (RDiscount) in a Rails 3 application

I'm trying to add some syntax highlighting to my blog that currently uses RDiscount. I am converting the Markdown to HTML with RDiscount then parsing the HTML code blocks with CodeRay to add syntax highlighting. This is what I have so far: class…
Andrew
  • 196,883
  • 184
  • 487
  • 673
4
votes
1 answer

CodeRay stylesheet

require 'coderay' puts CodeRay.scan('puts "Hello, world!"', :ruby).page This code will print full HTML page with CSS(classes). I may print only colored code using CodeRay.scan('puts "Hello, world!"', :ruby).div How can I print only CSS part?…
Dmitry
  • 6,829
  • 12
  • 53
  • 81
3
votes
2 answers

How to select a different theme/style for CodeRay syntax highlighting Ruby code?

I'm having difficulty figuring out how to select a different theme/style for syntax highlighting of Ruby code using the CodeRay gem, the default is OK but i wonder if there's anything else on offer? i can't seem to find them. Thanks
horseyguy
  • 27,966
  • 18
  • 97
  • 133
3
votes
1 answer

coderay solarized

How I can add solarized-dark colors to coderay ? I'm thinking about tweaking the alpha.rb file, but not sure which css class definitions substitute with which color code. Any better ideas ? Maybe there exist some out of the box solution ? Found…
astropanic
  • 10,140
  • 17
  • 64
  • 128
2
votes
1 answer

On Ruby on Rails, how to do Syntax highlighting using Markdown (RDiscount / BlueCloth) with CodeRay?

I am aware there is a Railscast and ASCIIcast for using Textile (RedCloth) with CodeRay, and the way it is done is by a helper: module ApplicationHelper def coderay(text) text.gsub(/\(.+?)\<\/code\>/m) do …
nonopolarity
  • 130,775
  • 117
  • 415
  • 675
2
votes
1 answer

Getting the list of available languages

How can I get the list of available languages (the short symbol to be passed when calling a method that represents the language) for CodeRay syntax highlighter? I tried require "coderay" CodeRay::Scanners.constants but that doesn't seem to give the…
sawa
  • 156,411
  • 36
  • 254
  • 350
2
votes
1 answer

Make Coderay (in Pry) highlight comments

My .pryrc looks like this: Pry.config.print = proc { |output, value| output.puts "# => " + value.inspect ; puts } Pry.config.prompt = [ proc { "" }, proc { "" } ] Pry.config.prompt_name = 'my_project_name' puts "# " +…
user2251284
  • 397
  • 1
  • 10
2
votes
0 answers

Code Syntax Highlighting with coderay

hey, i am using Coderay and Redcarpet for Syntax highlighting and parsing markup. Pls. suggest a way to get rid of the indicated leading spaces in the div (Ref Image) class CodeRayify < Redcarpet::Render::HTML def block_code(code, language) …
spidergears
  • 192
  • 11
2
votes
1 answer

Kramdown/coderay will not parse code snippets using html in Jekyl/Octopress

I have a website that is using Octopress (Which uses Jekyl). Here is my codeblock that I want to display the color highlighting syntax for: ~~~ def what? 42 end ~~~ {:lang='ruby} If this is in a file.markdown file it is parsed correctly and I…
user985723
  • 588
  • 2
  • 7
  • 17
1
vote
1 answer

Use Coderay with Liquid include?

I have a Jekyll blog, I am trying to switch from this {:lang='bash'} #!/bin/sh echo 'Hello World!' To this {:lang='bash'} {% include program-w32-build-100.sh %} The include inserts the text from the file, and the lang='bash' is supposed…
Steven Penny
  • 82,115
  • 47
  • 308
  • 348
1
vote
1 answer

How to integrate redcloth with coderay

I want to use syntax highlighting along with redcloth. The description of coderay says: Fast and easy syntax highlighting for selected languages, written in Ruby. Comes with RedCloth integration and LOC counter. 1 But I did not find a…
Mark
  • 7,137
  • 11
  • 49
  • 83
1
2 3