Code Duplication    Length = 48-49 lines in 2 locations

Michelf/Markdown.php 1 location

@@ 800-847 (lines=48) @@
797
	 * @param  string $text
798
	 * @return string
799
	 */
800
	protected function doImages($text) {
801
		// First, handle reference-style labeled images: ![alt text][id]
802
		$text = preg_replace_callback('{
803
			(				# wrap whole match in $1
804
			  !\[
805
				('.$this->nested_brackets_re.')		# alt text = $2
806
			  \]
807
808
			  [ ]?				# one optional space
809
			  (?:\n[ ]*)?		# one optional newline followed by spaces
810
811
			  \[
812
				(.*?)		# id = $3
813
			  \]
814
815
			)
816
			}xs',
817
			array($this, '_doImages_reference_callback'), $text);
818
819
		// Next, handle inline images:  ![alt text](url "optional title")
820
		// Don't forget: encode * and _
821
		$text = preg_replace_callback('{
822
			(				# wrap whole match in $1
823
			  !\[
824
				('.$this->nested_brackets_re.')		# alt text = $2
825
			  \]
826
			  \s?			# One optional whitespace character
827
			  \(			# literal paren
828
				[ \n]*
829
				(?:
830
					<(\S*)>	# src url = $3
831
				|
832
					('.$this->nested_url_parenthesis_re.')	# src url = $4
833
				)
834
				[ \n]*
835
				(			# $5
836
				  ([\'"])	# quote char = $6
837
				  (.*?)		# title = $7
838
				  \6		# matching quote
839
				  [ \n]*
840
				)?			# title is optional
841
			  \)
842
			)
843
			}xs',
844
			array($this, '_doImages_inline_callback'), $text);
845
846
		return $text;
847
	}
848
849
	/**
850
	 * Callback to parse references image tags

Michelf/MarkdownExtra.php 1 location

@@ 960-1008 (lines=49) @@
957
	 * @param  string $text
958
	 * @return string
959
	 */
960
	protected function doImages($text) {
961
		// First, handle reference-style labeled images: ![alt text][id]
962
		$text = preg_replace_callback('{
963
			(				# wrap whole match in $1
964
			  !\[
965
				(' . $this->nested_brackets_re . ')		# alt text = $2
966
			  \]
967
968
			  [ ]?				# one optional space
969
			  (?:\n[ ]*)?		# one optional newline followed by spaces
970
971
			  \[
972
				(.*?)		# id = $3
973
			  \]
974
975
			)
976
			}xs',
977
			array($this, '_doImages_reference_callback'), $text);
978
979
		// Next, handle inline images:  ![alt text](url "optional title")
980
		// Don't forget: encode * and _
981
		$text = preg_replace_callback('{
982
			(				# wrap whole match in $1
983
			  !\[
984
				(' . $this->nested_brackets_re . ')		# alt text = $2
985
			  \]
986
			  \s?			# One optional whitespace character
987
			  \(			# literal paren
988
				[ \n]*
989
				(?:
990
					<(\S*)>	# src url = $3
991
				|
992
					(' . $this->nested_url_parenthesis_re . ')	# src url = $4
993
				)
994
				[ \n]*
995
				(			# $5
996
				  ([\'"])	# quote char = $6
997
				  (.*?)		# title = $7
998
				  \6		# matching quote
999
				  [ \n]*
1000
				)?			# title is optional
1001
			  \)
1002
			  (?:[ ]? ' . $this->id_class_attr_catch_re . ' )?	 # $8 = id/class attributes
1003
			)
1004
			}xs',
1005
			array($this, '_doImages_inline_callback'), $text);
1006
1007
		return $text;
1008
	}
1009
1010
	/**
1011
	 * Callback for referenced images