Beispiel #1
0
 /**
  * Strip plugin definition from text,
  * stores the plugin-ID and params in hash references.
  */
 protected function stripLinkDefinitions($text)
 {
     $less_than_tab = $this->tab_width - 1;
     // First, catch the multi line YAML params
     //
     // [id]: plugin-name
     // ------
     // foo: bar
     // hoge: fuga
     // ------
     $text = preg_replace_callback('{
                         (?:\\A|\\n)
                         [ ]{0,' . $less_than_tab . '}\\[([^\\n]+?)\\][ ]?:    # id = $1
                           [ ]*
                           \\n?                # maybe *one* newline
                           [ ]*
                           (?:
                             (\\S+?)            # plugin-name = $2
                           )
                           [ ]*
                           \\n                # *one* newline
                             (-{3,})             # delimiter line = $3
                             [ ]*
                           \\n
                             ([\\w\\W]*)               # YAML structure = $4
                           \\n
                             \\3
                             [ ]*
                           (\\n|\\z)
         }x', array($this, '_stripPluginYamlDefinitions_callback'), $text);
     // Second, strip link definitions
     $text = parent::stripLinkDefinitions($text);
     // Last, strip normal plugin definitions
     // Link defs are in the form: ^[id]: plugin-name params, params, params ...
     // must have one more params
     $text = preg_replace_callback('{
                         ^[ ]{0,' . $less_than_tab . '}\\[(.+)\\][ ]?:    # id = $1
                           [ ]*
                           \\n?                # maybe *one* newline
                           [ ]*
                         (?:
                           (\\S+?)            # plugin-name = $2
                         )
                           [ ]*
                           \\n?                # maybe one newline
                           [ ]*
                         (?:
                             (?<=\\s)            # lookbehind for whitespace
                             (.*?)            # params = $3
                             [ ]*
                         )    # params is required
                         (?:\\n+|\\Z)
         }xm', array(&$this, '_stripPluginDefinitions_callback'), $text);
     return $text;
 }