Introdução ao Zend Framework

 Conhecendo o Zend Framework


 Referência do Zend Framework

  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Translation 12.2% Update 2011-11-16 - Revision 24447 - Version ZF 1.11.x

    46.3. Zend_Markup Parsers

    Zend_Markup is currently shipped with two parsers, a BBCode parser and a Textile parser.

    46.3.1. 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:


    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.

    46.3.2. 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:

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

    Some examples of valid BBCode tags are:

    code file=Zend/Markup.php]
    url="" title="Zend Framework!"]

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

    46.3.3. The Textile parser

    The Textile parser is a Zend_Markup parser that converts Textile to a token tree. Because Textile doesn't have a tag structure, the following is a list of example tags:

    Tabela 46.1. List of basic Textile tags

    Sample input Sample output
    *foo* <strong>foo</strong>
    _foo_ <em>foo</em>
    ??foo?? <cite>foo</cite>
    -foo- <del>foo</del>
    +foo+ <ins>foo</ins>
    ^foo^ <sup>foo</sup>
    ~foo~ <sub>foo</sub>
    %foo% <span>foo</span>
    PHP(PHP Hypertext Preprocessor) <acronym title="PHP Hypertext Preprocessor">PHP</acronym>
    "Zend Framework": <a href="">Zend Framework</a>
    h1. foobar <h1>foobar</h1>
    h6. foobar <h6>foobar</h6>
    !! <img src="" />

    Also, the Textile parser wraps all tags into paragraphs; a paragraph ends with two newlines, and if there are more tags, a new paragraph will be added. Lists

    The Textile parser also supports two types of lists. The numeric type, using the "#" character and bullit-lists using the "*" character. An example of both lists:

    # Item 1
    # Item 2

    Item 1
    Item 2

    The above will generate two lists: the first, numbered; and the second, bulleted. Inside list items, you can use normal tags like strong (*), and emphasized (_). Tags that need to start on a new line (like 'h1' etc.) cannot be used inside lists.

    digg delicious meneame google twitter technorati facebook