You are here

protected function Markdown::doHeaders in Markdown 7

* Parse Markdown heading elements to HTML *

Parameters

string $text: * @return string

1 method overrides Markdown::doHeaders()
MarkdownExtra::doHeaders in includes/MarkdownExtra.php
* Process markdown headers. Redefined to add ID and class attribute support. *

File

includes/Markdown.php, line 904

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function doHeaders($text) {

  /**
   * Setext-style headers:
   *	  Header 1
   *	  ========
   *
   *	  Header 2
   *	  --------
   */
  $text = preg_replace_callback('{ ^(.+?)[ ]*\\n(=+|-+)[ ]*\\n+ }mx', array(
    $this,
    '_doHeaders_callback_setext',
  ), $text);

  /**
   * atx-style headers:
   *   # Header 1
   *   ## Header 2
   *   ## Header 2 with closing hashes ##
   *   ...
   *   ###### Header 6
   */
  $text = preg_replace_callback('{
				^(\\#{1,6})	# $1 = string of #\'s
				[ ]*
				(.+?)		# $2 = Header text
				[ ]*
				\\#*			# optional closing #\'s (not counted)
				\\n+
			}xm', array(
    $this,
    '_doHeaders_callback_atx',
  ), $text);
  return $text;
}