Zend_Markup Renderers
Zend_Markup is currently shipped with one renderer, the
HTML renderer.
Adding your own markups
By adding your own markups, you can add your own functionality to the
Zend_Markup renderers. With the markup structure, you can add
about any functionality you want. From simple markups, to complicated markup structures.
A simple example for a 'foo' markup:
addMarkup(
'foo',
Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE,
array(
'start' => '-bar-',
'end' => '-baz-',
'group' => 'inline'
)
);
// now, this will output: 'my -bar-markup-baz-'
echo $bbcode->render('my [foo]markup[/foo]');
]]>
Please note that creating your own markups only makes sense when your parser also
supports it with a markup structure. Currently, only BBCode supports this.
Some renderers (like the HTML renderer) also have support for a
'markup' parameter. This replaces the 'start' and 'end' parameters, and
it renders the markups including some default attributes and the
closing markup.
Add a callback markup
By adding a callback markup, you can do a lot more then just a
simple replace of the markups. For instance, you can change the
contents, use the parameters to influence the output etc.
A callback is a class that implements the
Zend_Markup_Renderer_TokenInterface
interface. An example of a callback class:
Now you can add the 'upper' markup, with as callback, an instance
of the My_Markup_Renderer_Html_Upper
class. A simple example:
addMarkup(
'upper',
Zend_Markup_Renderer_RendererAbstract::TYPE_CALLBACK,
array(
'callback' => new My_Markup_Renderer_Html_Upper(),
'group' => 'inline'
)
);
// now, this will output: 'my !up!MARKUP!up!'
echo $bbcode->render('my [upper]markup[/upper]');
]]>
List of markups
List of markups
Sample input (bbcode)
Sample output
[b]foo[/b]
foo]]>
[i]foo[/i]
foo]]>
[cite]foo[/cite]
foo]]>
[del]foo[/del]
foo]]>
[ins]foo[/ins]
foo]]>
[sup]foo[/sup]
foo]]>
[sub]foo[/sub]
foo]]>
[span]foo[/span]
foo]]>
[acronym title="PHP Hypertext Preprocessor]PHP[/acronym]
PHP]]>
[url=http://framework.zend.com/]Zend Framework[/url]
Zend Framework]]>
[h1]foobar[/h1]
foobar]]>
[img]http://framework.zend.com/images/logo.gif[/img]
]]>