示例#1
0
 /**
  * Parse microblog
  *
  * @param string $text
  * @return string
  */
 public function parse($text)
 {
     Debugbar::startMeasure('parsing', 'Time for parsing');
     $parser = new Parser();
     $text = $parser->cache($text, function ($parser) {
         $parser->attach((new SimpleMarkdown($this->user))->setBreaksEnabled(true));
         $parser->attach((new Purifier())->set('HTML.Allowed', 'br,b,strong,i,em,a[href|title|data-user-id],code'));
         $parser->attach(new Link());
         $parser->attach(new Censore($this->word));
     });
     if (auth()->check() && auth()->user()->allow_smilies) {
         $parser->attach(new Smilies());
     }
     $text = $parser->parse($text);
     Debugbar::stopMeasure('parsing');
     return $text;
 }
示例#2
0
 /**
  * Parse microblog
  *
  * @param string $text
  * @return string
  */
 public function parse($text)
 {
     Debugbar::startMeasure('parsing', 'Time for parsing');
     $parser = new Parser();
     $parser->setEnableCache(false);
     $text = $parser->cache($text, function ($parser) {
         $parser->attach((new Markdown($this->user))->setBreaksEnabled(true));
         $parser->attach(new Purifier());
         $parser->attach(new Link());
         $parser->attach(new Geshi());
     });
     if (auth()->check() && auth()->user()->allow_smilies) {
         $parser->attach(new Smilies());
     }
     $text = $parser->parse($text);
     Debugbar::stopMeasure('parsing');
     return $text;
 }