function Markdown_Parser::parseSpan in Markdown 5
Same name and namespace in other branches
- 6 markdown.php \Markdown_Parser::parseSpan()
1 call to Markdown_Parser::parseSpan()
File
- ./
markdown.php, line 1486
Class
Code
function parseSpan($str) {
#
# Take the string $str and parse it into tokens, hashing embeded HTML,
# escaped characters and handling code spans.
#
$output = '';
$span_re = '{
(
\\\\' . $this->escape_chars_re . '
|
(?<![`\\\\])
`+ # code span marker
' . ($this->no_markup ? '' : '
|
<!-- .*? --> # comment
|
<\\?.*?\\?> | <%.*?%> # processing instruction
|
<[/!$]?[-a-zA-Z0-9:]+ # regular tags
(?>
\\s
(?>[^"\'>]+|"[^"]*"|\'[^\']*\')*
)?
>
') . '
)
}xs';
while (1) {
#
# Each loop iteration seach for either the next tag, the next
# openning code span marker, or the next escaped character.
# Each token is then passed to handleSpanToken.
#
$parts = preg_split($span_re, $str, 2, PREG_SPLIT_DELIM_CAPTURE);
# Create token from text preceding tag.
if ($parts[0] != "") {
$output .= $parts[0];
}
# Check if we reach the end.
if (isset($parts[1])) {
$output .= $this
->handleSpanToken($parts[1], $parts[2]);
$str = $parts[2];
}
else {
break;
}
}
return $output;
}