Creating and highlighting code blocks
  • Updated on 28 Feb 2019
  • 1 minute to read
  • Contributors
  • Print
  • Share
  • Dark

Creating and highlighting code blocks

  • Print
  • Share
  • Dark

When writing technical documentation, it's often very useful to write small snippets of code. Document360 authoring editor comes with a very rich Markdown code block with support for the following languages.

Supported Languages & Formats
C#, Java, JavaScript, XML, JSON, CSS, SQL, Python, Markdown, PHP, PowerShell

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

You can specify the language shortcode after the first 3 backticks which will automatically syntax highlight the code in the specified language.

Here are some examples

C# code block ```csharp

using System;
namespace HelloWorld
    class Hello 
        static void Main() 
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");

Javascript code block ```js

function $initHighlight(block, cls) {
try {
if (\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
} catch (e) {
/* handle exception */
export $initHighlight;

XML code block ```xml

<book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <description>An in-depth look at creating applications 
      with XML.</description>

Json code block ```json

    "one": 2,
    "three": {
        "point_1": "point_2",
        "point_3": 3.4
    "list": [

PowerShell code block ```powershell

$user = Read-Host "Enter Username"
$pass = Read-Host "Enter Password" -AsSecureString

Ruby code block ```ruby

require 'redcarpet'
markdown ="Hello World!")
puts markdown.to_html

Some of the most common language codes you may want to use include:

C: c
C++: cpp, c++
C#: csharp
CSS: css
CoffeeScript: coffeescript
HTML: html
JSON: json
Java: java
JavaScript: javascript, js
Objective-C: objective-c, obj-c, objc
Objective-C++: objective-c++, obj-c++, objc++
PHP: php
Perl: perl, pl
Python 3: python3, py3
Python: python, py
Ruby: ruby, rb
Snobol: snobol
XML: xml

Longer code samples can be denoted using block notation.
Any blocks which are indented at least 4 spaces will be treated as a code block. This code will not be syntax-highlighted, but instead will be shown as plain text.

The following code block will not be syntax-highlighted. (Indentation at the beginning of the line)

def test():
    logging.error('Test failed')
Was this article helpful?