Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about syntax highlighting with fenced code blocks #622

ajwann opened this issue Jul 16, 2017 · 1 comment

Question about syntax highlighting with fenced code blocks #622

ajwann opened this issue Jul 16, 2017 · 1 comment


Copy link

@ajwann ajwann commented Jul 16, 2017

I'm using redcarpet with the HTML renderer and :highlight => true is turned on.

When I create a code block like so:
class Foo
I don't see any syntax higlighting. I do however see in my browser that the code block was given class="ruby".

Should I be expecting to see syntax highlighting? Or does redcarpet just assign a class equal to whatever language I specified, leaving me to style the class myself?

Copy link

@robin850 robin850 commented Jul 16, 2017

Hello @ajwann,

Actually, the :highlight option allows you to write ==something== and get <mark>something</mark> once it's parsed.

Redcarpet doesn't come with syntax highlighting out of the box because people have different needs or sometimes don't need it at all. You can easily highlight code with Rouge. Once it's installed, you can do something like:

require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'

class CustomRender < Redcarpet::Render::HTML
  include Rouge::Plugins::Redcarpet

parser =, fenced_code_blocks: true)
parser.render("Your Markdown ...")

And then include a style-sheet provided by Rouge to properly show syntax highlighting on your page.

I hope this answers your question, feel free to ask if something isn't clear ! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants