Zend_Markup-Renderers.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.markup.renderers">
  4. <title>Zend_Markup Renderers</title>
  5. <para>
  6. <classname>Zend_Markup</classname> is currently shipped with one renderer, the
  7. <acronym>HTML</acronym> renderer.
  8. </para>
  9. <sect2 id="zend.markup.renderers.add">
  10. <title>Adding your own tags</title>
  11. <para>
  12. By adding your own tags, you can add your own functionality to the
  13. <classname>Zend_Markup</classname> renderers. With the tag structure, you can add about
  14. any functionality you want. From simple tags, to complicated tag structures. A simple
  15. example for a 'foo' tag:
  16. </para>
  17. <programlisting language="php"><![CDATA[
  18. // Creates instance of Zend_Markup_Renderer_Html,
  19. // with Zend_Markup_Parser_BbCode as its parser
  20. $bbcode = Zend_Markup::factory('Bbcode');
  21. // this will create a simple 'foo' tag
  22. // The first parameter defines the tag's name.
  23. // The second parameter takes an integer that defines the tags type.
  24. // The third parameter is an array that defines other things about a
  25. // tag, like the tag's group, and (in this case) a start and end tag.
  26. $bbcode->addTag(
  27. 'foo',
  28. Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE
  29. | Zend_Markup_Renderer_RendererAbstract::TAG_NORMAL,
  30. array(
  31. 'start' => '-bar-',
  32. 'end' => '-baz-',
  33. 'group' => 'inline',
  34. )
  35. );
  36. // now, this will output: 'my -bar-tag-baz-'
  37. echo $bbcode->render('my [foo]tag[/foo]');
  38. ]]></programlisting>
  39. <para>
  40. Please note that creating your own tags only makes sense when your parser also supports
  41. it with a tag structure. Currently, only BBCode supports this. Textile doesn't have
  42. support for custom tags.
  43. </para>
  44. </sect2>
  45. <sect2 id="zend.markup.renderers.list">
  46. <title>List of tags</title>
  47. <table id="zend.markup.renderers.list.tags">
  48. <title>List of tags</title>
  49. <tgroup cols="2" align="left" colsep="1" rowsep="1">
  50. <thead>
  51. <row>
  52. <entry>Sample input (bbcode)</entry>
  53. <entry>Sample output</entry>
  54. </row>
  55. </thead>
  56. <tbody>
  57. <row>
  58. <entry>[b]foo[/b]</entry>
  59. <entry><![CDATA[<strong>foo</strong>]]></entry>
  60. </row>
  61. <row>
  62. <entry>[i]foo[/i]</entry>
  63. <entry><![CDATA[<em>foo</em>]]></entry>
  64. </row>
  65. <row>
  66. <entry>[cite]foo[/cite]</entry>
  67. <entry><![CDATA[<cite>foo</cite>]]></entry>
  68. </row>
  69. <row>
  70. <entry>[del]foo[/del]</entry>
  71. <entry><![CDATA[<del>foo</del>]]></entry>
  72. </row>
  73. <row>
  74. <entry>[ins]foo[/ins]</entry>
  75. <entry><![CDATA[<ins>foo</ins>]]></entry>
  76. </row>
  77. <row>
  78. <entry>[sup]foo[/sup]</entry>
  79. <entry><![CDATA[<sup>foo</sup>]]></entry>
  80. </row>
  81. <row>
  82. <entry>[sub]foo[/sub]</entry>
  83. <entry><![CDATA[<sub>foo</sub>]]></entry>
  84. </row>
  85. <row>
  86. <entry>[span]foo[/span]</entry>
  87. <entry><![CDATA[<span>foo</span>]]></entry>
  88. </row>
  89. <row>
  90. <entry>[acronym title="PHP Hypertext Preprocessor]PHP[/acronym]</entry>
  91. <entry><![CDATA[<acronym title="PHP Hypertext Preprocessor">PHP</acronym>]]></entry>
  92. </row>
  93. <row>
  94. <entry>[url=http://framework.zend.com/]Zend Framework[/url]</entry>
  95. <entry><![CDATA[<a href="http://framework.zend.com/">Zend Framework</a>]]></entry>
  96. </row>
  97. <row>
  98. <entry>[h1]foobar[/h1]</entry>
  99. <entry><![CDATA[<h1>foobar</h1>]]></entry>
  100. </row>
  101. <row>
  102. <entry>[img]http://framework.zend.com/images/logo.gif[/img]</entry>
  103. <entry><![CDATA[<img src="http://framework.zend.com/images/logo.gif" />]]></entry>
  104. </row>
  105. </tbody>
  106. </tgroup>
  107. </table>
  108. </sect2>
  109. </sect1>