PHPackages                             kzykhys/ciconia - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. kzykhys/ciconia

ActiveLibrary[CLI &amp; Console](/categories/cli)

kzykhys/ciconia
===============

The Markdown parser for PHP5.4

v1.0.3(12y ago)35366.7k28[11 issues](https://github.com/kzykhys/Ciconia/issues)[4 PRs](https://github.com/kzykhys/Ciconia/pulls)13MITPHPPHP &gt;5.4.0

Since Aug 2Pushed 10y ago16 watchersCompare

[ Source](https://github.com/kzykhys/Ciconia)[ Packagist](https://packagist.org/packages/kzykhys/ciconia)[ RSS](/packages/kzykhys-ciconia/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (13)

Ciconia - A New Markdown Parser for PHP
=======================================

[](#ciconia---a-new-markdown-parser-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/13a6591f1cf260c26fbb060e70c18c78578d309febdc1b9ca69e0bcc10eb50df/68747470733a2f2f706f7365722e707567782e6f72672f6b7a796b6879732f6369636f6e69612f762f737461626c652e706e67)](https://packagist.org/packages/kzykhys/ciconia)[![Build Status](https://camo.githubusercontent.com/681a07810695a607adb62c14faacb0431e1717a8f22bcb562f8ee9e2b51ae372/68747470733a2f2f7472617669732d63692e6f72672f6b7a796b6879732f4369636f6e69612e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/kzykhys/Ciconia)[![Coverage Status](https://camo.githubusercontent.com/31d6fc51df13811e3614193e465390b84f36dc85fc921a818c4789d233c58b38/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6b7a796b6879732f4369636f6e69612f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/kzykhys/Ciconia?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/d320302b24e97f0fe96eab8af0393cc86c7796a6734bca7c3c5587eb188456fa/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f64306361376162372d633334322d346630342d386636372d6237643734633266646236362f6d696e692e706e67)](https://insight.sensiolabs.com/projects/d0ca7ab7-c342-4f04-8f67-b7d74c2fdb66)

The Markdown parser for PHP5.4, it is fully extensible. Ciconia is the collection of extension, so you can replace, add or remove each parsing mechanism.

[**Try Demo**](http://ciconia.kzykhys.com/) / [**Docs**](http://ciconia.kzykhys.com/docs/) / [**Supported Syntax**](http://ciconia.kzykhys.com/syntax.html) / [**API Reference**](http://ciconia.kzykhys.com/api/)

- Based on John Gruber's Markdown.pl
- [Github Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) support (disabled by default)

    - Multiple underscores in words
    - New lines
    - Fenced code blocks
    - Task lists
    - Table
    - URL Autolinking
- Tested with [karlcow/markdown-testsuite](https://github.com/karlcow/markdown-testsuite)

Requirements
------------

[](#requirements)

- PHP5.4+
- Composer

Installation
------------

[](#installation)

create a `composer.json`

```
{
    "require": {
        "kzykhys/ciconia": "~1.0.0"
    }
}
```

and run

```
php composer.phar install

```

Usage
-----

[](#usage)

### Traditional Markdown

[](#traditional-markdown)

```
use Ciconia\Ciconia;

$ciconia = new Ciconia();
$html = $ciconia->render('Markdown is **awesome**');

// Markdown is awesome
```

### Github Flavored Markdown

[](#github-flavored-markdown)

To activate 6 gfm features:

```
use Ciconia\Ciconia;
use Ciconia\Extension\Gfm;

$ciconia = new Ciconia();
$ciconia->addExtension(new Gfm\FencedCodeBlockExtension());
$ciconia->addExtension(new Gfm\TaskListExtension());
$ciconia->addExtension(new Gfm\InlineStyleExtension());
$ciconia->addExtension(new Gfm\WhiteSpaceExtension());
$ciconia->addExtension(new Gfm\TableExtension());
$ciconia->addExtension(new Gfm\UrlAutoLinkExtension());

$html = $ciconia->render('Markdown is **awesome**');

// Markdown is awesome
```

### Options

[](#options)

OptionTypeDefaultDescription**tabWidth**integer4Number of spaces**nestedTagLevel**integer3Max depth of nested HTML tags**strict**booleanfalseThrows exception if markdown contains syntax error```
use Ciconia\Ciconia;

$ciconia = new Ciconia();
$html = $ciconia->render(
    'Markdown is **awesome**',
    ['tabWidth' => 8, 'nestedTagLevel' => 5, 'strict' => true]
);
```

Rendering HTML or XHTML
-----------------------

[](#rendering-html-or-xhtml)

Ciconia renders HTML by default. If you prefer XHTML:

```
use Ciconia\Ciconia;
use Ciconia\Renderer\XhtmlRenderer;

$ciconia = new Ciconia(new XhtmlRenderer());
$html = $ciconia->render('Markdown is **awesome**');

// Markdown is awesome
```

Extend Ciconia
--------------

[](#extend-ciconia)

### How to Extend

[](#how-to-extend)

Creating extension is easy, just implement `Ciconia\Extension\ExtensionInterface`.

Your class must implement 2 methods.

#### *void* register(`Ciconia\Markdown` $markdown)

[](#void-registerciconiamarkdown-markdown)

Register your callback to markdown event manager. `Ciconia\Markdown` is instance of `Ciconia\Event\EmitterInterface` (looks like Node.js's EventEmitter)

#### *string* getName()

[](#string-getname)

Returns the name of your extension. If your name is the same as one of core extension, it will be replaced by your extension.

### Extension Example

[](#extension-example)

This sample extension turns `@username ` mentions into links.

```
