php-sundown is just simple wrapper of https://github.com/vmg/sundown.
PHP License
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Author: Shuhei Tanuma
PHP5.3 higher
git clone https://github.com/chobie/php-sundown.git php-sundown --recursive
cd php-sundown
phpize
./configure
make
make install
# please add following line to your php.ini
# extension=sundown.so
Note for Windows users: sundown/src/buffer.h conflicts declarations. please apply buffer_win32_compat.patch
by hand.
rake test:conformance
php-sundown has two styles: basic and advance.
basic: simple, fast rendering. advance: customize your own markdown render, little bit slower than basic.
make a basic Sundown instance with specified string and config.
str: you want parse and render as markdown html. config: sundown parser options
\Sundown: sundown instance
<?php
$sd = new Sundown("Hello World");
$sd->to_html();
parse text as markdown and returns rendered html.
string: rendered html
<?php
$sd = new Sundown("Hello World");
echo $sd->toHTML();
parse text as markdown and only returns toc parts.
string: rendered html
<?php
$sd = new Sundown("Hello World");
echo $sd->toTOC();
make a advance Sundown instance with specified render and config.
$render: it inherits Sundown\Render\Base class. also class name accepts. $config: sundown parser option.
\Sundown\Markdown:
<?php
$md = new \Sundown\Markdown(\Sundown\Render\HTML);
echo $md->render("Hello World");
parse and render specified string.
$str: parse and render as markdown text.
mixed: rendered something. (this depends render)
<?php
$render = new \Sundown\Render\HTML();
$md = new \Sundown\Markdown($render);
echo $md->render("Hello World");n
get current extensions.
- array
<?php
$md = new \Sundown\Markdown(\Sundown\Render\HTML,array("autolink"=>true));
$extensions = $md->getExtensions();
var_dump($extensions);
set extensions.
$extensions: extensions array.
- void
<?php
$md = new \Sundown\Markdown(\Sundown\Render\HTML,array("autolink"=>true));
$md->setExtensions(array("autolink"=>false));
var_dump($md->getExtensions());
get current render instance.
- Sundown\Render\Base
<?php
$md = new \Sundown\Markdown(\Sundown\Render\HTML,array("autolink"=>true));
$md->getRender()->setRenderFlags(array("filter_html"=>true));
set render instance.
render: render instance
- void
<?php
$md = new \Sundown\Markdown(\Sundown\Render\HTML,array("autolink"=>true));
$render2 = \Sundown\Render\HTML();
$md->setRender($render2);
documented at Render.md
documented at ExtensionsAndRenderFlags.md