Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 composer.json
Octocat-spinner-32 phpunit.xml.dist
README.md

SilexMarkdown

Build Status

SilexMarkdown provides a service provider class and twig extension to easily render markdown within Silex/Twig based projects.

The markdown renderer is based on php-markdown by Michel Fortin.

Usage

Register the service provider to your Silex application object:

<?php

require 'vendor/autoload.php';

$app = new \Silex\Application;
$app->register(new \Silex\Provider\TwigServiceProvider());
$app->register(new \SilexMarkdown\Provider\MarkdownServiceProvider());

Amplifyr

Amplifyr is REST based markdown rendering service with rich syntax highlighting capabilities. It is written in Ruby and based on Redcarpet. The syntax highlighter is based on the Python library Pygments and supports most common languages, even templating and markup languages.

Using Amplifyr is quite simple:

<?php

require 'vendor/autoload.php';

$app = new \Silex\Application;
$app->register(new \Silex\Provider\TwigServiceProvider());
$app->register(new \SilexMarkdown\Provider\MarkdownServiceProvider(), array(
    'markdown.parser' => new \SilexMarkdown\Parser\AmplifyrParser()
));

Attention! Amplifyr is a web service. If you want to render markdown on every page refresh, it would be quite slow and creates heavy load on the serves. Please cache the transformed HTML in some way. For example, my blog system CodrPress stores the transformed HTML in a separate database field only on saving a post. It's much faster this way.

Render markdown with PHP:

$app['markdown']->transform('# Headline');

Render Markdown with Twig:

{{ variable|markdown }}
Something went wrong with that request. Please try again.