Code Duplication    Length = 55-56 lines in 2 locations

_inc/lib/markdown/extra.php 2 locations

@@ 672-726 (lines=55) @@
669
	}
670
671
672
	function doImages($text) {
673
	#
674
	# Turn Markdown image shortcuts into <img> tags.
675
	#
676
		#
677
		# First, handle reference-style labeled images: ![alt text][id]
678
		#
679
		$text = preg_replace_callback('{
680
			(				# wrap whole match in $1
681
			  !\[
682
				('.$this->nested_brackets_re.')		# alt text = $2
683
			  \]
684
685
			  [ ]?				# one optional space
686
			  (?:\n[ ]*)?		# one optional newline followed by spaces
687
688
			  \[
689
				(.*?)		# id = $3
690
			  \]
691
692
			)
693
			}xs',
694
			array(&$this, '_doImages_reference_callback'), $text);
695
696
		#
697
		# Next, handle inline images:  ![alt text](url "optional title")
698
		# Don't forget: encode * and _
699
		#
700
		$text = preg_replace_callback('{
701
			(				# wrap whole match in $1
702
			  !\[
703
				('.$this->nested_brackets_re.')		# alt text = $2
704
			  \]
705
			  \s?			# One optional whitespace character
706
			  \(			# literal paren
707
				[ \n]*
708
				(?:
709
					<(\S*)>	# src url = $3
710
				|
711
					('.$this->nested_url_parenthesis_re.')	# src url = $4
712
				)
713
				[ \n]*
714
				(			# $5
715
				  ([\'"])	# quote char = $6
716
				  (.*?)		# title = $7
717
				  \6		# matching quote
718
				  [ \n]*
719
				)?			# title is optional
720
			  \)
721
			)
722
			}xs',
723
			array(&$this, '_doImages_inline_callback'), $text);
724
725
		return $text;
726
	}
727
	function _doImages_reference_callback($matches) {
728
		$whole_match = $matches[1];
729
		$alt_text    = $matches[2];
@@ 2361-2416 (lines=56) @@
2358
	}
2359
2360
2361
	function doImages($text) {
2362
	#
2363
	# Turn Markdown image shortcuts into <img> tags.
2364
	#
2365
		#
2366
		# First, handle reference-style labeled images: ![alt text][id]
2367
		#
2368
		$text = preg_replace_callback('{
2369
			(				# wrap whole match in $1
2370
			  !\[
2371
				('.$this->nested_brackets_re.')		# alt text = $2
2372
			  \]
2373
2374
			  [ ]?				# one optional space
2375
			  (?:\n[ ]*)?		# one optional newline followed by spaces
2376
2377
			  \[
2378
				(.*?)		# id = $3
2379
			  \]
2380
2381
			)
2382
			}xs',
2383
			array(&$this, '_doImages_reference_callback'), $text);
2384
2385
		#
2386
		# Next, handle inline images:  ![alt text](url "optional title")
2387
		# Don't forget: encode * and _
2388
		#
2389
		$text = preg_replace_callback('{
2390
			(				# wrap whole match in $1
2391
			  !\[
2392
				('.$this->nested_brackets_re.')		# alt text = $2
2393
			  \]
2394
			  \s?			# One optional whitespace character
2395
			  \(			# literal paren
2396
				[ \n]*
2397
				(?:
2398
					<(\S*)>	# src url = $3
2399
				|
2400
					('.$this->nested_url_parenthesis_re.')	# src url = $4
2401
				)
2402
				[ \n]*
2403
				(			# $5
2404
				  ([\'"])	# quote char = $6
2405
				  (.*?)		# title = $7
2406
				  \6		# matching quote
2407
				  [ \n]*
2408
				)?			# title is optional
2409
			  \)
2410
			  (?:[ ]? '.$this->id_class_attr_catch_re.' )?	 # $8 = id/class attributes
2411
			)
2412
			}xs',
2413
			array(&$this, '_doImages_inline_callback'), $text);
2414
2415
		return $text;
2416
	}
2417
	function _doImages_reference_callback($matches) {
2418
		$whole_match = $matches[1];
2419
		$alt_text    = $matches[2];