GithubHelp home page GithubHelp logo

stof / knpmarkdownbundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from knplabs/knpmarkdownbundle

2.0 4.0 0.0 312 KB

Symfony2 wrapper for PHP markdown

Home Page: http://knplabs.com/

License: MIT License

PHP 100.00%

knpmarkdownbundle's Introduction

Provide markdown conversion to your Symfony2 projects.

This implementation is based on Michel Fortin work. We added PHP5 sugar, feature selection, and unit tests.

Build Status

INSTALLATION

Add the following entry to deps the run php bin/vendors install.

[KnpMarkdownBundle]
    git=http://github.com/KnpLabs/KnpMarkdownBundle.git
    target=/bundles/Knp/Bundle/MarkdownBundle

Register the bundle in app/AppKernel.php

$bundles = array(
    // ...
    new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
);

Register namespace in app/autoload.php

$loader->registerNamespaces(array(
    // ...
    'Knp'              => __DIR__.'/../vendor/bundles',
));

USAGE

// Use the service
$html = $this->container->get('markdown.parser')->transform($text);

// Use the helper
echo $view['markdown']->transform($text);

If you have enabled the twig markdown filter, you can use the following in your twig templates:

{{ my_data | markdown }}

Change the parser implementation

Create a service implementing Knp\Bundle\MarkdownBundle\ParserInterface, then configure the bundle to use it:

knp_markdown:
      parser:
              service: my.markdown.parser

This bundle comes with 4 parser services, all based on the same algorithm but providing different levels of compliance to the markdown specification:

  • markdown.parser.max // fully compliant = slower (default implementation)
  • markdown.parser.medium // expensive and uncommon features dropped
  • markdown.parser.light // expensive features dropped
  • markdown.parser.min // most features dropped = faster

For more details, see the implementations in Parser/Preset.

TEST

phpunit -c myapp vendor/bundles/Knp/Bundle/MarkdownBundle

knpmarkdownbundle's People

Contributors

benji07 avatar brikou avatar gromnan avatar herzult avatar julesbou avatar l3pp4rd avatar lwagner avatar mbontemps avatar ornicar avatar pdenis avatar stloyd avatar xaav avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.