# How do I highlight Ruby code on a GitHub wiki?

**URL:** <https://www.ruby-forum.com/t/how-do-i-highlight-ruby-code-on-a-github-wiki/197486>\
**Category:** Ruby\
**Created:** [October 15, 2010, 8:26am UTC](https://www.ruby-forum.com/t/how-do-i-highlight-ruby-code-on-a-github-wiki/197486 "2010-10-15T08:26:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 15, 2010, 8:26am UTC](https://www.ruby-forum.com/t/how-do-i-highlight-ruby-code-on-a-github-wiki/197486/1 "2010-10-15T08:26:42Z")

</div>

I understand this question is a little off-topic here, but the  
documentation on [GitHub.com](http://GitHub.com) doesn’t help me.

Here’s the story:

GitHub allows one to use various markup languages when editing wiki  
pages. By default is used some modified Markdown.

We’re told to indent code blocks by 4 spaces (at least). It works  
alright.

But there’s more:

When I click the “Help” link (in the textarea) I see, under the “Code”  
section, that we can also highligh code. Cool. So I want to highlight  
the Ruby code I type into wiki pages. The example they give there isn’t  
quite clear. If I understand correctly, typing the following:

````ruby
    def foo
      puts 'bar'
    end
    ```

Should result in highlighted code. In other words, the first line should
contain 3 backticks immediately followed by the string "ruby", and the
block needs to end in 3 more backticks. It doesn't work: the code isn't
highlighted. I'm not surprised: I probably don't read the example
correctly.

So, does anybody know how to highlight Ruby code on GitHub?
````

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [October 15, 2010, 8:39am UTC](https://www.ruby-forum.com/t/how-do-i-highlight-ruby-code-on-a-github-wiki/197486/2 "2010-10-15T08:39:06Z")

</div>

Albert S. wrote in post #950349:

> So, does anybody know how to highlight Ruby code on GitHub?

Hurrey!!! I’ve found the answer!!!

It turns out that the last 3 backquotes must not be indented. Then  
everything works alright. The example they give (where they’re indented)  
is wrong.

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [October 15, 2010, 8:45am UTC](https://www.ruby-forum.com/t/how-do-i-highlight-ruby-code-on-a-github-wiki/197486/3 "2010-10-15T08:45:44Z")

</div>

Albert S. wrote in post #950351:

> Albert S. wrote in post #950349:
> 
> > So, does anybody know how to highlight Ruby code on GitHub?
> 
> Hurrey!!! I’ve found the answer!!!

Well, it seems I still have a problem:

I actually want to highlight code I put in a “README.markdown” file. I  
don’t care about the wiki. Anybody knows if it’s possible to highlight  
in README.markdown?

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [October 15, 2010, 10:48am UTC](https://www.ruby-forum.com/t/how-do-i-highlight-ruby-code-on-a-github-wiki/197486/4 "2010-10-15T10:48:25Z")

</div>

On Fri, Oct 15, 2010 at 1:46 AM, Albert S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> don’t care about the wiki. Anybody knows if it’s possible to highlight  
> in README.markdown?
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

I don’t think you can, it looks like they are handled completely  
differently. Code in readmes looks like it is a ` tag inside a`

`
tag. Code with language specific highlights such as what they show on a 
file
in your project, looks like it is parsed and marked up for the css to
highlight, with tags around each highlight "type"

Anyway, it looks like this is the gem they use to process readmes
http://github.com/github/markup
You could look at the the gems it, farms out to, see if any of them 
offer
better support, possibly change your readme format to accommodate that 
(if
you find out, post how you did it).`
