You are here

function Markdown_Parser::handleSpanToken in Markdown 5

Same name and namespace in other branches
  1. 6 markdown.php \Markdown_Parser::handleSpanToken()
1 call to Markdown_Parser::handleSpanToken()
Markdown_Parser::parseSpan in ./markdown.php

File

./markdown.php, line 1542

Class

Markdown_Parser

Code

function handleSpanToken($token, &$str) {

  #

  # Handle $token provided by parseSpan by determining its nature and

  # returning the corresponding value that should replace it.

  #
  switch ($token[0]) {
    case "\\":
      return $this
        ->hashPart("&#" . ord($token[1]) . ";");
    case "`":

      # Search for end marker in remaining text.
      if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm', $str, $matches)) {
        $str = $matches[2];
        $codespan = $this
          ->makeCodeSpan($matches[1]);
        return $this
          ->hashPart($codespan);
      }
      return $token;

    // return as text since no ending marker found.
    default:
      return $this
        ->hashPart($token);
  }
}