DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:parser

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
devel:parser [2013-03-06 15:32]
Klap-in
devel:parser [2016-05-08 06:52] (current)
84.142.137.15 [Renderer] correct link to Wikipedia
Line 74: Line 74:
 === The Lexer API === === The Lexer API ===
  
-A short introduction to the Lexer can be found at [[http://www.phppatterns.com/index.php/article/articleview/106/1/2/|Simple Test Lexer Notes]]. This provides more detail.+A short introduction to the Lexer can be found at [[http://web.archive.org/web/20070814083008/http://www.phppatterns.com/docs/develop/simple_test_lexer_notes|Simple Test Lexer Notes]]. This provides more detail.
  
 The key methods in the Lexer are; The key methods in the Lexer are;
Line 173: Line 173:
 The entry pattern checks it can find a closing ''%%</file>%%'' tag before it enters the state. The entry pattern checks it can find a closing ''%%</file>%%'' tag before it enters the state.
  
-**Note** the use of hex characters in the lookahead is required because there's (probably) a bug in the Lexer hack to make lookaheads possible. Needs investigation. 
  
  
Line 904: Line 903:
 It is used to document the Renderer although it could be also be extended if you wanted to write a Renderer which only captures certain calls. It is used to document the Renderer although it could be also be extended if you wanted to write a Renderer which only captures certain calls.
  
-The basic principle for how the instructions, returned from the parser, are used against a Renderer is similar to the notion of a [[wp>SAX XML API]] - the instructions are a list of function / method names and their arguments. Looping through the list of instructions, each instruction can be called against the Renderer (i.e. the methods provided by the Renderer are [[wp>Callback_(computer_science)|callbacks]]). Unlike the SAX API, where only a few, fairly general, callbacks are available (e.g. tag_start, tag_end, cdata etc.), the Renderer defines a more explicit API, where the methods typically correspond one-to-one with the act of generating the output.+The basic principle for how the instructions, returned from the parser, are used against a Renderer is similar to the notion of a [[wp>Simple_API_for_XML|SAX XML API]] - the instructions are a list of function / method names and their arguments. Looping through the list of instructions, each instruction can be called against the Renderer (i.e. the methods provided by the Renderer are [[wp>Callback_(computer_science)|callbacks]]). Unlike the SAX API, where only a few, fairly general, callbacks are available (e.g. tag_start, tag_end, cdata etc.), the Renderer defines a more explicit API, where the methods typically correspond one-to-one with the act of generating the output.
 In the section of the Renderer shown above, the ''p_open'' and ''p_close'' methods would be used to output the tags ''%%<p>%%'' and ''%%</p>%%'' in XHTML, respectively, while the ''header'' function takes two arguments - some text to display and the "level" of the header so a call like ''%%header('Some Title',1)%%'' would be output in XHTML like ''%%<h1>Some Title</h1>%%''. In the section of the Renderer shown above, the ''p_open'' and ''p_close'' methods would be used to output the tags ''%%<p>%%'' and ''%%</p>%%'' in XHTML, respectively, while the ''header'' function takes two arguments - some text to display and the "level" of the header so a call like ''%%header('Some Title',1)%%'' would be output in XHTML like ''%%<h1>Some Title</h1>%%''.
  
Line 994: Line 993:
 ==== Basic Invocation ==== ==== Basic Invocation ====
  
-To invoke the parser will //all// current modes, and parse the DokuWiki syntax document;+To invoke the parser with //all// current modes, and parse the DokuWiki syntax document;
  
 <code php> <code php>
Line 2293: Line 2292:
  
 Even if the parser not understand and corrects all the html-rules, the parser wold be more stable and produces more accurate code. It only have to correct the "p" "table" and simple "b i u ..." behavior correctly and it would be a useful improvement.\\ Even if the parser not understand and corrects all the html-rules, the parser wold be more stable and produces more accurate code. It only have to correct the "p" "table" and simple "b i u ..." behavior correctly and it would be a useful improvement.\\
- 
devel/parser.1362580355.txt.gz · Last modified: 2013-03-06 15:32 (external edit)