Code Blocks

A Code Block preserves all text content it encapsulates and presents it exactly how it was written. Code Blocks are useful for presenting information that needs to be written explicitly, like examples of code. They can provide users with content that can be copied and used for their own purposes, too.

Syntax

Code Blocks are created by adding 4 spaces before text content. A Code Block can consist of one or more lines created in this manner.

Basics

Starting a line with 4 spaces will create a basic Code Block.

    var firstName, lastName;
Multi-Line Code Blocks

Multiple lines can be used; start all lines with at least 4 spaces.

    var firstName, lastName;
    
    firstName = "John";
    lastName = "Doe";
Space is Preserved.

Any spaces after the first 4 will be used as indentation for the content of the Code Block.

    function addTwoNumbers(num1, num2) {
      return num1 + num2;
    }
No Parsing in Code Blocks

Markdown written inside of Code Blocks will render as plain text.

    # Heading 1 in Plain Text

HTML will also render as plain text when written inside Code Blocks.

    <p>HTML in plain text</p>

Markdown++

A custom Paragraph Style can be given to a Code Block using a Markdown++ style: command on the line directly above the Code Block.

<!--style:CustomCodeBlock-->
    function addTwoNumbers(num1, num2) {
      return num1 + num2;
    }

To learn more about Markdown++ tagging, see Learning Markdown++.

ePublisher Style Information

Default Style Properties

Style Type: Paragraph
Style Name: Code Block

Property

Value

background color

#efefef

font family

Consolas

font size

11pt

margin top

6pt

margin bottom

6pt

padding top

12pt

padding right

12pt

padding bottom

12pt

padding left

12pt

overflow

auto

white space

pre

If a custom style name is assigned to a Code Block, that style name will still inherit all of the listed default style information.

Last modified date: 2025-11-07