Zend_Markup レンダラー
Zend_Markup には現在ひとつのレンダラー、
HTML レンダラーが同梱されています。
自作のマークアップを追加
自作のマークアップを追加することによって、Zend_Markup レンダラーに
自作の機能の追加できます。 マークアップ構造とともに、
あなたが望むいかなる機能も追加ができます。
簡潔なマークアップから複雑なマークアップ構造まで。 'foo' マークアップでの単純な例:
addMarkup(
'foo',
Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE,
array(
'start' => '-bar-',
'end' => '-baz-',
'group' => 'inline'
)
);
// これは 'my -bar-markup-baz-' と出力されるでしょう。
echo $bbcode->render('my [foo]markup[/foo]');
]]>
あなたの作成したマークアップは、あなたのパーサーがマークアップ構造もサポートするときに
機能することに注意してください。現在、 BBCode はこれをサポートします。
Textile はカスタムマークアップをサポートしません。
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'
)
);
// これは 'my !up!MARKUP!up!' と出力されるでしょう。
echo $bbcode->render('my [upper]markup[/upper]');
]]>
マークアップ一覧
マークアップ一覧
入力例 (bbcode)
出力例
[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]
]]>