1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/content/github/writing-on-github/creating-and-highlighting-code-blocks.md
Ethan Palm 18c71b152b Language support across GitHub products (#18677)
* Update content

* Create github-language-support.md

* Add reminder HTML comments

* Add link to supported languages article

* Add intro for GitHub's products

* Add note to list of CodeQL supported languages

* table with package managers

* Update table and add conceptual info

* Versioning to fix broken links

* Fix table layout

* Add package managers to table

* Fix versioning syntax

* Incorporate reviewer feedback

* Center table headers

* Update Dependabot features in table

* Add footnote for third-party code scanning support

* Update link

* support native markdown table alignments

* Update links for ghes2.22

* Use proper names of package managers

* Add Scala

* Adjust conceptual info

* Flip table axes

* Delete unused reusables

* Update link to Packages info

* fix merge conflict

* fix other merge conflict

* Update codeql-languages-bullets.md

* Revert "Update codeql-languages-bullets.md"

This reverts commit 69547205f5e43a8fbf3edc51c89f0f647eef285a.

* Update article topic to sentence case

Co-authored-by: Sarah Schneider <sarahs@github.com>
2021-05-10 12:35:34 -04:00

2.0 KiB

title, intro, redirect_from, versions
title intro redirect_from versions
Creating and highlighting code blocks Share samples of code with fenced code blocks and enabling syntax highlighting.
/articles/creating-and-highlighting-code-blocks
free-pro-team enterprise-server github-ae
* * *

Fenced code blocks

You can create fenced code blocks by placing triple backticks ``` before and after the code block. We recommend placing a blank line before and after code blocks to make the raw formatting easier to read.

```
function test() {
  console.log("notice the blank line before this function?");
}
```

Rendered fenced code block

{% tip %}

Tip: To preserve your formatting within a list, make sure to indent non-fenced code blocks by eight spaces.

{% endtip %}

Syntax highlighting

You can add an optional language identifier to enable syntax highlighting in your fenced code block.

For example, to syntax highlight Ruby code:

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

Rendered code block with Ruby syntax highlighting

We use Linguist to perform language detection and to select third-party grammars for syntax highlighting. You can find out which keywords are valid in the languages YAML file.

Further reading