Passed
Pull Request — lib (#355)
by
unknown
02:25
created
Michelf/Markdown.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -775,8 +775,9 @@
 block discarded – undo
775 775
 		// tag parser and hashed. Need to reverse the process before using
776 776
 		// the URL.
777 777
 		$unhashed = $this->unhash($url);
778
-		if ($unhashed !== $url)
779
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
778
+		if ($unhashed !== $url) {
779
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
780
+		}
780 781
 
781 782
 		$url = $this->encodeURLAttribute($url);
782 783
 
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 		// Try to take parser from the static parser list
37 37
 		static $parser_list;
38
-		$parser =& $parser_list[$parser_class];
38
+		$parser = & $parser_list[$parser_class];
39 39
 
40 40
 		// Create the parser it not already set
41 41
 		if (!$parser) {
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
 		$this->prepareItalicsAndBold();
160 160
 
161 161
 		$this->nested_brackets_re =
162
-			str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth).
162
+			str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) .
163 163
 			str_repeat('\])*', $this->nested_brackets_depth);
164 164
 
165 165
 		$this->nested_url_parenthesis_re =
166
-			str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth).
166
+			str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) .
167 167
 			str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth);
168 168
 
169
-		$this->escape_chars_re = '['.preg_quote($this->escape_chars).']';
169
+		$this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']';
170 170
 
171 171
 		// Sort document, block, and span gamut in ascendent priority order.
172 172
 		asort($this->document_gamut);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 
286 286
 		// Link defs are in the form: ^[id]: url "optional title"
287 287
 		$text = preg_replace_callback('{
288
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
288
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
289 289
 							  [ ]*
290 290
 							  \n?				# maybe *one* newline
291 291
 							  [ ]*
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		$link_id = strtolower($matches[1]);
322 322
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
323 323
 		$this->urls[$link_id] = $url;
324
-		$this->titles[$link_id] =& $matches[4];
324
+		$this->titles[$link_id] = & $matches[4];
325 325
 		return ''; // String that will replace the block
326 326
 	}
327 327
 
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 		 * *  List "b" is made of tags which are always block-level;
354 354
 		 */
355 355
 		$block_tags_a_re = 'ins|del';
356
-		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
357
-						   'script|noscript|style|form|fieldset|iframe|math|svg|'.
358
-						   'article|section|nav|aside|hgroup|header|footer|'.
356
+		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' .
357
+						   'script|noscript|style|form|fieldset|iframe|math|svg|' .
358
+						   'article|section|nav|aside|hgroup|header|footer|' .
359 359
 						   'figure|details|summary';
360 360
 
361 361
 		// Regular expression for the content of a block tag.
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
 				  [^<]+			# content without tag
381 381
 				|
382 382
 				  <\2			# nested opening tag
383
-					'.$attr.'	# attributes
383
+					'.$attr . '	# attributes
384 384
 					(?>
385 385
 					  />
386 386
 					|
387
-					  >', $nested_tags_level).	// end of opening tag
388
-					  '.*?'.					// last level nested tag content
387
+					  >', $nested_tags_level) . // end of opening tag
388
+					  '.*?' . // last level nested tag content
389 389
 			str_repeat('
390 390
 					  </\2\s*>	# closing nested tag
391 391
 					)
@@ -421,20 +421,20 @@  discard block
 block discarded – undo
421 421
 			  # Match from `\n<tag>` to `</tag>\n`, handling nested tags
422 422
 			  # in between.
423 423
 
424
-						[ ]{0,'.$less_than_tab.'}
425
-						<('.$block_tags_b_re.')# start tag = $2
426
-						'.$attr.'>			# attributes followed by > and \n
427
-						'.$content.'		# content, support nesting
424
+						[ ]{0,'.$less_than_tab . '}
425
+						<('.$block_tags_b_re . ')# start tag = $2
426
+						'.$attr . '>			# attributes followed by > and \n
427
+						'.$content . '		# content, support nesting
428 428
 						</\2>				# the matching end tag
429 429
 						[ ]*				# trailing spaces/tabs
430 430
 						(?=\n+|\Z)	# followed by a newline or end of document
431 431
 
432 432
 			| # Special version for tags of group a.
433 433
 
434
-						[ ]{0,'.$less_than_tab.'}
435
-						<('.$block_tags_a_re.')# start tag = $3
436
-						'.$attr.'>[ ]*\n	# attributes followed by >
437
-						'.$content2.'		# content, support nesting
434
+						[ ]{0,'.$less_than_tab . '}
435
+						<('.$block_tags_a_re . ')# start tag = $3
436
+						'.$attr . '>[ ]*\n	# attributes followed by >
437
+						'.$content2 . '		# content, support nesting
438 438
 						</\3>				# the matching end tag
439 439
 						[ ]*				# trailing spaces/tabs
440 440
 						(?=\n+|\Z)	# followed by a newline or end of document
@@ -442,16 +442,16 @@  discard block
 block discarded – undo
442 442
 			| # Special case just for <hr />. It was easier to make a special
443 443
 			  # case than to make the other regex more complicated.
444 444
 
445
-						[ ]{0,'.$less_than_tab.'}
445
+						[ ]{0,'.$less_than_tab . '}
446 446
 						<(hr)				# start tag = $2
447
-						'.$attr.'			# attributes
447
+						'.$attr . '			# attributes
448 448
 						/?>					# the matching end tag
449 449
 						[ ]*
450 450
 						(?=\n{2,}|\Z)		# followed by a blank line or end of document
451 451
 
452 452
 			| # Special case for standalone HTML comments:
453 453
 
454
-					[ ]{0,'.$less_than_tab.'}
454
+					[ ]{0,'.$less_than_tab . '}
455 455
 					(?s:
456 456
 						<!-- .*? -->
457 457
 					)
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 
461 461
 			| # PHP and ASP-style processor instructions (<? and <%)
462 462
 
463
-					[ ]{0,'.$less_than_tab.'}
463
+					[ ]{0,'.$less_than_tab . '}
464 464
 					(?s:
465 465
 						<([?%])			# $2
466 466
 						.*?
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 				[ ]*		# Tailing spaces
592 592
 				$			# End of line.
593 593
 			}mx',
594
-			"\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n",
594
+			"\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n",
595 595
 			$text
596 596
 		);
597 597
 	}
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 		$text = preg_replace_callback('{
671 671
 			(					# wrap whole match in $1
672 672
 			  \[
673
-				('.$this->nested_brackets_re.')	# link text = $2
673
+				('.$this->nested_brackets_re . ')	# link text = $2
674 674
 			  \]
675 675
 
676 676
 			  [ ]?				# one optional space
@@ -687,14 +687,14 @@  discard block
 block discarded – undo
687 687
 		$text = preg_replace_callback('{
688 688
 			(				# wrap whole match in $1
689 689
 			  \[
690
-				('.$this->nested_brackets_re.')	# link text = $2
690
+				('.$this->nested_brackets_re . ')	# link text = $2
691 691
 			  \]
692 692
 			  \(			# literal paren
693 693
 				[ \n]*
694 694
 				(?:
695 695
 					<(.+?)>	# href = $3
696 696
 				|
697
-					('.$this->nested_url_parenthesis_re.')	# href = $4
697
+					('.$this->nested_url_parenthesis_re . ')	# href = $4
698 698
 				)
699 699
 				[ \n]*
700 700
 				(			# $5
@@ -730,9 +730,9 @@  discard block
 block discarded – undo
730 730
 	 * @return string
731 731
 	 */
732 732
 	protected function _doAnchors_reference_callback($matches) {
733
-		$whole_match =  $matches[1];
734
-		$link_text   =  $matches[2];
735
-		$link_id     =& $matches[3];
733
+		$whole_match = $matches[1];
734
+		$link_text   = $matches[2];
735
+		$link_id     = & $matches[3];
736 736
 
737 737
 		if ($link_id == "") {
738 738
 			// for shortcut links like [this][] or [this].
@@ -748,10 +748,10 @@  discard block
 block discarded – undo
748 748
 			$url = $this->encodeURLAttribute($url);
749 749
 
750 750
 			$result = "<a href=\"$url\"";
751
-			if ( isset( $this->titles[$link_id] ) ) {
751
+			if (isset($this->titles[$link_id])) {
752 752
 				$title = $this->titles[$link_id];
753 753
 				$title = $this->encodeAttribute($title);
754
-				$result .=  " title=\"$title\"";
754
+				$result .= " title=\"$title\"";
755 755
 			}
756 756
 
757 757
 			$result .= $this->build_class_attributes("a");
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
 	 * @return string
771 771
 	 */
772 772
 	protected function _doAnchors_inline_callback($matches) {
773
-		$link_text		=  $this->runSpanGamut($matches[2]);
774
-		$url			=  $matches[3] === '' ? $matches[4] : $matches[3];
775
-		$title			=& $matches[7];
773
+		$link_text = $this->runSpanGamut($matches[2]);
774
+		$url = $matches[3] === '' ? $matches[4] : $matches[3];
775
+		$title = & $matches[7];
776 776
 
777 777
 		// If the URL was of the form <s p a c e s> it got caught by the HTML
778 778
 		// tag parser and hashed. Need to reverse the process before using
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 		$result = "<a href=\"$url\"";
787 787
 		if (isset($title)) {
788 788
 			$title = $this->encodeAttribute($title);
789
-			$result .=  " title=\"$title\"";
789
+			$result .= " title=\"$title\"";
790 790
 		}
791 791
 
792 792
 		$result .= $this->build_class_attributes("a");
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 		$text = preg_replace_callback('{
807 807
 			(				# wrap whole match in $1
808 808
 			  !\[
809
-				('.$this->nested_brackets_re.')		# alt text = $2
809
+				('.$this->nested_brackets_re . ')		# alt text = $2
810 810
 			  \]
811 811
 
812 812
 			  [ ]?				# one optional space
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 		$text = preg_replace_callback('{
826 826
 			(				# wrap whole match in $1
827 827
 			  !\[
828
-				('.$this->nested_brackets_re.')		# alt text = $2
828
+				('.$this->nested_brackets_re . ')		# alt text = $2
829 829
 			  \]
830 830
 			  \s?			# One optional whitespace character
831 831
 			  \(			# literal paren
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 				(?:
834 834
 					<(\S*)>	# src url = $3
835 835
 				|
836
-					('.$this->nested_url_parenthesis_re.')	# src url = $4
836
+					('.$this->nested_url_parenthesis_re . ')	# src url = $4
837 837
 				)
838 838
 				[ \n]*
839 839
 				(			# $5
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			if (isset($this->titles[$link_id])) {
872 872
 				$title = $this->titles[$link_id];
873 873
 				$title = $this->encodeAttribute($title);
874
-				$result .=  " title=\"$title\"";
874
+				$result .= " title=\"$title\"";
875 875
 			}
876 876
 			$result .= $this->build_class_attributes("img");
877 877
 			$result .= $this->empty_element_suffix;
@@ -890,17 +890,17 @@  discard block
 block discarded – undo
890 890
 	 * @return string
891 891
 	 */
892 892
 	protected function _doImages_inline_callback($matches) {
893
-		$whole_match	= $matches[1];
894
-		$alt_text		= $matches[2];
895
-		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
896
-		$title			=& $matches[7];
893
+		$whole_match = $matches[1];
894
+		$alt_text = $matches[2];
895
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
896
+		$title = & $matches[7];
897 897
 
898 898
 		$alt_text = $this->encodeAttribute($alt_text);
899 899
 		$url = $this->encodeURLAttribute($url);
900 900
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
901 901
 		if (isset($title)) {
902 902
 			$title = $this->encodeAttribute($title);
903
-			$result .=  " title=\"$title\""; // $title already quoted
903
+			$result .= " title=\"$title\""; // $title already quoted
904 904
 		}
905 905
 		$result .= $this->build_class_attributes("img");
906 906
 		$result .= $this->empty_element_suffix;
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 		// ID attribute generation
963 963
 		$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
964 964
 
965
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[1])."</h$level>";
965
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[1]) . "</h$level>";
966 966
 		return "\n" . $this->hashBlock($block) . "\n\n";
967 967
 	}
968 968
 
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 		$idAtt = $this->_generateIdFromHeaderValue($matches[2]);
977 977
 
978 978
 		$level = strlen($matches[1]);
979
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[2])."</h$level>";
979
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[2]) . "</h$level>";
980 980
 		return "\n" . $this->hashBlock($block) . "\n\n";
981 981
 	}
982 982
 
@@ -1024,8 +1024,8 @@  discard block
 block discarded – undo
1024 1024
 			$whole_list_re = '
1025 1025
 				(								# $1 = whole list
1026 1026
 				  (								# $2
1027
-					([ ]{0,'.$less_than_tab.'})	# $3 = number of spaces
1028
-					('.$marker_re.')			# $4 = first list item marker
1027
+					([ ]{0,'.$less_than_tab . '})	# $3 = number of spaces
1028
+					('.$marker_re . ')			# $4 = first list item marker
1029 1029
 					[ ]+
1030 1030
 				  )
1031 1031
 				  (?s:.+?)
@@ -1036,13 +1036,13 @@  discard block
 block discarded – undo
1036 1036
 					  (?=\S)
1037 1037
 					  (?!						# Negative lookahead for another list item marker
1038 1038
 						[ ]*
1039
-						'.$marker_re.'[ ]+
1039
+						'.$marker_re . '[ ]+
1040 1040
 					  )
1041 1041
 					|
1042 1042
 					  (?=						# Lookahead for another kind of list
1043 1043
 					    \n
1044 1044
 						\3						# Must have the same indentation
1045
-						'.$other_marker_re.'[ ]+
1045
+						'.$other_marker_re . '[ ]+
1046 1046
 					  )
1047 1047
 				  )
1048 1048
 				)
@@ -1054,13 +1054,13 @@  discard block
 block discarded – undo
1054 1054
 			if ($this->list_level) {
1055 1055
 				$text = preg_replace_callback('{
1056 1056
 						^
1057
-						'.$whole_list_re.'
1057
+						'.$whole_list_re . '
1058 1058
 					}mx',
1059 1059
 					array($this, '_doLists_callback'), $text);
1060 1060
 			} else {
1061 1061
 				$text = preg_replace_callback('{
1062 1062
 						(?:(?<=\n)\n|\A\n?) # Must eat the newline
1063
-						'.$whole_list_re.'
1063
+						'.$whole_list_re . '
1064 1064
 					}mx',
1065 1065
 					array($this, '_doLists_callback'), $text);
1066 1066
 			}
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 		$list = $matches[1];
1085 1085
 		$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
1086 1086
 
1087
-		$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
1087
+		$marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re);
1088 1088
 
1089 1089
 		$list .= "\n";
1090 1090
 		$result = $this->processListItems($list, $marker_any_re);
@@ -1095,18 +1095,18 @@  discard block
 block discarded – undo
1095 1095
 			if ($list_type == 'ol') {
1096 1096
 				$ol_start_array = array();
1097 1097
 				$ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array);
1098
-				if ($ol_start_check){
1098
+				if ($ol_start_check) {
1099 1099
 					$ol_start = $ol_start_array[0];
1100 1100
 				}
1101 1101
 			}
1102 1102
 		}
1103 1103
 
1104
-		if ($ol_start > 1 && $list_type == 'ol'){
1104
+		if ($ol_start > 1 && $list_type == 'ol') {
1105 1105
 			$result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>");
1106 1106
 		} else {
1107 1107
 			$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
1108 1108
 		}
1109
-		return "\n". $result ."\n\n";
1109
+		return "\n" . $result . "\n\n";
1110 1110
 	}
1111 1111
 
1112 1112
 	/**
@@ -1153,12 +1153,12 @@  discard block
 block discarded – undo
1153 1153
 		$list_str = preg_replace_callback('{
1154 1154
 			(\n)?							# leading line = $1
1155 1155
 			(^[ ]*)							# leading whitespace = $2
1156
-			('.$marker_any_re.'				# list marker and space = $3
1156
+			('.$marker_any_re . '				# list marker and space = $3
1157 1157
 				(?:[ ]+|(?=\n))	# space only required if item is not empty
1158 1158
 			)
1159 1159
 			((?s:.*?))						# list item text   = $4
1160 1160
 			(?:(\n+(?=\n))|\n)				# tailing blank line = $5
1161
-			(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
1161
+			(?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n))))
1162 1162
 			}xm',
1163 1163
 			array($this, '_processListItems_callback'), $list_str);
1164 1164
 
@@ -1173,17 +1173,17 @@  discard block
 block discarded – undo
1173 1173
 	 */
1174 1174
 	protected function _processListItems_callback($matches) {
1175 1175
 		$item = $matches[4];
1176
-		$leading_line =& $matches[1];
1177
-		$leading_space =& $matches[2];
1176
+		$leading_line = & $matches[1];
1177
+		$leading_space = & $matches[2];
1178 1178
 		$marker_space = $matches[3];
1179
-		$tailing_blank_line =& $matches[5];
1179
+		$tailing_blank_line = & $matches[5];
1180 1180
 
1181 1181
 		if ($leading_line || $tailing_blank_line ||
1182 1182
 			preg_match('/\n{2,}/', $item))
1183 1183
 		{
1184 1184
 			// Replace marker with the appropriate whitespace indentation
1185 1185
 			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1186
-			$item = $this->runBlockGamut($this->outdent($item)."\n");
1186
+			$item = $this->runBlockGamut($this->outdent($item) . "\n");
1187 1187
 		} else {
1188 1188
 			// Recursion for sub-lists:
1189 1189
 			$item = $this->doLists($this->outdent($item));
@@ -1203,11 +1203,11 @@  discard block
 block discarded – undo
1203 1203
 				(?:\n\n|\A\n?)
1204 1204
 				(	            # $1 = the code block -- one or more lines, starting with a space/tab
1205 1205
 				  (?>
1206
-					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces
1206
+					[ ]{'.$this->tab_width . '}  # Lines must start with a tab or a tab-width of spaces
1207 1207
 					.*\n+
1208 1208
 				  )+
1209 1209
 				)
1210
-				((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1210
+				((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1211 1211
 			}xm',
1212 1212
 			array($this, '_doCodeBlocks_callback'), $text);
1213 1213
 
@@ -1335,8 +1335,8 @@  discard block
 block discarded – undo
1335 1335
 			// Each token is then passed to handleSpanToken.
1336 1336
 			$parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
1337 1337
 			$text_stack[0] .= $parts[0];
1338
-			$token =& $parts[1];
1339
-			$text =& $parts[2];
1338
+			$token = & $parts[1];
1339
+			$text = & $parts[2];
1340 1340
 
1341 1341
 			if (empty($token)) {
1342 1342
 				// Reached end of text span: empty stack without emitting.
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 				} else {
1364 1364
 					// Other closing marker: close one em or strong and
1365 1365
 					// change current token state to match the other
1366
-					$token_stack[0] = str_repeat($token[0], 3-$token_len);
1366
+					$token_stack[0] = str_repeat($token[0], 3 - $token_len);
1367 1367
 					$tag = $token_len == 2 ? "strong" : "em";
1368 1368
 					$span = $text_stack[0];
1369 1369
 					$span = $this->runSpanGamut($span);
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
 		}
1710 1710
 
1711 1711
 		$chars = preg_split('/(?<!^)(?!$)/', $text);
1712
-		$seed = (int)abs(crc32($text) / strlen($text)); // Deterministic seed.
1712
+		$seed = (int) abs(crc32($text) / strlen($text)); // Deterministic seed.
1713 1713
 
1714 1714
 		foreach ($chars as $key => $char) {
1715 1715
 			$ord = ord($char);
@@ -1722,9 +1722,9 @@  discard block
 block discarded – undo
1722 1722
 				if ($r > 90 && strpos('@"&>', $char) === false) {
1723 1723
 					/* do nothing */
1724 1724
 				} else if ($r < 45) {
1725
-					$chars[$key] = '&#x'.dechex($ord).';';
1725
+					$chars[$key] = '&#x' . dechex($ord) . ';';
1726 1726
 				} else {
1727
-					$chars[$key] = '&#'.$ord.';';
1727
+					$chars[$key] = '&#' . $ord . ';';
1728 1728
 				}
1729 1729
 			}
1730 1730
 		}
@@ -1746,11 +1746,11 @@  discard block
 block discarded – undo
1746 1746
 
1747 1747
 		$span_re = '{
1748 1748
 				(
1749
-					\\\\'.$this->escape_chars_re.'
1749
+					\\\\'.$this->escape_chars_re . '
1750 1750
 				|
1751 1751
 					(?<![`\\\\])
1752 1752
 					`+						# code span marker
1753
-			'.( $this->no_markup ? '' : '
1753
+			'.($this->no_markup ? '' : '
1754 1754
 				|
1755 1755
 					<!--    .*?     -->		# comment
1756 1756
 				|
@@ -1766,7 +1766,7 @@  discard block
 block discarded – undo
1766 1766
 					<[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag
1767 1767
 				|
1768 1768
 					</[-a-zA-Z0-9:_]+\s*> # closing tag
1769
-			').'
1769
+			') . '
1770 1770
 				)
1771 1771
 				}xs';
1772 1772
 
@@ -1803,10 +1803,10 @@  discard block
 block discarded – undo
1803 1803
 	protected function handleSpanToken($token, &$str) {
1804 1804
 		switch ($token[0]) {
1805 1805
 			case "\\":
1806
-				return $this->hashPart("&#". ord($token[1]). ";");
1806
+				return $this->hashPart("&#" . ord($token[1]) . ";");
1807 1807
 			case "`":
1808 1808
 				// Search for end marker in remaining text.
1809
-				if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
1809
+				if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm',
1810 1810
 					$str, $matches))
1811 1811
 				{
1812 1812
 					$str = $matches[2];
@@ -1920,14 +1920,14 @@  discard block
 block discarded – undo
1920 1920
 	 * @return string
1921 1921
 	 */
1922 1922
 	protected function build_class_attributes($tag) {
1923
-		if($this->class_attributes === null || !isset($this->class_attributes[$tag])) {
1923
+		if ($this->class_attributes === null || !isset($this->class_attributes[$tag])) {
1924 1924
 			return "";
1925 1925
 		}
1926 1926
 		
1927 1927
 		$attributes = $this->class_attributes[$tag];
1928
-		if(is_string($attributes)) {
1928
+		if (is_string($attributes)) {
1929 1929
 			return ' class="' . $attributes . '"';
1930
-		} else if(is_array($attributes)) {
1930
+		} else if (is_array($attributes)) {
1931 1931
 			return ' class="' . implode(' ', $attributes) . '"';
1932 1932
 		} else {
1933 1933
 			return '';
Please login to merge, or discard this patch.
Readme.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 // you like.
6 6
 
7 7
 // Install PSR-4-compatible class autoloader
8
-spl_autoload_register(function($class){
9
-	require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
8
+spl_autoload_register(function($class) {
9
+	require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')) . '.php';
10 10
 });
11 11
 // If using Composer, use this instead:
12 12
 //require 'vendor/autoload.php';
Please login to merge, or discard this patch.
Michelf/MarkdownExtra.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -154,10 +154,10 @@
 block discarded – undo
154 154
 	 */
155 155
 	protected $footnote_counter = 1;
156 156
 
157
-    /**
158
-     * Ref attribute for links
159
-     * @var array
160
-     */
157
+	/**
158
+	 * Ref attribute for links
159
+	 * @var array
160
+	 */
161 161
 	protected $ref_attr = array();
162 162
 
163 163
 	/**
Please login to merge, or discard this patch.
Braces   +42 added lines, -36 removed lines patch added patch discarded remove patch
@@ -187,8 +187,9 @@  discard block
 block discarded – undo
187 187
 		$this->footnotes_assembled = null;
188 188
 
189 189
 		foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
190
-			if ($this->abbr_word_re)
191
-				$this->abbr_word_re .= '|';
190
+			if ($this->abbr_word_re) {
191
+							$this->abbr_word_re .= '|';
192
+			}
192 193
 			$this->abbr_word_re .= preg_quote($abbr_word);
193 194
 			$this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
194 195
 		}
@@ -205,8 +206,9 @@  discard block
 block discarded – undo
205 206
 		$this->abbr_desciptions = array();
206 207
 		$this->abbr_word_re = '';
207 208
 
208
-		if ( ! $this->omit_footnotes )
209
-			$this->footnotes_assembled = null;
209
+		if ( ! $this->omit_footnotes ) {
210
+					$this->footnotes_assembled = null;
211
+		}
210 212
 
211 213
 		parent::teardown();
212 214
 	}
@@ -259,7 +261,9 @@  discard block
 block discarded – undo
259 261
 			if ($element[0] === '.') {
260 262
 				$classes[] = substr($element, 1);
261 263
 			} else if ($element[0] === '#') {
262
-				if ($id === false) $id = substr($element, 1);
264
+				if ($id === false) {
265
+					$id = substr($element, 1);
266
+				}
263 267
 			} else if (strpos($element, '=') > 0) {
264 268
 				$parts = explode('=', $element, 2);
265 269
 				$attributes[] = $parts[0] . '="' . $parts[1] . '"';
@@ -435,7 +439,9 @@  discard block
 block discarded – undo
435 439
 										$enclosing_tag_re = '', $span = false)
436 440
 	{
437 441
 
438
-		if ($text === '') return array('', '');
442
+		if ($text === '') {
443
+			return array('', '');
444
+		}
439 445
 
440 446
 		// Regex to check for the presense of newlines around a block tag.
441 447
 		$newline_before_re = '/(?:^\n?|\n\n)*$/';
@@ -546,8 +552,7 @@  discard block
 block discarded – undo
546 552
 					// End marker found: pass text unchanged until marker.
547 553
 					$parsed .= $tag . $matches[0];
548 554
 					$text = substr($text, strlen($matches[0]));
549
-				}
550
-				else {
555
+				} else {
551 556
 					// No end marker: just skip it.
552 557
 					$parsed .= $tag;
553 558
 				}
@@ -569,8 +574,7 @@  discard block
 block discarded – undo
569 574
 					// End marker found: pass text unchanged until marker.
570 575
 					$parsed .= $tag . $matches[0];
571 576
 					$text = substr($text, strlen($matches[0]));
572
-				}
573
-				else {
577
+				} else {
574 578
 					// Unmatched marker: just skip it.
575 579
 					$parsed .= $tag;
576 580
 				}
@@ -623,8 +627,7 @@  discard block
 block discarded – undo
623 627
 				}
624 628
 
625 629
 				$parsed .= $tag;
626
-			}
627
-			else {
630
+			} else {
628 631
 				$parsed .= $tag;
629 632
 			}
630 633
 		} while ($depth >= 0);
@@ -647,7 +650,9 @@  discard block
 block discarded – undo
647 650
 	 * @return array
648 651
 	 */
649 652
 	protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
650
-		if ($text === '') return array('', '');
653
+		if ($text === '') {
654
+			return array('', '');
655
+		}
651 656
 
652 657
 		// Regex to match `markdown` attribute inside of a tag.
653 658
 		$markdown_attr_re = '
@@ -697,8 +702,9 @@  discard block
 block discarded – undo
697 702
 
698 703
 		// Get the name of the starting tag.
699 704
 		// (This pattern makes $base_tag_name_re safe without quoting.)
700
-		if (preg_match('/^<([\w:$]*)\b/', $text, $matches))
701
-			$base_tag_name_re = $matches[1];
705
+		if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) {
706
+					$base_tag_name_re = $matches[1];
707
+		}
702 708
 
703 709
 		// Loop through every tag until we find the corresponding closing tag.
704 710
 		do {
@@ -727,8 +733,7 @@  discard block
 block discarded – undo
727 733
 			{
728 734
 				// Just add the tag to the block as if it was text.
729 735
 				$block_text .= $tag;
730
-			}
731
-			else {
736
+			} else {
732 737
 				// Increase/decrease nested tag count. Only do so if
733 738
 				// the tag's name match base tag's.
734 739
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
@@ -789,8 +794,9 @@  discard block
 block discarded – undo
789 794
 
790 795
 					// Start over with a new block.
791 796
 					$block_text = "";
797
+				} else {
798
+					$block_text .= $tag;
792 799
 				}
793
-				else $block_text .= $tag;
794 800
 			}
795 801
 
796 802
 		} while ($depth > 0);
@@ -911,14 +917,14 @@  discard block
 block discarded – undo
911 917
 				$title = $this->encodeAttribute($title);
912 918
 				$result .=  " title=\"$title\"";
913 919
 			}
914
-			if (isset($this->ref_attr[$link_id]))
915
-				$result .= $this->ref_attr[$link_id];
920
+			if (isset($this->ref_attr[$link_id])) {
921
+							$result .= $this->ref_attr[$link_id];
922
+			}
916 923
 
917 924
 			$link_text = $this->runSpanGamut($link_text);
918 925
 			$result .= ">$link_text</a>";
919 926
 			$result = $this->hashPart($result);
920
-		}
921
-		else {
927
+		} else {
922 928
 			$result = $whole_match;
923 929
 		}
924 930
 		return $result;
@@ -938,8 +944,9 @@  discard block
 block discarded – undo
938 944
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
939 945
 		// tag parser and hashed. Need to reverse the process before using the URL.
940 946
 		$unhashed = $this->unhash($url);
941
-		if ($unhashed !== $url)
942
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
947
+		if ($unhashed !== $url) {
948
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
949
+		}
943 950
 
944 951
 		$url = $this->encodeURLAttribute($url);
945 952
 
@@ -1039,8 +1046,7 @@  discard block
 block discarded – undo
1039 1046
 			}
1040 1047
 			$result .= $this->empty_element_suffix;
1041 1048
 			$result = $this->hashPart($result);
1042
-		}
1043
-		else {
1049
+		} else {
1044 1050
 			// If there's no such link ID, leave intact:
1045 1051
 			$result = $whole_match;
1046 1052
 		}
@@ -1255,14 +1261,15 @@  discard block
 block discarded – undo
1255 1261
 		// Reading alignement from header underline.
1256 1262
 		$separators	= preg_split('/ *[|] */', $underline);
1257 1263
 		foreach ($separators as $n => $s) {
1258
-			if (preg_match('/^ *-+: *$/', $s))
1259
-				$attr[$n] = $this->_doTable_makeAlignAttr('right');
1260
-			else if (preg_match('/^ *:-+: *$/', $s))
1261
-				$attr[$n] = $this->_doTable_makeAlignAttr('center');
1262
-			else if (preg_match('/^ *:-+ *$/', $s))
1263
-				$attr[$n] = $this->_doTable_makeAlignAttr('left');
1264
-			else
1265
-				$attr[$n] = '';
1264
+			if (preg_match('/^ *-+: *$/', $s)) {
1265
+							$attr[$n] = $this->_doTable_makeAlignAttr('right');
1266
+			} else if (preg_match('/^ *:-+: *$/', $s)) {
1267
+							$attr[$n] = $this->_doTable_makeAlignAttr('center');
1268
+			} else if (preg_match('/^ *:-+ *$/', $s)) {
1269
+							$attr[$n] = $this->_doTable_makeAlignAttr('left');
1270
+			} else {
1271
+							$attr[$n] = '';
1272
+			}
1266 1273
 		}
1267 1274
 
1268 1275
 		// Parsing span elements, including code spans, character escapes,
@@ -1445,8 +1452,7 @@  discard block
 block discarded – undo
1445 1452
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1446 1453
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1447 1454
 			$def = "\n". $def ."\n";
1448
-		}
1449
-		else {
1455
+		} else {
1450 1456
 			$def = rtrim($def);
1451 1457
 			$def = $this->runSpanGamut($this->outdent($def));
1452 1458
 		}
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		$this->abbr_desciptions = array();
206 206
 		$this->abbr_word_re = '';
207 207
 
208
-		if ( ! $this->omit_footnotes )
208
+		if (!$this->omit_footnotes)
209 209
 			$this->footnotes_assembled = null;
210 210
 
211 211
 		parent::teardown();
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
 		// Compose attributes as string
274 274
 		$attr_str = "";
275 275
 		if (!empty($id)) {
276
-			$attr_str .= ' id="'.$this->encodeAttribute($id) .'"';
276
+			$attr_str .= ' id="' . $this->encodeAttribute($id) . '"';
277 277
 		}
278 278
 		if (!empty($classes)) {
279
-			$attr_str .= ' class="'. implode(" ", $classes) . '"';
279
+			$attr_str .= ' class="' . implode(" ", $classes) . '"';
280 280
 		}
281 281
 		if (!$this->no_markup && !empty($attributes)) {
282
-			$attr_str .= ' '.implode(" ", $attributes);
282
+			$attr_str .= ' ' . implode(" ", $attributes);
283 283
 		}
284 284
 		return $attr_str;
285 285
 	}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 		// Link defs are in the form: ^[id]: url "optional title"
297 297
 		$text = preg_replace_callback('{
298
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
298
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
299 299
 							  [ ]*
300 300
 							  \n?				# maybe *one* newline
301 301
 							  [ ]*
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 								[")]
315 315
 								[ ]*
316 316
 							)?	# title is optional
317
-					(?:[ ]* '.$this->id_class_attr_catch_re.' )?  # $5 = extra id & class attr
317
+					(?:[ ]* '.$this->id_class_attr_catch_re . ' )?  # $5 = extra id & class attr
318 318
 							(?:\n+|\Z)
319 319
 			}xm',
320 320
 			array($this, '_stripLinkDefinitions_callback'),
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 		$link_id = strtolower($matches[1]);
332 332
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
333 333
 		$this->urls[$link_id] = $url;
334
-		$this->titles[$link_id] =& $matches[4];
335
-		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]);
334
+		$this->titles[$link_id] = & $matches[4];
335
+		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]);
336 336
 		return ''; // String that will replace the block
337 337
 	}
338 338
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		}
396 396
 
397 397
 		// Call the HTML-in-Markdown hasher.
398
-		list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
398
+		list($text,) = $this->_hashHTMLBlocks_inMarkdown($text);
399 399
 
400 400
 		return $text;
401 401
 	}
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 					<\?.*?\?> | <%.*?%>	# Processing instruction
473 473
 				|
474 474
 					<!\[CDATA\[.*?\]\]>	# CData Block
475
-				' . ( !$span ? ' # If not in span.
475
+				' . (!$span ? ' # If not in span.
476 476
 				|
477 477
 					# Indented code block
478 478
 					(?: ^[ ]*\n | ^ | \n[ ]*\n )
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 					(?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes
491 491
 					[ ]*
492 492
 					(?= \n )
493
-				' : '' ) . ' # End (if not is span).
493
+				' : '') . ' # End (if not is span).
494 494
 				|
495 495
 					# Code span marker
496 496
 					# Note, this regex needs to go after backtick fenced
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 			}xs';
502 502
 
503 503
 
504
-		$depth = 0;		// Current depth inside the tag tree.
505
-		$parsed = "";	// Parsed text that will be returned.
504
+		$depth = 0; // Current depth inside the tag tree.
505
+		$parsed = ""; // Parsed text that will be returned.
506 506
 
507 507
 		// Loop through every tag until we find the closing tag of the parent
508 508
 		// or loop until reaching the end of text if no parent tag specified.
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
 			//            Opening Context Block tag (like ins and del)
580 580
 			//               used as a block tag (tag is alone on it's line).
581 581
 			else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) ||
582
-				(	preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
582
+				(preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
583 583
 					preg_match($newline_before_re, $parsed) &&
584
-					preg_match($newline_after_re, $text)	)
584
+					preg_match($newline_after_re, $text))
585 585
 				)
586 586
 			{
587 587
 				// Need to parse tag and following text using the HTML parser.
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 				// Increase/decrease nested tag count.
612 612
 				if ($tag[1] === '/') {
613 613
 					$depth--;
614
-				} else if ($tag[strlen($tag)-2] !== '/') {
614
+				} else if ($tag[strlen($tag) - 2] !== '/') {
615 615
 					$depth++;
616 616
 				}
617 617
 
@@ -688,11 +688,11 @@  discard block
 block discarded – undo
688 688
 				)
689 689
 			}xs';
690 690
 
691
-		$original_text = $text;		// Save original text in case of faliure.
691
+		$original_text = $text; // Save original text in case of faliure.
692 692
 
693
-		$depth		= 0;	// Current depth inside the tag tree.
694
-		$block_text	= "";	// Temporary text holder for current text.
695
-		$parsed		= "";	// Parsed text that will be returned.
693
+		$depth = 0; // Current depth inside the tag tree.
694
+		$block_text = ""; // Temporary text holder for current text.
695
+		$parsed = ""; // Parsed text that will be returned.
696 696
 		$base_tag_name_re = '';
697 697
 
698 698
 		// Get the name of the starting tag.
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
735 735
 					if ($tag[1] === '/') {
736 736
 						$depth--;
737
-					} else if ($tag[strlen($tag)-2] !== '/') {
737
+					} else if ($tag[strlen($tag) - 2] !== '/') {
738 738
 						$depth++;
739 739
 					}
740 740
 				}
@@ -888,9 +888,9 @@  discard block
 block discarded – undo
888 888
 	 * @return string
889 889
 	 */
890 890
 	protected function _doAnchors_reference_callback($matches) {
891
-		$whole_match =  $matches[1];
892
-		$link_text   =  $matches[2];
893
-		$link_id     =& $matches[3];
891
+		$whole_match = $matches[1];
892
+		$link_text   = $matches[2];
893
+		$link_id     = & $matches[3];
894 894
 
895 895
 		if ($link_id == "") {
896 896
 			// for shortcut links like [this][] or [this].
@@ -906,10 +906,10 @@  discard block
 block discarded – undo
906 906
 			$url = $this->encodeURLAttribute($url);
907 907
 
908 908
 			$result = "<a href=\"$url\"";
909
-			if ( isset( $this->titles[$link_id] ) ) {
909
+			if (isset($this->titles[$link_id])) {
910 910
 				$title = $this->titles[$link_id];
911 911
 				$title = $this->encodeAttribute($title);
912
-				$result .=  " title=\"$title\"";
912
+				$result .= " title=\"$title\"";
913 913
 			}
914 914
 			if (isset($this->ref_attr[$link_id]))
915 915
 				$result .= $this->ref_attr[$link_id];
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
 	 * @return string
931 931
 	 */
932 932
 	protected function _doAnchors_inline_callback($matches) {
933
-		$link_text		=  $this->runSpanGamut($matches[2]);
934
-		$url			=  $matches[3] === '' ? $matches[4] : $matches[3];
935
-		$title_quote		=& $matches[6];
936
-		$title			=& $matches[7];
937
-		$attr  = $this->doExtraAttributes("a", $dummy =& $matches[8]);
933
+		$link_text = $this->runSpanGamut($matches[2]);
934
+		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
935
+		$title_quote = & $matches[6];
936
+		$title = & $matches[7];
937
+		$attr  = $this->doExtraAttributes("a", $dummy = & $matches[8]);
938 938
 
939 939
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
940 940
 		// tag parser and hashed. Need to reverse the process before using the URL.
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 		$result = "<a href=\"$url\"";
948 948
 		if (isset($title) && $title_quote) {
949 949
 			$title = $this->encodeAttribute($title);
950
-			$result .=  " title=\"$title\"";
950
+			$result .= " title=\"$title\"";
951 951
 		}
952 952
 		$result .= $attr;
953 953
 
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 			if (isset($this->titles[$link_id])) {
1034 1034
 				$title = $this->titles[$link_id];
1035 1035
 				$title = $this->encodeAttribute($title);
1036
-				$result .=  " title=\"$title\"";
1036
+				$result .= " title=\"$title\"";
1037 1037
 			}
1038 1038
 			if (isset($this->ref_attr[$link_id])) {
1039 1039
 				$result .= $this->ref_attr[$link_id];
@@ -1055,18 +1055,18 @@  discard block
 block discarded – undo
1055 1055
 	 * @return string
1056 1056
 	 */
1057 1057
 	protected function _doImages_inline_callback($matches) {
1058
-		$alt_text		= $matches[2];
1058
+		$alt_text = $matches[2];
1059 1059
 		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
1060
-		$title_quote		=& $matches[6];
1061
-		$title			=& $matches[7];
1062
-		$attr  = $this->doExtraAttributes("img", $dummy =& $matches[8]);
1060
+		$title_quote = & $matches[6];
1061
+		$title = & $matches[7];
1062
+		$attr  = $this->doExtraAttributes("img", $dummy = & $matches[8]);
1063 1063
 
1064 1064
 		$alt_text = $this->encodeAttribute($alt_text);
1065 1065
 		$url = $this->encodeURLAttribute($url);
1066 1066
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1067 1067
 		if (isset($title) && $title_quote) {
1068 1068
 			$title = $this->encodeAttribute($title);
1069
-			$result .=  " title=\"$title\""; // $title already quoted
1069
+			$result .= " title=\"$title\""; // $title already quoted
1070 1070
 		}
1071 1071
 		$result .= $attr;
1072 1072
 		$result .= $this->empty_element_suffix;
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 		//
1105 1105
 		$text = preg_replace_callback('{
1106 1106
 				^(\#{1,6})	# $1 = string of #\'s
1107
-				[ ]'.($this->hashtag_protection ? '+' : '*').'
1107
+				[ ]'.($this->hashtag_protection ? '+' : '*') . '
1108 1108
 				(.+?)		# $2 = Header text
1109 1109
 				[ ]*
1110 1110
 				\#*			# optional closing #\'s (not counted)
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 
1132 1132
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
1133 1133
 
1134
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
1134
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId);
1135 1135
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>";
1136 1136
 		return "\n" . $this->hashBlock($block) . "\n\n";
1137 1137
 	}
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 		$level = strlen($matches[1]);
1146 1146
 
1147 1147
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
1148
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
1148
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId);
1149 1149
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>";
1150 1150
 		return "\n" . $this->hashBlock($block) . "\n\n";
1151 1151
 	}
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 	 * @return string
1217 1217
 	 */
1218 1218
 	protected function _doTable_leadingPipe_callback($matches) {
1219
-		$head		= $matches[1];
1220
-		$underline	= $matches[2];
1219
+		$head = $matches[1];
1220
+		$underline = $matches[2];
1221 1221
 		$content	= $matches[3];
1222 1222
 
1223 1223
 		$content	= preg_replace('/^ *[|]/m', '', $content);
@@ -1245,14 +1245,14 @@  discard block
 block discarded – undo
1245 1245
 	 * @return string
1246 1246
 	 */
1247 1247
 	protected function _doTable_callback($matches) {
1248
-		$head		= $matches[1];
1249
-		$underline	= $matches[2];
1250
-		$content	= $matches[3];
1248
+		$head = $matches[1];
1249
+		$underline = $matches[2];
1250
+		$content = $matches[3];
1251 1251
 
1252 1252
 		// Remove any tailing pipes for each line.
1253
-		$head		= preg_replace('/[|] *$/m', '', $head);
1254
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
1255
-		$content	= preg_replace('/[|] *$/m', '', $content);
1253
+		$head = preg_replace('/[|] *$/m', '', $head);
1254
+		$underline = preg_replace('/[|] *$/m', '', $underline);
1255
+		$content = preg_replace('/[|] *$/m', '', $content);
1256 1256
 
1257 1257
 		// Reading alignement from header underline.
1258 1258
 		$separators	= preg_split('/ *[|] */', $underline);
@@ -1269,10 +1269,10 @@  discard block
 block discarded – undo
1269 1269
 
1270 1270
 		// Parsing span elements, including code spans, character escapes,
1271 1271
 		// and inline HTML tags, so that pipes inside those gets ignored.
1272
-		$head		= $this->parseSpan($head);
1273
-		$headers	= preg_split('/ *[|] */', $head);
1274
-		$col_count	= count($headers);
1275
-		$attr       = array_pad($attr, $col_count, '');
1272
+		$head = $this->parseSpan($head);
1273
+		$headers = preg_split('/ *[|] */', $head);
1274
+		$col_count = count($headers);
1275
+		$attr = array_pad($attr, $col_count, '');
1276 1276
 
1277 1277
 		// Write column headers.
1278 1278
 		$text = "<table>\n";
@@ -1440,13 +1440,13 @@  discard block
 block discarded – undo
1440 1440
 	protected function _processDefListItems_callback_dd($matches) {
1441 1441
 		$leading_line	= $matches[1];
1442 1442
 		$marker_space	= $matches[2];
1443
-		$def			= $matches[3];
1443
+		$def = $matches[3];
1444 1444
 
1445 1445
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
1446 1446
 			// Replace marker with the appropriate whitespace indentation
1447 1447
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1448 1448
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1449
-			$def = "\n". $def ."\n";
1449
+			$def = "\n" . $def . "\n";
1450 1450
 		}
1451 1451
 		else {
1452 1452
 			$def = rtrim($def);
@@ -1506,8 +1506,8 @@  discard block
 block discarded – undo
1506 1506
 	 * @return string
1507 1507
 	 */
1508 1508
 	protected function _doFencedCodeBlocks_callback($matches) {
1509
-		$classname =& $matches[2];
1510
-		$attrs     =& $matches[3];
1509
+		$classname = & $matches[2];
1510
+		$attrs     = & $matches[3];
1511 1511
 		$codeblock = $matches[4];
1512 1512
 
1513 1513
 		if ($this->code_block_content_func) {
@@ -1529,9 +1529,9 @@  discard block
 block discarded – undo
1529 1529
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
1530 1530
 		$pre_attr_str  = $this->code_attr_on_pre ? $attr_str : '';
1531 1531
 		$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
1532
-		$codeblock  = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1532
+		$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1533 1533
 
1534
-		return "\n\n".$this->hashBlock($codeblock)."\n\n";
1534
+		return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
1535 1535
 	}
1536 1536
 
1537 1537
 	/**
@@ -1664,9 +1664,9 @@  discard block
 block discarded – undo
1664 1664
 		$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
1665 1665
 			array($this, '_appendFootnotes_callback'), $text);
1666 1666
 
1667
-		if ( ! empty( $this->footnotes_ordered ) ) {
1667
+		if (!empty($this->footnotes_ordered)) {
1668 1668
 			$this->_doFootnotes();
1669
-			if ( ! $this->omit_footnotes ) {
1669
+			if (!$this->omit_footnotes) {
1670 1670
 				$text .= "\n\n";
1671 1671
 				$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
1672 1672
 				$text .= "<hr" . $this->empty_element_suffix . "\n";
@@ -1766,7 +1766,7 @@  discard block
 block discarded – undo
1766 1766
 		// Create footnote marker only if it has a corresponding footnote *and*
1767 1767
 		// the footnote hasn't been used by another marker.
1768 1768
 		if (isset($this->footnotes[$node_id])) {
1769
-			$num =& $this->footnotes_numbers[$node_id];
1769
+			$num = & $this->footnotes_numbers[$node_id];
1770 1770
 			if (!isset($num)) {
1771 1771
 				// Transfer footnote content to the ordered list and give it its
1772 1772
 				// number
@@ -1795,8 +1795,8 @@  discard block
 block discarded – undo
1795 1795
 			$node_id = $this->encodeAttribute($node_id);
1796 1796
 
1797 1797
 			return
1798
-				"<sup id=\"fnref$ref_count_mark:$node_id\">".
1799
-				"<a href=\"#fn:$node_id\"$attr>$num</a>".
1798
+				"<sup id=\"fnref$ref_count_mark:$node_id\">" .
1799
+				"<a href=\"#fn:$node_id\"$attr>$num</a>" .
1800 1800
 				"</sup>";
1801 1801
 		}
1802 1802
 
Please login to merge, or discard this patch.