Code Duplication    Length = 55-56 lines in 2 locations

_inc/lib/markdown/extra.php 2 locations

@@ 659-713 (lines=55) @@
656
	}
657
658
659
	function doImages($text) {
660
	#
661
	# Turn Markdown image shortcuts into <img> tags.
662
	#
663
		#
664
		# First, handle reference-style labeled images: ![alt text][id]
665
		#
666
		$text = preg_replace_callback('{
667
			(				# wrap whole match in $1
668
			  !\[
669
				('.$this->nested_brackets_re.')		# alt text = $2
670
			  \]
671
672
			  [ ]?				# one optional space
673
			  (?:\n[ ]*)?		# one optional newline followed by spaces
674
675
			  \[
676
				(.*?)		# id = $3
677
			  \]
678
679
			)
680
			}xs',
681
			array(&$this, '_doImages_reference_callback'), $text);
682
683
		#
684
		# Next, handle inline images:  ![alt text](url "optional title")
685
		# Don't forget: encode * and _
686
		#
687
		$text = preg_replace_callback('{
688
			(				# wrap whole match in $1
689
			  !\[
690
				('.$this->nested_brackets_re.')		# alt text = $2
691
			  \]
692
			  \s?			# One optional whitespace character
693
			  \(			# literal paren
694
				[ \n]*
695
				(?:
696
					<(\S*)>	# src url = $3
697
				|
698
					('.$this->nested_url_parenthesis_re.')	# src url = $4
699
				)
700
				[ \n]*
701
				(			# $5
702
				  ([\'"])	# quote char = $6
703
				  (.*?)		# title = $7
704
				  \6		# matching quote
705
				  [ \n]*
706
				)?			# title is optional
707
			  \)
708
			)
709
			}xs',
710
			array(&$this, '_doImages_inline_callback'), $text);
711
712
		return $text;
713
	}
714
	function _doImages_reference_callback($matches) {
715
		$whole_match = $matches[1];
716
		$alt_text    = $matches[2];
@@ 2348-2403 (lines=56) @@
2345
	}
2346
2347
2348
	function doImages($text) {
2349
	#
2350
	# Turn Markdown image shortcuts into <img> tags.
2351
	#
2352
		#
2353
		# First, handle reference-style labeled images: ![alt text][id]
2354
		#
2355
		$text = preg_replace_callback('{
2356
			(				# wrap whole match in $1
2357
			  !\[
2358
				('.$this->nested_brackets_re.')		# alt text = $2
2359
			  \]
2360
2361
			  [ ]?				# one optional space
2362
			  (?:\n[ ]*)?		# one optional newline followed by spaces
2363
2364
			  \[
2365
				(.*?)		# id = $3
2366
			  \]
2367
2368
			)
2369
			}xs',
2370
			array(&$this, '_doImages_reference_callback'), $text);
2371
2372
		#
2373
		# Next, handle inline images:  ![alt text](url "optional title")
2374
		# Don't forget: encode * and _
2375
		#
2376
		$text = preg_replace_callback('{
2377
			(				# wrap whole match in $1
2378
			  !\[
2379
				('.$this->nested_brackets_re.')		# alt text = $2
2380
			  \]
2381
			  \s?			# One optional whitespace character
2382
			  \(			# literal paren
2383
				[ \n]*
2384
				(?:
2385
					<(\S*)>	# src url = $3
2386
				|
2387
					('.$this->nested_url_parenthesis_re.')	# src url = $4
2388
				)
2389
				[ \n]*
2390
				(			# $5
2391
				  ([\'"])	# quote char = $6
2392
				  (.*?)		# title = $7
2393
				  \6		# matching quote
2394
				  [ \n]*
2395
				)?			# title is optional
2396
			  \)
2397
			  (?:[ ]? '.$this->id_class_attr_catch_re.' )?	 # $8 = id/class attributes
2398
			)
2399
			}xs',
2400
			array(&$this, '_doImages_inline_callback'), $text);
2401
2402
		return $text;
2403
	}
2404
	function _doImages_reference_callback($matches) {
2405
		$whole_match = $matches[1];
2406
		$alt_text    = $matches[2];