示例#1
0
 protected static function consumeTextElements(&$text)
 {
     if ('**' != substr($text, 0, 2)) {
         return array();
     }
     $text = substr($text, 2);
     $textElementTypes = array('UnformattedText', 'ItalicText', 'Link');
     $textElements = array();
     do {
         foreach ($textElementTypes as $textElementType) {
             $textElementType = '\\Creole\\' . $textElementType;
             if (!is_null($textElement = $textElementType::consume($text))) {
                 $textElements[] = $textElement;
                 break;
             }
             if ('**' == substr($text, 0, 2)) {
                 $text = substr($text, 2);
                 break;
             } elseif ("\n" == $text[0]) {
                 if (TextParagraph::isParagraphBreak(substr($text, 1, 4))) {
                     break;
                 }
                 $text = substr($text, 1);
                 $textElement = new UnformattedText(' ');
                 $textElements[] = $textElement;
                 break;
             }
         }
     } while (!is_null($textElement));
     return $textElements;
 }
示例#2
0
 protected static function consumeTextElements(&$text, $inList = null)
 {
     if (TextParagraph::isParagraphBreak($text)) {
         return array();
     }
     $textElementTypes = array('UnformattedText', 'BoldText', 'ItalicText', 'Link', 'Image', 'PreformattedText', 'LineBreak');
     $textElements = array();
     do {
         foreach ($textElementTypes as $textElementType) {
             $textElementType = '\\Creole\\' . $textElementType;
             if (!is_null($textElement = $textElementType::consume($text))) {
                 $textElements[] = $textElement;
                 break;
             }
         }
     } while (!is_null($textElement));
     if ("\n" == $text[0] and !TextParagraph::isParagraphBreak(substr($text, 1, 4), $inList)) {
         $textElements[] = new UnformattedText(' ');
         $text = substr($text, 1);
     }
     return $textElements;
 }