You are here

function Markdown_Parser::doHeaders in Markdown 6

Same name and namespace in other branches
  1. 5 markdown.php \Markdown_Parser::doHeaders()
1 method overrides Markdown_Parser::doHeaders()
MarkdownExtra_Parser::doHeaders in ./markdown.php

File

./markdown.php, line 914

Class

Markdown_Parser

Code

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