GitHub Flavored Markdown editing & rendering using Parsedown for SilverStripe
JavaScript PHP CSS
Latest commit a7162eb Jan 30, 2017 @axllent Fix path
Permalink
Failed to load latest commit information.
_config
css
javascript
src
thirdparty/ace
.editorconfig
.gitattributes
.gitignore
.scrutinizer.yml
.upgrade.yml
LICENSE
README.md
composer.json

README.md

Github Flavoured Markdown for SilverStripe 4

This module adds a field and a data type that allows for Markdown editing in the CMS using the Github Flavoured Markdown parser Parsedown to render the html.

It is integrated with the Ace editor for CMS editing.

Silverstripe-gfmarkdown is strongly based on silverstripe-markdown.

Requirements

  • SilverStripe 4.x

Installation

composer require axllent/silverstripe-gfmarkdown

Usage

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

Page class:

use Page;
use Axllent\Gfmarkdown\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;
    }
}

Template:

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