Skip to content

Loading…

Blog should do Syntax Highlighting on specific blocks #193

Closed
robyurkowski opened this Issue · 3 comments

4 participants

@robyurkowski

If we want to increase adoption amongst programmers (our biggest evangelists), it would make sense to have an in-box solution to do some syntax highlighting in the blog module.

@simi suggested using something like this: http://google-code-prettify.googlecode.com/svn/trunk/README.html

@joemsak

In our blog, I monkey patched it to pick up this convention:

[gist:567469]

in the text and re-format it into a < script /> include of the gist... (the URLs follow the same pattern with the ID.js)

<%= @blog_post.gsub(/\[gist:(\d*)\]/,"<script src='http://gist.github.com/\1.js'></script>") %>

Would that work? Obviously we could make it more sophisticated

Otherwise, we could try to go the github way of surrounding in ```

def highlight(blog_post_body)
  to_highlight = blog_post_body.match() #=> some regex match for ```#{formatter}\n<code>\n```
  to_highlight.formatter #=> :ruby
  to_highlight.format_as(to_highlight.formatter)
end
@phiggins

I was just pointed at this client-side highlighter today: http://craig.is/making/rainbows

@parndt
Refinery member

Stale! If anyone wants to pull request please do

@parndt parndt closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.