How do I highlight Ruby code on a GitHub wiki?

I understand this question is a little off-topic here, but the
documentation on 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:

    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?

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.

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?

On Fri, Oct 15, 2010 at 1:46 AM, Albert S.
[email protected]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/.

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).

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs