public function testNames()
 {
     $handlers = new HandlerContainer();
     $this->assertEmpty($handlers->getNames());
     $handlers->add('code', function (ShortcodeInterface $s) {
     });
     $this->assertSame(array('code'), $handlers->getNames());
     $handlers->addAlias('c', 'code');
     $this->assertSame(array('code', 'c'), $handlers->getNames());
 }
 /**
  * setup the markdown parser to handle shortcodes properly
  * 
  * @param  mixed $markdown the markdown parser object
  */
 public function setupMarkdown($markdown)
 {
     $markdown->addBlockType('[', 'ShortCodes', true, false);
     $markdown->blockShortCodes = function ($Line) {
         $valid_shortcodes = implode('|', $this->handlers->getNames());
         $regex = '/^\\[\\/?(?:' . $valid_shortcodes . ')[^\\]]*\\]$/';
         if (preg_match($regex, $Line['body'], $matches)) {
             $Block = array('markup' => $Line['body']);
             return $Block;
         }
     };
 }
 public static function createFromHandlers(HandlerContainer $handlers)
 {
     return static::createFromNames($handlers->getNames());
 }
Beispiel #4
0
 /**
  * Get count from all shortcodes.
  *
  * @return int
  */
 public function count()
 {
     return count($this->handlers->getNames());
 }