Exemplo n.º 1
0
 /**
  * Parse the given content.
  *
  * Any newly created nodes should be appended to the given target. Any remaining content should be passed to the
  * next parser in the chain.
  *
  * @param Text $content
  * @param InlineNodeAcceptorInterface $target
  * @return void
  */
 public function parseInline(Text $content, InlineNodeAcceptorInterface $target)
 {
     if ($content->contains('**') || $content->contains('__')) {
         $this->parseStars($content, $target);
     } else {
         $this->next->parseInline($content, $target);
     }
 }
Exemplo n.º 2
0
 protected function parseEmail(Text $content, InlineNodeAcceptorInterface $target)
 {
     if ($content->contains('@')) {
         $content->handle('{
                 <
                 (?:mailto:)?
                 (
                     [a-zA-Z0-9.!#$%&\'*+/=?^_`{|}~-]+
                     \\@
                     [a-zA-Z0-9]
                     (?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?
                     (?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*
                 )
                 >
             }ix', function (Text $w, Text $email) use($target) {
             $text = $email->copy();
             $link = new Link($email->prepend('mailto:'));
             $link->addInline(new String($text));
             $target->addInline($link);
         }, function (Text $part) use($target) {
             $this->next->parseInline($part, $target);
         });
     } else {
         $this->next->parseInline($content, $target);
     }
 }
Exemplo n.º 3
0
 /**
  * Parse the given content.
  *
  * Any newly created nodes should be appended to the given target. Any remaining content should be passed to the
  * next parser in the chain.
  *
  * @param Text $content
  * @param InlineNodeAcceptorInterface $target
  * @return void
  */
 public function parseInline(Text $content, InlineNodeAcceptorInterface $target)
 {
     if ($content->contains('`')) {
         $this->parseCodeSpan($content, $target);
     } else {
         $this->next->parseInline($content, $target);
     }
 }