Lines Matching +defs:text +defs:line

24     function text($text)
29 # standardize line breaks
30 $text = str_replace(array("\r\n", "\r"), "\n", $text);
32 # remove surrounding line breaks
33 $text = trim($text, "\n");
35 # split text into lines
36 $lines = explode("\n", $text);
41 # trim line breaks
148 foreach ($lines as $line)
150 if (chop($line) === '')
160 if (strpos($line, "\t") !== false)
162 $parts = explode("\t", $line);
164 $line = $parts[0];
170 $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
172 $line .= str_repeat(' ', $shortage);
173 $line .= $part;
179 while (isset($line[$indent]) and $line[$indent] === ' ')
184 $text = $indent > 0 ? substr($line, $indent) : $line;
188 $Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
213 $marker = $text[0];
260 $CurrentBlock['element']['text'] .= "\n".$text;
329 $text = substr($Line['body'], 4);
335 'text' => array(
337 'text' => $text,
352 $Block['element']['text']['text'] .= "\n";
357 $Block['element']['text']['text'] .= "\n";
359 $text = substr($Line['body'], 4);
361 $Block['element']['text']['text'] .= $text;
369 $text = $Block['element']['text']['text'];
371 $Block['element']['text']['text'] = $text;
386 if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
392 if (preg_match('/-->$/', $Line['text']))
410 if (preg_match('/-->$/', $Line['text']))
423 if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([^`]+)?[ ]*$/', $Line['text'], $matches))
427 'text' => '',
454 'char' => $Line['text'][0],
458 'text' => $Element,
475 $Block['element']['text']['text'] .= "\n";
480 if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
482 $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
489 $Block['element']['text']['text'] .= "\n".$Line['body'];
496 $text = $Block['element']['text']['text'];
498 $Block['element']['text']['text'] = $text;
508 if (isset($Line['text'][1]))
512 while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
522 $text = trim($Line['text'], '# ');
527 'text' => $text,
528 'handler' => 'line',
541 list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
543 if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
567 'text' => array(
572 $Block['element']['text'] []= & $Block['li'];
580 if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
584 $Block['li']['text'] []= '';
593 $text = isset($matches[1]) ? $matches[1] : '';
598 'text' => array(
599 $text,
603 $Block['element']['text'] []= & $Block['li'];
608 if ($Line['text'][0] === '[' and $this->blockReference($Line))
615 $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
617 $Block['li']['text'] []= $text;
624 $Block['li']['text'] []= '';
626 $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
628 $Block['li']['text'] []= $text;
640 foreach ($Block['element']['text'] as &$li)
642 if (end($li['text']) !== '')
644 $li['text'] []= '';
657 if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
663 'text' => (array) $matches[1],
673 if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
677 $Block['element']['text'] []= '';
682 $Block['element']['text'] []= $matches[1];
689 $Block['element']['text'] []= $Line['text'];
700 if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
722 if (chop($Line['text'], $Line['text'][0]) === '')
724 $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
740 if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
752 'markup' => $Line['text'],
757 $remainder = substr($Line['text'], $length);
792 if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
797 if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
826 if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
860 if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '')
864 $divider = $Line['text'];
899 $header = $Block['element']['text'];
912 'text' => $headerCell,
913 'handler' => 'line',
921 'style' => 'text-align: '.$alignment.';',
939 $Block['element']['text'] []= array(
944 $Block['element']['text'] []= array(
947 'text' => array(),
950 $Block['element']['text'][0]['text'] []= array(
953 'text' => $HeaderElements,
967 if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
971 $row = $Line['text'];
984 'handler' => 'line',
985 'text' => $cell,
991 'style' => 'text-align: '.$Block['alignments'][$index].';',
1001 'text' => $Elements,
1004 $Block['element']['text'][1]['text'] []= $Element;
1019 'text' => $Line['text'],
1020 'handler' => 'line',
1054 public function line($text, $nonNestables=array())
1060 while ($excerpt = strpbrk($text, $this->inlineMarkerList))
1064 $markerPosition = strpos($text, $marker);
1066 $Excerpt = array('text' => $excerpt, 'context' => $text);
1105 # the text that comes before the inline
1106 $unmarkedText = substr($text, 0, $Inline['position']);
1108 # compile the unmarked text
1114 # remove the examined text
1115 $text = substr($text, $Inline['position'] + $Inline['extent']);
1122 $unmarkedText = substr($text, 0, $markerPosition + 1);
1126 $text = substr($text, $markerPosition + 1);
1129 $markup .= $this->unmarkedText($text);
1140 $marker = $Excerpt['text'][0];
1142 if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/s', $Excerpt['text'], $matches))
1144 $text = $matches[2];
1145 $text = preg_replace("/[ ]*\n/", ' ', $text);
1151 'text' => $text,
1159 if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
1172 'text' => $matches[1],
1183 if ( ! isset($Excerpt['text'][1]))
1188 $marker = $Excerpt['text'][0];
1190 if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
1194 elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1207 'handler' => 'line',
1208 'text' => $matches[1],
1215 if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
1218 'markup' => $Excerpt['text'][1],
1226 if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1231 $Excerpt['text']= substr($Excerpt['text'], 1);
1246 'alt' => $Link['element']['text'],
1262 'handler' => 'line',
1264 'text' => null,
1273 $remainder = $Excerpt['text'];
1277 $Element['text'] = $matches[1];
1303 $definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
1310 $definition = strtolower($Element['text']);
1332 if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false)
1337 if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches))
1345 if ($Excerpt['text'][1] === '!' and preg_match('/^<!---?[^>-](?:-?[^-])*-->/s', $Excerpt['text'], $matches))
1353 if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
1364 if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1374 if (isset($SpecialCharacter[$Excerpt['text'][0]]))
1377 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
1385 if ( ! isset($Excerpt['text'][1]))
1390 if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
1396 'text' => $matches[1],
1397 'handler' => 'line',
1405 if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1419 'text' => $url,
1432 if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
1440 'text' => $url,
1451 protected function unmarkedText($text)
1455 $text = preg_replace('/[ ]*\n/', "<br />\n", $text);
1459 $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
1460 $text = str_replace(" \n", "\n", $text);
1463 return $text;
1494 if (isset($Element['text']))
1496 $text = $Element['text'];
1502 $text = $Element['rawHtml'];
1507 if (isset($text))
1518 $markup .= $this->{$Element['handler']}($text, $Element['nonNestables']);
1522 $markup .= self::escape($text, true);
1526 $markup .= $text;
1578 function parse($text)
1580 $markup = $this->text($text);
1637 protected static function escape($text, $allowQuotes = false)
1639 return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8');