Code Duplication    Length = 30-40 lines in 2 locations

system/vendor/Markdown.php 2 locations

@@ 894-923 (lines=30) @@
891
	}
892
893
894
	function doHeaders($text) {
895
		# Setext-style headers:
896
		#	  Header 1
897
		#	  ========
898
		#  
899
		#	  Header 2
900
		#	  --------
901
		#
902
		$text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
903
			array(&$this, '_doHeaders_callback_setext'), $text);
904
905
		# atx-style headers:
906
		#	# Header 1
907
		#	## Header 2
908
		#	## Header 2 with closing hashes ##
909
		#	...
910
		#	###### Header 6
911
		#
912
		$text = preg_replace_callback('{
913
				^(\#{1,6})	# $1 = string of #\'s
914
				[ ]*
915
				(.+?)		# $2 = Header text
916
				[ ]*
917
				\#*			# optional closing #\'s (not counted)
918
				\n+
919
			}xm',
920
			array(&$this, '_doHeaders_callback_atx'), $text);
921
922
		return $text;
923
	}
924
	function _doHeaders_callback_setext($matches) {
925
		# Terrible hack to check we haven't found an empty list item.
926
		if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
@@ 2216-2255 (lines=40) @@
2213
	}
2214
2215
2216
	function doHeaders($text) {
2217
	#
2218
	# Redefined to add id attribute support.
2219
	#
2220
		# Setext-style headers:
2221
		#	  Header 1  {#header1}
2222
		#	  ========
2223
		#  
2224
		#	  Header 2  {#header2}
2225
		#	  --------
2226
		#
2227
		$text = preg_replace_callback(
2228
			'{
2229
				(^.+?)								# $1: Header text
2230
				(?:[ ]+\{\#([-_:a-zA-Z0-9]+)\})?	# $2: Id attribute
2231
				[ ]*\n(=+|-+)[ ]*\n+				# $3: Header footer
2232
			}mx',
2233
			array(&$this, '_doHeaders_callback_setext'), $text);
2234
2235
		# atx-style headers:
2236
		#	# Header 1        {#header1}
2237
		#	## Header 2       {#header2}
2238
		#	## Header 2 with closing hashes ##  {#header3}
2239
		#	...
2240
		#	###### Header 6   {#header2}
2241
		#
2242
		$text = preg_replace_callback('{
2243
				^(\#{1,6})	# $1 = string of #\'s
2244
				[ ]*
2245
				(.+?)		# $2 = Header text
2246
				[ ]*
2247
				\#*			# optional closing #\'s (not counted)
2248
				(?:[ ]+\{\#([-_:a-zA-Z0-9]+)\})? # id attribute
2249
				[ ]*
2250
				\n+
2251
			}xm',
2252
			array(&$this, '_doHeaders_callback_atx'), $text);
2253
2254
		return $text;
2255
	}
2256
	function _doHeaders_attr($attr) {
2257
		if (empty($attr))  return "";
2258
		return " id=\"$attr\"";