Inline code syntax highlighting in GitHub markdown?

GithubMarkdown

Github Problem Overview


GitHub-flavored markdown supports syntax highlighting in codeblocks. This is done by adding the name of the language next to the triple-grave codeblock markers:

```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```

Standard markdown also supports inline codeblocks by wrapping text in `single graves`. Is there any way to add syntax highlighting to these inline codeblocks?

Github Solutions


Solution 1 - Github

GitHub comments, wikis, README.md etc. use GFM, essentially CommonMark with some extensions. There it's not possible.

However, GitHub Pages uses Jekyll and by extension kramdown where you can use:

`x = 4`{:.ruby}

P.S. If you happen to use pandoc, the syntax is:

`x = 4`{.ruby}

Solution 2 - Github

I had to do

`(inline code)`{:.language-clojure .highlihgt}

for it to work, you have to add .highlight class too. That only applies to Jekyll with kramdown.

Solution 3 - Github

Yes, it is possible with Github Markdown:

I needed to do the same with an XML-structure inside a table row (in my case defined with markdown, nit html, so with | | delimitiers for the table structure)

just put the desired Style-class (in my case .language-xml) within the Structure {: }

`<xml attrib="someVal"></xml>`{:.language-xml}

this will set the style of the table cell to highlight the code according to the set style class

i guess for ruby it then will just be

{:.language-ruby}

took me over an hour to figure out, found the solution nowhere, so i thought i'd post it here if anyone stumbles upon this problem again.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHydrothermalView Question on Stackoverflow
Solution 1 - Githubmb21View Answer on Stackoverflow
Solution 2 - GithubSharasView Answer on Stackoverflow
Solution 3 - Githubnicolas gasserView Answer on Stackoverflow