Adds a field and a data type that allows for Markdown editing, uses the github api to render the html

Installs: 6 408

Dependents: 1

Suggesters: 0

Security: 0

Stars: 12

Watchers: 2

Forks: 5


2.0.1 2019-05-31 16:17 UTC

This package is auto-updated.

Last update: 2024-05-29 02:35:33 UTC


Adds a field and a data type that allows for Markdown editing, uses a supported renderer (default is the GitHub API) to render the HTML.


  • SilverStripe 4.x
  • PHP cURL Support


  • Install with composer: composer require undefinedoffset/silverstripe-markdown ^2.0
  • Run dev/build?flush=all to regenerate the manifest


Use the Markdown data type as your fields data type, then use the MarkdownEditor field in the cms for editing.

Page class

use UndefinedOffset\Markdown\Forms\MarkdownEditor;

class MyPage extends Page
    public static $db = array(
        'MarkdownContent' => 'Markdown'
    public function getCMSFields()
        $fields = parent::getCMSFields();
        $editor = new MarkdownEditor('MarkdownContent', 'Page Content (Markdown)');
        $editor->setRows(15); //optional, set number of rows in CMS
        $editor->setWrapMode(true); //optional, turn on word wrapping
        $fields->addFieldToTab('Root.Main', $editor);
        return $fields;


<div class="content">
    $MarkdownContent  <!-- Will show as rendered HTML -->

You may also request the markdown using Github Flavored Markdown by calling $YourField.AsHTML(true) in your template by default Github Flavored Markdown is not used just regular Markdown is used.

<div class="content">
    $MarkdownContent.AsHTML(true)  <!-- Will render the content using Github Flavoured Markdown -->


The default renderer is the GitHub renderer. However, other renderers are supported.

To set what renderer to use, in _config.php do the following:

use UndefinedOffset\Markdown\Model\FieldTypes\Markdown;

// Fully qualified (namespaced) class name of any implementation of IMarkdownRenderer will work:


The following options are available on the default GithubMarkdownRenderer:

use UndefinedOffset\Markdown\Renderer\GitHubMarkdownRenderer;

// authenticate to the Github API to get 5,000 requests per hour instead of 60
GithubMarkdownRenderer::useBasicAuth('github username', 'github password'); 
// whether or not to use Github Flavoured Markdown


PHPMarkdownMarkdownRenderer is simple and has no options. Use this to avoid the delay on page load the first time after editing that comes from using the Github renderer (especially if the page has many sections of markdown). You will need to install PHP Markdown for this to work - it can be installed with composer.

Note: This renderer does not support Github Flavoured Markdown.

use UndefinedOffset\Markdown\Model\FieldTypes\Markdown;