Documentation

Zend_Markup Parsers - Zend_Markup

Zend_Markup Parsers

Zend_Markup is currently shipped with one parser, a BBCode parser.

Theory of Parsing

The parsers of Zend_Markup are classes that convert text with markup to a token tree. Although we are using the BBCode parser as example here, the idea of the token tree remains the same across all parsers. We will start with this piece of BBCode for example:

  1. [b]foo[i]bar[/i][/b]baz

Then the BBCode parser will take that value, tear it apart and create the following tree:

  • [b]

    • foo

    • [i]

      • bar

  • baz

You will notice that the closing tags are gone, they don't show up as content in the tree structure. This is because the closing tag isn't part of the actual content. Although, this does not mean that the closing tag is just lost, it is stored inside the tag information for the tag itself. Also, please note that this is just a simplified view of the tree itself. The actual tree contains a lot more information, like the tag's attributes and its name.

The BBCode parser

The BBCode parser is a Zend_Markup parser that converts BBCode to a token tree. The syntax of all BBCode tags is:

  1. [name(=(value|"value"))( attribute=(value|"value"))*]

Some examples of valid BBCode tags are:

  1. [b]
  2. [list=1]
  3. [code file=Zend/Markup.php]
  4. [url="http://framework.zend.com/" title="Zend Framework!"]

By default, all tags are closed by using the format '[/tagname]'.

Copyright

© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts