Code Duplication    Length = 15-30 lines in 3 locations

system/vendor/Markdown.php 3 locations

@@ 346-375 (lines=30) @@
343
		);
344
345
346
	function stripLinkDefinitions($text) {
347
	#
348
	# Strips link definitions from text, stores the URLs and titles in
349
	# hash references.
350
	#
351
		$less_than_tab = $this->tab_width - 1;
352
353
		# Link defs are in the form: ^[id]: url "optional title"
354
		$text = preg_replace_callback('{
355
							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
356
							  [ ]*
357
							  \n?				# maybe *one* newline
358
							  [ ]*
359
							<?(\S+?)>?			# url = $2
360
							  [ ]*
361
							  \n?				# maybe one newline
362
							  [ ]*
363
							(?:
364
								(?<=\s)			# lookbehind for whitespace
365
								["(]
366
								(.*?)			# title = $3
367
								[")]
368
								[ ]*
369
							)?	# title is optional
370
							(?:\n+|\Z)
371
			}xm',
372
			array(&$this, '_stripLinkDefinitions_callback'),
373
			$text);
374
		return $text;
375
	}
376
	function _stripLinkDefinitions_callback($matches) {
377
		$link_id = strtolower($matches[1]);
378
		$this->urls[$link_id] = $matches[2];
@@ 2641-2667 (lines=27) @@
2638
	
2639
	### Footnotes
2640
	
2641
	function stripFootnotes($text) {
2642
	#
2643
	# Strips link definitions from text, stores the URLs and titles in
2644
	# hash references.
2645
	#
2646
		$less_than_tab = $this->tab_width - 1;
2647
2648
		# Link defs are in the form: [^id]: url "optional title"
2649
		$text = preg_replace_callback('{
2650
			^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?:	# note_id = $1
2651
			  [ ]*
2652
			  \n?					# maybe *one* newline
2653
			(						# text = $2 (no blank lines allowed)
2654
				(?:					
2655
					.+				# actual text
2656
				|
2657
					\n				# newlines but 
2658
					(?!\[\^.+?\]:\s)# negative lookahead for footnote marker.
2659
					(?!\n+[ ]{0,3}\S)# ensure line is not blank and followed 
2660
									# by non-indented content
2661
				)*
2662
			)		
2663
			}xm',
2664
			array(&$this, '_stripFootnotes_callback'),
2665
			$text);
2666
		return $text;
2667
	}
2668
	function _stripFootnotes_callback($matches) {
2669
		$note_id = $this->fn_id_prefix . $matches[1];
2670
		$this->footnotes[$note_id] = $this->outdent($matches[2]);
@@ 2782-2796 (lines=15) @@
2779
	
2780
	### Abbreviations ###
2781
	
2782
	function stripAbbreviations($text) {
2783
	#
2784
	# Strips abbreviations from text, stores titles in hash references.
2785
	#
2786
		$less_than_tab = $this->tab_width - 1;
2787
2788
		# Link defs are in the form: [id]*: url "optional title"
2789
		$text = preg_replace_callback('{
2790
			^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?:	# abbr_id = $1
2791
			(.*)					# text = $2 (no blank lines allowed)	
2792
			}xm',
2793
			array(&$this, '_stripAbbreviations_callback'),
2794
			$text);
2795
		return $text;
2796
	}
2797
	function _stripAbbreviations_callback($matches) {
2798
		$abbr_word = $matches[1];
2799
		$abbr_desc = $matches[2];