How do I highlight Ruby code on a GitHub wiki?

A

Albert Schlef

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:

```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?
 
A

Albert Schlef

Albert Schlef 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.
 
A

Albert Schlef

Albert Schlef wrote in post #950351:
Albert Schlef wrote in post #950349:

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?
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

Albert Schlef wrote in post #950351:

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?
I don't think you can, it looks like they are handled completely
differently. Code in readmes looks like it is a <code> tag inside a <pre>
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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top