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
1
vote
1 answer

Preserve Whitespace with Rails, Datamapper & Coderay (Oh yeah and Haml too)

I'm trying to show syntax highlighted C code in a ruby app. Coderay seemed like the defacto solution since I'm not doing anything else special with the styling. The following code give me highlighted code in a div, but with no leading whitespace.…
Nilloc
  • 775
  • 6
  • 18
1
vote
1 answer

CodeRay adds incorrect indentation

I am using CodeRay version 1.1.1 to render a ruby file. However, it is adding a large number of extra spaces to indent all lines except the first line. As a MCVE, I have a file called something.rb with contents: # This comment will not be…
Chris Britt
  • 1,383
  • 1
  • 16
  • 35
0
votes
1 answer

Why is my pry not using coderay to make output pretty?

Why is my pry not using coderay to make output pretty? I don't get pretty awesome_print-style object/output printing... just boring irb-style one-line output. This question implies it should Just Work: How to get awesome_print to work in…
John Bachir
  • 21,401
  • 22
  • 137
  • 203
0
votes
1 answer

Can Coderay re-indent C (or C-like) code?

I've got a site that accepts input from newbie coders, and would like to re-indent code so that it is "properly" formatted. I'd be happy with re-indenting the code as it's displayed, so it could be a ruby solution, but might also be interested in a…
Nilloc
  • 775
  • 6
  • 18
0
votes
1 answer

Get line number in html by JavaScript

I've highlighted the ruby code by CodeRay and now I'd like to know on which line number user clicked. This line number should correspond to line nuber in source code. Which is the best way to do this?
megas
  • 20,057
  • 11
  • 70
  • 126
0
votes
1 answer

How to add line breaks to Redmine markdown in code highlighting?

The Redmine textile formatting guide directs us to use code highlighting like so:

  Place your code here.
And while line breaks are preserved within
 tags, once I add the , it removes…
Excel Help
  • 124
  • 9
0
votes
1 answer

How can I use RedCarpet without CodeRay to implement markdown in my blogs?

So I have patiently tried for some time to work with CodeRay gem to implement markdown in my blogs. It worked for awhile, but then it would break my blog page with a 500 error. The CodeRay.scan was identified as the culprit: class CodeRayify <…
user8359832
0
votes
1 answer

Ruby: nested regular expressions and string replace

I'm using CodeRay for syntax highlighting, but I'm having trouble with this regular expression. The text will look like this:
:::ruby
def say_hello
  puts 'hello!'
end
This part: :::ruby will tell CodeRay which language the…
Andrew
  • 196,883
  • 184
  • 487
  • 673
0
votes
2 answers

Is there a VB.NET plugin for CodeRay (or any VB.NET syntax highlighting)?

I recently set up a Redmine server for my time. Redmine's Wiki uses CodeRay for syntax highlighting. However, most of my team prefers to code in VB.NET, which CodeRay doesn't support. Are there any plugins out there that offer syntax highlighting…
Dan Tao
  • 119,009
  • 50
  • 280
  • 431
0
votes
2 answers

CodeRay style messed up - how to fix

I'm trying to use CodeRay in my project and it seems to be working, however the style and formatting seems to be messed: Note that I'm using CodeRay in conjunction with Markdown (Redcarpet). I've added both gems in my gemfile and in the…
WagnerMatosUK
  • 3,861
  • 5
  • 45
  • 84
0
votes
1 answer

How to mark search phrase in syntax highlighted markdown code?

In my rails blog app, I may author the post body markdown (I am using redcarpet for markdown parsing with CodeRay for syntax highlighting). I have a search page, which returns posts containing the search query string. I use the rails helper to…
Anand
  • 3,246
  • 4
  • 28
  • 55
0
votes
1 answer

syntax highlighting with coderay, asciidoctor not working

I have asciidoctor markdown like so, as described here http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#source-code :source-highlighter: coderay :coderay-css: class :stylesheet:…
ahnbizcad
  • 9,810
  • 9
  • 54
  • 77
0
votes
1 answer

Show syntax name for code snippets

I'm using Jekyll with Kramdown and Coderay. Is there a way to add the name of the syntax rules used to the output of the code highlighter, when using kramdown? I'd like it to look similar to what ajax-syntax-highlighter outputs. Thus showing the…
Michael Krupp
  • 1,820
  • 3
  • 17
  • 36
0
votes
1 answer

Coderay renders actual ruby code

I have RedCloth with Coderay installed to highlight my code pasted in my blog. If I paste some code like this: CodeRay.scan( "set_meta_tags :og => { :title => @blog.title, :type => 'article', :url => current_url, …
Jan
  • 4,108
  • 4
  • 35
  • 57
0
votes
1 answer

using Coderay with a html.erb file

Has anyone got any experience with using Coderay with html.erb files. I'm unsure how to use coderay with these files. I have a helper method def coderay(text) text.gsub(/\(.+?)\<\/code\>/m) do CodeRay.scan($3,…
Richlewis
  • 13,978
  • 32
  • 103
  • 238