Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline code syntax highlighting in GitHub markdown?

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?

like image 418
Hydrothermal Avatar asked Apr 22 '14 17:04

Hydrothermal


People also ask

How do you highlight code in Markdown?

To highlight code, write the name of the language the code is written in after the initial triple backticks. In the above example, the code is written in JavaScript, and hence javascript is added after triple backticks.

How do I highlight code in github?

To link to multiple lines of highlighted code, select your first line of code and then CTRL+SHIFT click on the last line of code you want to highlight. Notice the URL is now appended with a range of line numbers (e.g. https://github.com/…/functions.php#L117-L148).

How do you underline in Github Markdown?

Just use the HTML <u> tag (recommended) or the <ins> tag inside your markdown for this. The HTML tag <ins> is the HTML "insert tag", and is usually displayed as underlined.

How do you add a code block in Markdown?

To format a code block in Markdown, indent every line of the block by at least four spaces. An indented code block cannot interrupt a paragraph, so you must insert at least one blank line between a paragraph the indented code block that follows.


1 Answers

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} 
like image 180
mb21 Avatar answered Nov 01 '22 08:11

mb21