function Markdown_Parser::_detab_callback in Markdown 5
Same name and namespace in other branches
- 6 markdown.php \Markdown_Parser::_detab_callback()
File
- ./
markdown.php, line 1591
Class
Code
function _detab_callback($matches) {
$line = $matches[0];
$strlen = $this->utf8_strlen;
# strlen function for UTF-8.
# Split in blocks.
$blocks = explode("\t", $line);
# Add each blocks to the line.
$line = $blocks[0];
unset($blocks[0]);
# Do not add first block twice.
foreach ($blocks as $block) {
# Calculate amount of space, insert spaces, insert block.
$amount = $this->tab_width - $strlen($line, 'UTF-8') % $this->tab_width;
$line .= str_repeat(" ", $amount) . $block;
}
return $line;
}