Code Duplication    Length = 70-71 lines in 2 locations

3pp/php-markdown/Michelf/Markdown.php 2 locations

@@ 510-579 (lines=70) @@
507
	}
508
509
510
	protected function doAnchors($text) {
511
	#
512
	# Turn Markdown link shortcuts into XHTML <a> tags.
513
	#
514
		if ($this->in_anchor) return $text;
515
		$this->in_anchor = true;
516
		
517
		#
518
		# First, handle reference-style links: [link text] [id]
519
		#
520
		$text = preg_replace_callback('{
521
			(					# wrap whole match in $1
522
			  \[
523
				('.$this->nested_brackets_re.')	# link text = $2
524
			  \]
525
526
			  [ ]?				# one optional space
527
			  (?:\n[ ]*)?		# one optional newline followed by spaces
528
529
			  \[
530
				(.*?)		# id = $3
531
			  \]
532
			)
533
			}xs',
534
			array(&$this, '_doAnchors_reference_callback'), $text);
535
536
		#
537
		# Next, inline-style links: [link text](url "optional title")
538
		#
539
		$text = preg_replace_callback('{
540
			(				# wrap whole match in $1
541
			  \[
542
				('.$this->nested_brackets_re.')	# link text = $2
543
			  \]
544
			  \(			# literal paren
545
				[ \n]*
546
				(?:
547
					<(.+?)>	# href = $3
548
				|
549
					('.$this->nested_url_parenthesis_re.')	# href = $4
550
				)
551
				[ \n]*
552
				(			# $5
553
				  ([\'"])	# quote char = $6
554
				  (.*?)		# Title = $7
555
				  \6		# matching quote
556
				  [ \n]*	# ignore any spaces/tabs between closing quote and )
557
				)?			# title is optional
558
			  \)
559
			)
560
			}xs',
561
			array(&$this, '_doAnchors_inline_callback'), $text);
562
563
		#
564
		# Last, handle reference-style shortcuts: [link text]
565
		# These must come last in case you've also got [link text][1]
566
		# or [link text](/foo)
567
		#
568
		$text = preg_replace_callback('{
569
			(					# wrap whole match in $1
570
			  \[
571
				([^\[\]]+)		# link text = $2; can\'t contain [ or ]
572
			  \]
573
			)
574
			}xs',
575
			array(&$this, '_doAnchors_reference_callback'), $text);
576
577
		$this->in_anchor = false;
578
		return $text;
579
	}
580
	protected function _doAnchors_reference_callback($matches) {
581
		$whole_match =  $matches[1];
582
		$link_text   =  $matches[2];
@@ 2206-2276 (lines=71) @@
2203
	}
2204
2205
2206
	protected function doAnchors($text) {
2207
	#
2208
	# Turn Markdown link shortcuts into XHTML <a> tags.
2209
	#
2210
		if ($this->in_anchor) return $text;
2211
		$this->in_anchor = true;
2212
		
2213
		#
2214
		# First, handle reference-style links: [link text] [id]
2215
		#
2216
		$text = preg_replace_callback('{
2217
			(					# wrap whole match in $1
2218
			  \[
2219
				('.$this->nested_brackets_re.')	# link text = $2
2220
			  \]
2221
2222
			  [ ]?				# one optional space
2223
			  (?:\n[ ]*)?		# one optional newline followed by spaces
2224
2225
			  \[
2226
				(.*?)		# id = $3
2227
			  \]
2228
			)
2229
			}xs',
2230
			array(&$this, '_doAnchors_reference_callback'), $text);
2231
2232
		#
2233
		# Next, inline-style links: [link text](url "optional title")
2234
		#
2235
		$text = preg_replace_callback('{
2236
			(				# wrap whole match in $1
2237
			  \[
2238
				('.$this->nested_brackets_re.')	# link text = $2
2239
			  \]
2240
			  \(			# literal paren
2241
				[ \n]*
2242
				(?:
2243
					<(.+?)>	# href = $3
2244
				|
2245
					('.$this->nested_url_parenthesis_re.')	# href = $4
2246
				)
2247
				[ \n]*
2248
				(			# $5
2249
				  ([\'"])	# quote char = $6
2250
				  (.*?)		# Title = $7
2251
				  \6		# matching quote
2252
				  [ \n]*	# ignore any spaces/tabs between closing quote and )
2253
				)?			# title is optional
2254
			  \)
2255
			  (?:[ ]? '.$this->id_class_attr_catch_re.' )?	 # $8 = id/class attributes
2256
			)
2257
			}xs',
2258
			array(&$this, '_doAnchors_inline_callback'), $text);
2259
2260
		#
2261
		# Last, handle reference-style shortcuts: [link text]
2262
		# These must come last in case you've also got [link text][1]
2263
		# or [link text](/foo)
2264
		#
2265
		$text = preg_replace_callback('{
2266
			(					# wrap whole match in $1
2267
			  \[
2268
				([^\[\]]+)		# link text = $2; can\'t contain [ or ]
2269
			  \]
2270
			)
2271
			}xs',
2272
			array(&$this, '_doAnchors_reference_callback'), $text);
2273
2274
		$this->in_anchor = false;
2275
		return $text;
2276
	}
2277
	protected function _doAnchors_reference_callback($matches) {
2278
		$whole_match =  $matches[1];
2279
		$link_text   =  $matches[2];