Code blocks
  • 01 May 2020
  • 1 Minute To Read
  • Print
  • Share
  • Dark
    Light

Code blocks

  • Print
  • Share
  • Dark
    Light

Document 360 uses Prisim.js for syntax highlighting, and supports syntax highlighting in code blocks for languages like:

  • HTML
  • C#
  • Java
  • JavaScript
  • XML
  • JSON
  • CSS
  • SQL
  • Python
  • Markdown
  • PHP
  • PowerShell

For a complete list supported languages, see Prisim's Supported Languages documentation.


Creating code blocks

In the Markdown editor, you can create fenced code blocks by placing triple backticks ``` before and after the included code snippet.

To apply a language's specific syntax highlighting, include the language shortcode (see list below) after the first 3 backticks.

For example:

```csharp
[your code snippet]
```

In the WYSIWYG editor, you can create a code block by clicking the code block icon and selecting your desired language.

Language shortcodes

  • 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++: objc++
  • PHP: php
  • Perl: perl, pl
  • Python 3: python3, py3
  • Python: python, py
  • Ruby: ruby, rb
  • Snobol: snobol
  • XML: xml

Indentation and code blocks

Any text indented at least 4 spaces will be treated as a code block. This is helpful for longer code snippets. This code will not be syntax-highlighted, but instead will be shown as plain text.

The following code block is created using indents instead of backticks.

def test():
    logging.error('Test failed')

Code block examples

C# block

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.");
            Console.ReadKey();
        }
    }
}

Javascript block

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

XML block

<book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications 
      with XML.</description>
   </book>

JSON block

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

PowerShell block

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

Ruby block

require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
Was This Article Helpful?