Passed
Pull Request — lib (#351)
by Aurélien
03:02
created
Michelf/MarkdownExtra.php 1 patch
Braces   +60 added lines, -42 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;
@@ -939,8 +945,9 @@  discard block
 block discarded – undo
939 945
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
940 946
 		// tag parser and hashed. Need to reverse the process before using the URL.
941 947
 		$unhashed = $this->unhash($url);
942
-		if ($unhashed !== $url)
943
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
948
+		if ($unhashed !== $url) {
949
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
950
+		}
944 951
 
945 952
 		$url = $this->encodeURLAttribute($url);
946 953
 
@@ -1033,9 +1040,15 @@  discard block
 block discarded – undo
1033 1040
 			if(file_exists($url))
1034 1041
 			{
1035 1042
 				list($width, $height, $type, $attr) = getimagesize($url);
1036
-				if(isset($width)) $result .= " width=\"$width\"";
1037
-				if(isset($height)) $result .= " height=\"$height\"";
1038
-				if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1043
+				if(isset($width)) {
1044
+					$result .= " width=\"$width\"";
1045
+				}
1046
+				if(isset($height)) {
1047
+					$result .= " height=\"$height\"";
1048
+				}
1049
+				if(isset($width) && isset($height)) {
1050
+					$result .= " loading=\"lazy\"";
1051
+				}
1039 1052
 			}
1040 1053
 			if (isset($this->titles[$link_id])) {
1041 1054
 				$title = $this->titles[$link_id];
@@ -1047,8 +1060,7 @@  discard block
 block discarded – undo
1047 1060
 			}
1048 1061
 			$result .= $this->empty_element_suffix;
1049 1062
 			$result = $this->hashPart($result);
1050
-		}
1051
-		else {
1063
+		} else {
1052 1064
 			// If there's no such link ID, leave intact:
1053 1065
 			$result = $whole_match;
1054 1066
 		}
@@ -1074,9 +1086,15 @@  discard block
 block discarded – undo
1074 1086
 		if(file_exists($url))
1075 1087
 		{
1076 1088
 			list($width, $height, $type, $attr) = getimagesize($url);
1077
-			if(isset($width)) $result .= " width=\"$width\"";
1078
-			if(isset($height)) $result .= " height=\"$height\"";
1079
-			if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1089
+			if(isset($width)) {
1090
+				$result .= " width=\"$width\"";
1091
+			}
1092
+			if(isset($height)) {
1093
+				$result .= " height=\"$height\"";
1094
+			}
1095
+			if(isset($width) && isset($height)) {
1096
+				$result .= " loading=\"lazy\"";
1097
+			}
1080 1098
 		}
1081 1099
 		if (isset($title) && $title_quote) {
1082 1100
 			$title = $this->encodeAttribute($title);
@@ -1271,14 +1289,15 @@  discard block
 block discarded – undo
1271 1289
 		// Reading alignement from header underline.
1272 1290
 		$separators	= preg_split('/ *[|] */', $underline);
1273 1291
 		foreach ($separators as $n => $s) {
1274
-			if (preg_match('/^ *-+: *$/', $s))
1275
-				$attr[$n] = $this->_doTable_makeAlignAttr('right');
1276
-			else if (preg_match('/^ *:-+: *$/', $s))
1277
-				$attr[$n] = $this->_doTable_makeAlignAttr('center');
1278
-			else if (preg_match('/^ *:-+ *$/', $s))
1279
-				$attr[$n] = $this->_doTable_makeAlignAttr('left');
1280
-			else
1281
-				$attr[$n] = '';
1292
+			if (preg_match('/^ *-+: *$/', $s)) {
1293
+							$attr[$n] = $this->_doTable_makeAlignAttr('right');
1294
+			} else if (preg_match('/^ *:-+: *$/', $s)) {
1295
+							$attr[$n] = $this->_doTable_makeAlignAttr('center');
1296
+			} else if (preg_match('/^ *:-+ *$/', $s)) {
1297
+							$attr[$n] = $this->_doTable_makeAlignAttr('left');
1298
+			} else {
1299
+							$attr[$n] = '';
1300
+			}
1282 1301
 		}
1283 1302
 
1284 1303
 		// Parsing span elements, including code spans, character escapes,
@@ -1461,8 +1480,7 @@  discard block
 block discarded – undo
1461 1480
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1462 1481
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1463 1482
 			$def = "\n". $def ."\n";
1464
-		}
1465
-		else {
1483
+		} else {
1466 1484
 			$def = rtrim($def);
1467 1485
 			$def = $this->runSpanGamut($this->outdent($def));
1468 1486
 		}
Please login to merge, or discard this patch.
Michelf/Markdown.php 1 patch
Braces   +21 added lines, -8 removed lines patch added patch discarded remove patch
@@ -775,8 +775,9 @@  discard block
 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
 
@@ -867,9 +868,15 @@  discard block
 block discarded – undo
867 868
 			if(file_exists($url))
868 869
 			{
869 870
 				list($width, $height, $type, $attr) = getimagesize($url);
870
-				if(isset($width)) $result .= " width=\"$width\"";
871
-				if(isset($height)) $result .= " height=\"$height\"";
872
-				if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
871
+				if(isset($width)) {
872
+					$result .= " width=\"$width\"";
873
+				}
874
+				if(isset($height)) {
875
+					$result .= " height=\"$height\"";
876
+				}
877
+				if(isset($width) && isset($height)) {
878
+					$result .= " loading=\"lazy\"";
879
+				}
873 880
 			}
874 881
 			if (isset($this->titles[$link_id])) {
875 882
 				$title = $this->titles[$link_id];
@@ -903,9 +910,15 @@  discard block
 block discarded – undo
903 910
 		if(file_exists($url))
904 911
 		{
905 912
 			list($width, $height, $type, $attr) = getimagesize($url);
906
-			if(isset($width)) $result .= " width=\"$width\"";
907
-			if(isset($height)) $result .= " height=\"$height\"";
908
-			if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
913
+			if(isset($width)) {
914
+				$result .= " width=\"$width\"";
915
+			}
916
+			if(isset($height)) {
917
+				$result .= " height=\"$height\"";
918
+			}
919
+			if(isset($width) && isset($height)) {
920
+				$result .= " loading=\"lazy\"";
921
+			}
909 922
 		}
910 923
 		if (isset($title)) {
911 924
 			$title = $this->encodeAttribute($title);
Please login to merge, or discard this patch.