1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.markup.parsers">
4 <title>Zend_Markup Parsers</title>
7 <classname>Zend_Markup</classname> is currently shipped with two parsers, a BBCode parser
11 <sect2 id="zend.markup.parsers.theory">
12 <title>Theory of Parsing</title>
15 The parsers of <classname>Zend_Markup</classname> are classes that convert text with
16 markup to a token tree. Although we are using the BBCode parser as example here, the
17 idea of the token tree remains the same across all parsers. We will start with this
18 piece of BBCode for example:
21 <programlisting><![CDATA[
22 [b]foo[i]bar[/i][/b]baz
26 Then the BBCode parser will take that value, tear it apart and create the following
57 You will notice that the closing tags are gone, they don't show up as content in the
58 tree structure. This is because the closing tag isn't part of the actual content.
59 Although, this does not mean that the closing tag is just lost, it is stored inside the
60 tag information for the tag itself. Also, please note that this is just a simplified
61 view of the tree itself. The actual tree contains a lot more information, like the tag's
62 attributes and its name.
66 <sect2 id="zend.markup.parsers.bbcode">
67 <title>The BBCode parser</title>
70 The BBCode parser is a <classname>Zend_Markup</classname> parser that converts BBCode to
71 a token tree. The syntax of all BBCode tags is:
74 <programlisting language="text"><![CDATA[
75 [name(=(value|"value"))( attribute=(value|"value"))*]
79 Some examples of valid BBCode tags are:
82 <programlisting><![CDATA[
85 [code file=Zend/Markup.php]
86 [url="http://framework.zend.com/" title="Zend Framework!"]
90 By default, all tags are closed by using the format '[/tagname]'.
94 <sect2 id="zend.markup.parsers.textile">
95 <title>The Textile parser</title>
98 The Textile parser is a <classname>Zend_Markup</classname> parser that converts Textile
99 to a token tree. Because Textile doesn't have a tag structure, the following is a list
103 <table id="zend.markup.parsers.textile.tags">
104 <title>List of basic Textile tags</title>
106 <tgroup cols="2" align="left" colsep="1" rowsep="1">
109 <entry>Sample input</entry>
110 <entry>Sample output</entry>
117 <entry><![CDATA[<strong>foo</strong>]]></entry>
122 <entry><![CDATA[<em>foo</em>]]></entry>
126 <entry>??foo??</entry>
127 <entry><![CDATA[<cite>foo</cite>]]></entry>
132 <entry><![CDATA[<del>foo</del>]]></entry>
137 <entry><![CDATA[<ins>foo</ins>]]></entry>
142 <entry><![CDATA[<sup>foo</sup>]]></entry>
147 <entry><![CDATA[<sub>foo</sub>]]></entry>
152 <entry><![CDATA[<span>foo</span>]]></entry>
156 <entry>PHP(PHP Hypertext Preprocessor)</entry>
159 <![CDATA[<acronym title="PHP Hypertext Preprocessor">PHP</acronym>]]>
164 <entry>"Zend Framework":http://framework.zend.com/</entry>
167 <![CDATA[<a href="http://framework.zend.com/">Zend Framework</a>]]>
172 <entry>h1. foobar</entry>
173 <entry><![CDATA[<h1>foobar</h1>]]></entry>
177 <entry>h6. foobar</entry>
178 <entry><![CDATA[<h6>foobar</h6>]]></entry>
182 <entry>!http://framework.zend.com/images/logo.gif!</entry>
185 <![CDATA[<img src="http://framework.zend.com/images/logo.gif" />]]>
193 Also, the Textile parser wraps all tags into paragraphs; a paragraph ends with two
194 newlines, and if there are more tags, a new paragraph will be added.
197 <sect3 id="zend.markup.parsers.textile.lists">
201 The Textile parser also supports two types of lists. The numeric type, using the "#"
202 character and bullit-lists using the "*" character. An example of both lists:
205 <programlisting><![CDATA[
214 The above will generate two lists: the first, numbered; and the second, bulleted.
215 Inside list items, you can use normal tags like strong (*), and emphasized (_). Tags
216 that need to start on a new line (like 'h1' etc.) cannot be used inside lists.