Table of Contents

ComboStrap - Prism

About

Prism components permits to add raw external content in the web page with extra's such as

The following component are prism component:

Example

Line numbers

HTML code in a code component with the following syntax,

<code html line-numbers="true">
    <p class="hey">Type some code here</p>
</code>

You will get this output:

    <p class="hey">Type some code here</p>

Line Highlight

This example shows an HTML code in a code component where the lines:

are highlighted

Example:

<code html line-numbers="true" line-highlight="1-3, 5">
    <p>Line 1</p>
    <p>Line 2</p>
    <p>Line 3</p>
    <p>Line 4</p>
    <p>Line 5</p>
</code>

With this markup, you will get this output:

    <p>Line 1</p>
    <p>Line 2</p>
    <p>Line 3</p>
    <p>Line 4</p>
    <p>Line 5</p>

Prompt

This example shows a bash prompt.

Example with HTML code in a code component:

<code bash prompt="#">
ls -a
</code>

With this markup, you will get this output:

ls -a

File Name

This example shows you how to defined a file name.

Example: A file block with the file name loremipsum.txt

<file txt loremipsum.txt>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</file>

With the above markup, you will get this output:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Constrained by height

prism component may contain a big content that is not completely relevant for the reading of article. In this case, you can constrained it in height

<file txt loremipsum.txt height="150px" scroll="toggle">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
Ut enim ad minim veniam, quis nostrud exercitation ullamco
Duis aute irure dolor in reprehenderit in voluptate velit esse
Excepteur sint occaecat cupidatat non proident, sunt in culp

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
Ut enim ad minim veniam, quis nostrud exercitation ullamco
Duis aute irure dolor in reprehenderit in voluptate velit esse
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</file>

Result:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
Ut enim ad minim veniam, quis nostrud exercitation ullamco
Duis aute irure dolor in reprehenderit in voluptate velit esse
Excepteur sint occaecat cupidatat non proident, sunt in culp

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
Ut enim ad minim veniam, quis nostrud exercitation ullamco
Duis aute irure dolor in reprehenderit in voluptate velit esse
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Syntax

Except from preformatted that is based on indentation, they all follows the below syntax:

<component language [file-path] line-numbers="true" prompt="$" line-highlight="x-y, z">
    .... your code
</component>

where:

Configuration

Theme

The code_theme configuration permits to choose the prism theme.

The following themes are available:

You can check them on the Prism website by clicking on the theme name in the right toolbar.

Prompt

You can define default prompt for the languages:

Windows Prompt: The prism component will add automatically a > at the end of the windows shell prompt (batch and powershell) if not present. This is not possible to pass the character > via the syntax argument because the dokuwiki parser is based on regular expression.

Note

The prism components are based on the Prism library

Supported Plugin

This component integrates the following Prism plugin:

If you want more plugin, just ask

Code Annotation

Prism does not support out of the box code annotation such as the Asciidoctor callout.

The possibilities are:

myCode # (3)

See also this prism faq entry

Support

Regex language

Dokuwiki set a group class to apply a clearfix in its all.css file. This name pollute the css global scope and competes with the output of the regex prism language that set it on the regexp group. The result is that there is a new line on all ( and ) characters.

As you can see below, this is no more the case.

^(\\w+\\s+\\d+\\s+\\d+:\\d+:\\d+)\\s+
([^@]+?)@(\\s+)\\s+(\\S+):\\s+(\\S+)\\s+(\\S+)
\\s+((?:\\S+?,\\s+)*(?:\\S+?))\\s+(\\S+)\\s+(\\S+)
\\s+\\[([^\\]]+)\\]\\s+\"(\\w+)\\s+([^\"\\\\]*
(?:\\\\.[^\"\\\\]*)*)\\s+(\\S+)\"\\s+(\\S+)\\s+
(\\S+)\\s+\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)
\"\\s+\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"\\s*
(\\d*-[\\d-]*)?\\s*(\\d+)?\\s*(\\d*\\.[\\d\\.]*)?
(\\s+[-\\w]+)?.*$