Giter VIP home page Giter VIP logo

markup_parsers's Introduction

Markup Parsers Plugin for CakePHP

This plugin offers a solution for working with different type of markup for you application. It offers both some markup parser implementations and a parser factory responsible for registering available parser classes and returning instances of them.

It provides three different markup implementations:

BBcode Parser

Supports the [b], [p], [u], [s], [sub], [sup]. [indent], [img], [color], [code], [color], [size], [font]. [align], [quote], [h1] ... [h6], [table] and it's associated [tr], [th] and [td], [list], [ulist] and [li]. It can also link emails and urls using the [url] tag

This parser will also split the passed string in pages, using the [Page separator] marker as separator.

Markdown Parser

Supports regular markdown syntax with a few exceptions and additions:

* reference style links are not supported, only inline links work.
* Setext style headers are not supported, only ATX style headers work.
* Block quotes are not implemented at this time.

As this class was original intended to parse functions doc blocks, it has some additional syntax items:

* Class::method() links. These are links to other class + methods in your code base.
* Class::$property links. These are links to other class properties in your code base.
* Code blocks - Code blocks can be indicated with either {{{ code }}} or @@@ code @@@ or indented.

Html

The simplest of all parsers, it just adds some sugar to split a HTML string into multiple pages, and strip some dangerous content.

This parser splits the input string in multiple pages using the <!--Page Separator--> marker as separator

The ParserRegistry Class##

Every parser needs to be configured so they can be instantiated by the helper using the ParserRegistry class. To configure the parsers your are going to use in tour app put use the Configure class to list them.

    Configure::write('Parsers.markdown' => array(
		'name' => 'Markdown',
		'class' => array('MarkdownParser', 'MarkupParsers.Parser'), 
	));

If you have your own parser implementation you can list it to into the array this way:

    Configure::write('Parsers.my_parser' => array(
	    'name' => 'MyParser',
	    'class' => array('MyParser', 'MyPlugin.Parser'),
    ));

Writing a parser

You can develop your own parser or extend the shipped ones for your specific needs. A Parser class must be a Library implementing the ParserInterface shipped as a plugin lib.

Here is a simple Parser example:

App::uses('ParserInterface', 'MarkupParsers.Lib');
class FoobarParser implements ParserInterface {
	public function parse($string, $options = array()) {
		return str_replace('foo', 'bar', $string);
	}
}

Then you can access it from the ParserRegistry after configuring it as detailed previously.

Using the helper

To use any parser in your views just include the Parser helper into the $helpers array in your controller:

    public $helpers = array('MarkupParsers.Parser');

And in your views

    echo $this->Parser->parse($string, 'my_parser'); // the second parameter can be left blank ad will use 'markdown' as default

Requirements

  • PHP version: PHP 5.2+
  • CakePHP version: Cakephp 2.x Stable

Support

For support and feature request, please visit the Markup Parsers Plugin Support Site.

For more information about our Professional CakePHP Services please visit the Cake Development Corporation website.

Branch strategy

The master branch holds the STABLE latest version of the plugin. Develop branch is UNSTABLE and used to test new features before releasing them.

Previous maintenance versions are named after the CakePHP compatible version, for example, branch 1.3 is the maintenance version compatible with CakePHP 1.3. All versions are updated with security patches.

Contributing to this Plugin

Please feel free to contribute to the plugin with new issues, requests, unit tests and code fixes or new features. If you want to contribute some code, create a feature branch from develop, and send us your pull request. Unit tests for new features and issues detected are mandatory to keep quality high.

License

Copyright 2009-2012, Cake Development Corporation

Licensed under The MIT License
Redistributions of files must retain the above copyright notice.

Copyright

Copyright 2009-2012
Cake Development Corporation
1785 E. Sahara Avenue, Suite 490-423
Las Vegas, Nevada 89104
http://cakedc.com

markup_parsers's People

Contributors

ajibarra avatar lorenzo avatar predominant avatar real34 avatar renan avatar skie avatar steinkel avatar vitorpacheco avatar yeliparra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.