Sometimes, programming blogs or repositories such as Github and bitbucket need to display programming code to preview code and with nice color formatting styles.

code can be java,json, CSS or HTML, or python.

Markdown code fenced blocks

Markdown has support for code fence blocks as part of the native build.

Code block always starts with three backticks ````codetype` in a new line end with three backticks in a new line.

Here is an example for code blocks syntax

This is an example of markdown code fence blocks.

codetype is an optional language name and uses to highlight code syntax colors for given code.

Markdown only supports code fence blocks but no support code type natively.

Many engines such as Github and bitbucket supports code type for beautiful syntax color highlight. Here is an example code fence block

example markdown code fenced blocks.

Renders on the web page

example markdown code fenced blocks.

It generates following html

<div class="highlight">
    <pre tabindex="0" class="chroma">
        <code class="language-fallback" data-lang="fallback">
            example markdown code fence blocks.

markdown syntax highlight code

Codetype is used to highlight the source code with formatting and syntax colors.

It supports the following code languages.

codetype Language
javascript,ecmascript,js,jsx,node javascript
html html
console, shell Shell programming
bash,sh,zsh bash commands programming
dos,cmd,bat DOS commands and programming
ps, powershell powershell commands programming
properties properties files
python python language
xml xml,xslt
json json content
yaml,yml yaml content
toml toml
php php code
cs C#, .net code
rs,rust Rust programming code
swift Swift programming
ts,typescript Typescript program code
scala Scala
jsx React
R R programming
objectivec,objc Objective C
lua Lua
julia,jl Julia
ocaml,ml OCaml
pl,perl Perl

Example for display C# code in markdown

Console.WriteLine("Markdown fenced code example");

Render on page

Console.WriteLine("Markdown fenced code example");

Generates html

<code class="language-cs" data-lang="cs">
    <span class="n">Console</span>
    <span class="p">.</span>
    <span class="n">WriteLine</span>
    <span class="p">(</span>
        <span class="s">
            "Markdown fenced code example"
        <span class="p">);</span>