You are here

protected function Markdown::_detab_callback in Express 8

* Replace tabs callback *

Parameters

string $matches: * @return string

File

vendor/michelf/php-markdown/Michelf/Markdown.php, line 1842

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected 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;
}