Zend_Markup-Parsers.xml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.markup.parsers">
  4. <title>Zend_Markup Parsers</title>
  5. <para>
  6. <classname>Zend_Markup</classname> is currently shipped with one parser, a BBCode parser.
  7. </para>
  8. <sect2 id="zend.markup.parsers.theory">
  9. <title>Theory of Parsing</title>
  10. <para>
  11. The parsers of <classname>Zend_Markup</classname> are classes that convert text with
  12. markup to a token tree. Although we are using the BBCode parser as example here, the
  13. idea of the token tree remains the same across all parsers. We will start with this
  14. piece of BBCode for example:
  15. </para>
  16. <programlisting language="text"><![CDATA[
  17. [b]foo[i]bar[/i][/b]baz
  18. ]]></programlisting>
  19. <para>
  20. Then the BBCode parser will take that value, tear it apart and create the following
  21. tree:
  22. </para>
  23. <itemizedlist>
  24. <listitem>
  25. <para>[b]</para>
  26. <itemizedlist>
  27. <listitem>
  28. <para>foo</para>
  29. </listitem>
  30. <listitem>
  31. <para>[i]</para>
  32. <itemizedlist>
  33. <listitem>
  34. <para>bar</para>
  35. </listitem>
  36. </itemizedlist>
  37. </listitem>
  38. </itemizedlist>
  39. </listitem>
  40. <listitem>
  41. <para>baz</para>
  42. </listitem>
  43. </itemizedlist>
  44. <para>
  45. You will notice that the closing tags are gone, they don't show up as content in the
  46. tree structure. This is because the closing tag isn't part of the actual content.
  47. Although, this does not mean that the closing tag is just lost, it is stored inside the
  48. tag information for the tag itself. Also, please note that this is just a simplified
  49. view of the tree itself. The actual tree contains a lot more information, like the tag's
  50. attributes and its name.
  51. </para>
  52. </sect2>
  53. <sect2 id="zend.markup.parsers.bbcode">
  54. <title>The BBCode parser</title>
  55. <para>
  56. The BBCode parser is a <classname>Zend_Markup</classname> parser that converts BBCode to
  57. a token tree. The syntax of all BBCode tags is:
  58. </para>
  59. <programlisting language="text"><![CDATA[
  60. [name(=(value|"value"))( attribute=(value|"value"))*]
  61. ]]></programlisting>
  62. <para>
  63. Some examples of valid BBCode tags are:
  64. </para>
  65. <programlisting language="text"><![CDATA[
  66. [b]
  67. [list=1]
  68. [code file=Zend/Markup.php]
  69. [url="http://framework.zend.com/" title="Zend Framework!"]
  70. ]]></programlisting>
  71. <para>
  72. By default, all tags are closed by using the format '[/tagname]'.
  73. </para>
  74. </sect2>
  75. </sect1>