Passed
Pull Request — lib (#351)
by Aurélien
03:02
created
Michelf/MarkdownExtra.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 * @param  integer $indent
415 415
 	 * @param  string  $enclosing_tag_re
416 416
 	 * @param  boolean $span
417
-	 * @return array
417
+	 * @return string[]
418 418
 	 */
419 419
 	protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
420 420
 										$enclosing_tag_re = '', $span = false)
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 	 * @param  string $text
630 630
 	 * @param  string $hash_method
631 631
 	 * @param  bool $md_attr Handle `markdown="1"` attribute
632
-	 * @return array
632
+	 * @return string[]
633 633
 	 */
634 634
 	protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
635 635
 		if ($text === '') return array('', '');
Please login to merge, or discard this patch.
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.
Spacing   +72 added lines, -72 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
 
@@ -1030,17 +1030,17 @@  discard block
 block discarded – undo
1030 1030
 		if (isset($this->urls[$link_id])) {
1031 1031
 			$url = $this->encodeURLAttribute($this->urls[$link_id]);
1032 1032
 			$result = "<img src=\"$url\" alt=\"$alt_text\"";
1033
-			if(file_exists($url))
1033
+			if (file_exists($url))
1034 1034
 			{
1035 1035
 				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\"";
1036
+				if (isset($width)) $result .= " width=\"$width\"";
1037
+				if (isset($height)) $result .= " height=\"$height\"";
1038
+				if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1039 1039
 			}
1040 1040
 			if (isset($this->titles[$link_id])) {
1041 1041
 				$title = $this->titles[$link_id];
1042 1042
 				$title = $this->encodeAttribute($title);
1043
-				$result .=  " title=\"$title\"";
1043
+				$result .= " title=\"$title\"";
1044 1044
 			}
1045 1045
 			if (isset($this->ref_attr[$link_id])) {
1046 1046
 				$result .= $this->ref_attr[$link_id];
@@ -1062,25 +1062,25 @@  discard block
 block discarded – undo
1062 1062
 	 * @return string
1063 1063
 	 */
1064 1064
 	protected function _doImages_inline_callback($matches) {
1065
-		$alt_text		= $matches[2];
1065
+		$alt_text = $matches[2];
1066 1066
 		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
1067
-		$title_quote		=& $matches[6];
1068
-		$title			=& $matches[7];
1069
-		$attr  = $this->doExtraAttributes("img", $dummy =& $matches[8]);
1067
+		$title_quote = & $matches[6];
1068
+		$title = & $matches[7];
1069
+		$attr  = $this->doExtraAttributes("img", $dummy = & $matches[8]);
1070 1070
 
1071 1071
 		$alt_text = $this->encodeAttribute($alt_text);
1072 1072
 		$url = $this->encodeURLAttribute($url);
1073 1073
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1074
-		if(file_exists($url))
1074
+		if (file_exists($url))
1075 1075
 		{
1076 1076
 			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\"";
1077
+			if (isset($width)) $result .= " width=\"$width\"";
1078
+			if (isset($height)) $result .= " height=\"$height\"";
1079
+			if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1080 1080
 		}
1081 1081
 		if (isset($title) && $title_quote) {
1082 1082
 			$title = $this->encodeAttribute($title);
1083
-			$result .=  " title=\"$title\""; // $title already quoted
1083
+			$result .= " title=\"$title\""; // $title already quoted
1084 1084
 		}
1085 1085
 		$result .= $attr;
1086 1086
 		$result .= $this->empty_element_suffix;
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		//
1119 1119
 		$text = preg_replace_callback('{
1120 1120
 				^(\#{1,6})	# $1 = string of #\'s
1121
-				[ ]'.($this->hashtag_protection ? '+' : '*').'
1121
+				[ ]'.($this->hashtag_protection ? '+' : '*') . '
1122 1122
 				(.+?)		# $2 = Header text
1123 1123
 				[ ]*
1124 1124
 				\#*			# optional closing #\'s (not counted)
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 
1146 1146
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
1147 1147
 
1148
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
1148
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId);
1149 1149
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>";
1150 1150
 		return "\n" . $this->hashBlock($block) . "\n\n";
1151 1151
 	}
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 		$level = strlen($matches[1]);
1160 1160
 
1161 1161
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
1162
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
1162
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId);
1163 1163
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>";
1164 1164
 		return "\n" . $this->hashBlock($block) . "\n\n";
1165 1165
 	}
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
 	 * @return string
1231 1231
 	 */
1232 1232
 	protected function _doTable_leadingPipe_callback($matches) {
1233
-		$head		= $matches[1];
1234
-		$underline	= $matches[2];
1233
+		$head = $matches[1];
1234
+		$underline = $matches[2];
1235 1235
 		$content	= $matches[3];
1236 1236
 
1237 1237
 		$content	= preg_replace('/^ *[|]/m', '', $content);
@@ -1259,14 +1259,14 @@  discard block
 block discarded – undo
1259 1259
 	 * @return string
1260 1260
 	 */
1261 1261
 	protected function _doTable_callback($matches) {
1262
-		$head		= $matches[1];
1263
-		$underline	= $matches[2];
1264
-		$content	= $matches[3];
1262
+		$head = $matches[1];
1263
+		$underline = $matches[2];
1264
+		$content = $matches[3];
1265 1265
 
1266 1266
 		// Remove any tailing pipes for each line.
1267
-		$head		= preg_replace('/[|] *$/m', '', $head);
1268
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
1269
-		$content	= preg_replace('/[|] *$/m', '', $content);
1267
+		$head = preg_replace('/[|] *$/m', '', $head);
1268
+		$underline = preg_replace('/[|] *$/m', '', $underline);
1269
+		$content = preg_replace('/[|] *$/m', '', $content);
1270 1270
 
1271 1271
 		// Reading alignement from header underline.
1272 1272
 		$separators	= preg_split('/ *[|] */', $underline);
@@ -1283,10 +1283,10 @@  discard block
 block discarded – undo
1283 1283
 
1284 1284
 		// Parsing span elements, including code spans, character escapes,
1285 1285
 		// and inline HTML tags, so that pipes inside those gets ignored.
1286
-		$head		= $this->parseSpan($head);
1287
-		$headers	= preg_split('/ *[|] */', $head);
1288
-		$col_count	= count($headers);
1289
-		$attr       = array_pad($attr, $col_count, '');
1286
+		$head = $this->parseSpan($head);
1287
+		$headers = preg_split('/ *[|] */', $head);
1288
+		$col_count = count($headers);
1289
+		$attr = array_pad($attr, $col_count, '');
1290 1290
 
1291 1291
 		// Write column headers.
1292 1292
 		$text = "<table>\n";
@@ -1454,13 +1454,13 @@  discard block
 block discarded – undo
1454 1454
 	protected function _processDefListItems_callback_dd($matches) {
1455 1455
 		$leading_line	= $matches[1];
1456 1456
 		$marker_space	= $matches[2];
1457
-		$def			= $matches[3];
1457
+		$def = $matches[3];
1458 1458
 
1459 1459
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
1460 1460
 			// Replace marker with the appropriate whitespace indentation
1461 1461
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1462 1462
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1463
-			$def = "\n". $def ."\n";
1463
+			$def = "\n" . $def . "\n";
1464 1464
 		}
1465 1465
 		else {
1466 1466
 			$def = rtrim($def);
@@ -1520,8 +1520,8 @@  discard block
 block discarded – undo
1520 1520
 	 * @return string
1521 1521
 	 */
1522 1522
 	protected function _doFencedCodeBlocks_callback($matches) {
1523
-		$classname =& $matches[2];
1524
-		$attrs     =& $matches[3];
1523
+		$classname = & $matches[2];
1524
+		$attrs     = & $matches[3];
1525 1525
 		$codeblock = $matches[4];
1526 1526
 
1527 1527
 		if ($this->code_block_content_func) {
@@ -1543,9 +1543,9 @@  discard block
 block discarded – undo
1543 1543
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
1544 1544
 		$pre_attr_str  = $this->code_attr_on_pre ? $attr_str : '';
1545 1545
 		$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
1546
-		$codeblock  = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1546
+		$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1547 1547
 
1548
-		return "\n\n".$this->hashBlock($codeblock)."\n\n";
1548
+		return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
1549 1549
 	}
1550 1550
 
1551 1551
 	/**
@@ -1678,9 +1678,9 @@  discard block
 block discarded – undo
1678 1678
 		$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
1679 1679
 			array($this, '_appendFootnotes_callback'), $text);
1680 1680
 
1681
-		if ( ! empty( $this->footnotes_ordered ) ) {
1681
+		if (!empty($this->footnotes_ordered)) {
1682 1682
 			$this->_doFootnotes();
1683
-			if ( ! $this->omit_footnotes ) {
1683
+			if (!$this->omit_footnotes) {
1684 1684
 				$text .= "\n\n";
1685 1685
 				$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
1686 1686
 				$text .= "<hr" . $this->empty_element_suffix . "\n";
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
 		// Create footnote marker only if it has a corresponding footnote *and*
1781 1781
 		// the footnote hasn't been used by another marker.
1782 1782
 		if (isset($this->footnotes[$node_id])) {
1783
-			$num =& $this->footnotes_numbers[$node_id];
1783
+			$num = & $this->footnotes_numbers[$node_id];
1784 1784
 			if (!isset($num)) {
1785 1785
 				// Transfer footnote content to the ordered list and give it its
1786 1786
 				// number
@@ -1809,8 +1809,8 @@  discard block
 block discarded – undo
1809 1809
 			$node_id = $this->encodeAttribute($node_id);
1810 1810
 
1811 1811
 			return
1812
-				"<sup id=\"fnref$ref_count_mark:$node_id\">".
1813
-				"<a href=\"#fn:$node_id\"$attr>$num</a>".
1812
+				"<sup id=\"fnref$ref_count_mark:$node_id\">" .
1813
+				"<a href=\"#fn:$node_id\"$attr>$num</a>" .
1814 1814
 				"</sup>";
1815 1815
 		}
1816 1816
 
Please login to merge, or discard this 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.
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/Markdown.php 2 patches
Spacing   +85 added lines, -85 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) {
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 		$this->prepareItalicsAndBold();
158 158
 
159 159
 		$this->nested_brackets_re =
160
-			str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth).
160
+			str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) .
161 161
 			str_repeat('\])*', $this->nested_brackets_depth);
162 162
 
163 163
 		$this->nested_url_parenthesis_re =
164
-			str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth).
164
+			str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) .
165 165
 			str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth);
166 166
 
167
-		$this->escape_chars_re = '['.preg_quote($this->escape_chars).']';
167
+		$this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']';
168 168
 
169 169
 		// Sort document, block, and span gamut in ascendent priority order.
170 170
 		asort($this->document_gamut);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
 		// Link defs are in the form: ^[id]: url "optional title"
285 285
 		$text = preg_replace_callback('{
286
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
286
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
287 287
 							  [ ]*
288 288
 							  \n?				# maybe *one* newline
289 289
 							  [ ]*
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		$link_id = strtolower($matches[1]);
320 320
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
321 321
 		$this->urls[$link_id] = $url;
322
-		$this->titles[$link_id] =& $matches[4];
322
+		$this->titles[$link_id] = & $matches[4];
323 323
 		return ''; // String that will replace the block
324 324
 	}
325 325
 
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 		 * *  List "b" is made of tags which are always block-level;
352 352
 		 */
353 353
 		$block_tags_a_re = 'ins|del';
354
-		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
355
-						   'script|noscript|style|form|fieldset|iframe|math|svg|'.
356
-						   'article|section|nav|aside|hgroup|header|footer|'.
354
+		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' .
355
+						   'script|noscript|style|form|fieldset|iframe|math|svg|' .
356
+						   'article|section|nav|aside|hgroup|header|footer|' .
357 357
 						   'figure|details|summary';
358 358
 
359 359
 		// Regular expression for the content of a block tag.
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
 				  [^<]+			# content without tag
379 379
 				|
380 380
 				  <\2			# nested opening tag
381
-					'.$attr.'	# attributes
381
+					'.$attr . '	# attributes
382 382
 					(?>
383 383
 					  />
384 384
 					|
385
-					  >', $nested_tags_level).	// end of opening tag
386
-					  '.*?'.					// last level nested tag content
385
+					  >', $nested_tags_level) . // end of opening tag
386
+					  '.*?' . // last level nested tag content
387 387
 			str_repeat('
388 388
 					  </\2\s*>	# closing nested tag
389 389
 					)
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
 			  # Match from `\n<tag>` to `</tag>\n`, handling nested tags
420 420
 			  # in between.
421 421
 
422
-						[ ]{0,'.$less_than_tab.'}
423
-						<('.$block_tags_b_re.')# start tag = $2
424
-						'.$attr.'>			# attributes followed by > and \n
425
-						'.$content.'		# content, support nesting
422
+						[ ]{0,'.$less_than_tab . '}
423
+						<('.$block_tags_b_re . ')# start tag = $2
424
+						'.$attr . '>			# attributes followed by > and \n
425
+						'.$content . '		# content, support nesting
426 426
 						</\2>				# the matching end tag
427 427
 						[ ]*				# trailing spaces/tabs
428 428
 						(?=\n+|\Z)	# followed by a newline or end of document
429 429
 
430 430
 			| # Special version for tags of group a.
431 431
 
432
-						[ ]{0,'.$less_than_tab.'}
433
-						<('.$block_tags_a_re.')# start tag = $3
434
-						'.$attr.'>[ ]*\n	# attributes followed by >
435
-						'.$content2.'		# content, support nesting
432
+						[ ]{0,'.$less_than_tab . '}
433
+						<('.$block_tags_a_re . ')# start tag = $3
434
+						'.$attr . '>[ ]*\n	# attributes followed by >
435
+						'.$content2 . '		# content, support nesting
436 436
 						</\3>				# the matching end tag
437 437
 						[ ]*				# trailing spaces/tabs
438 438
 						(?=\n+|\Z)	# followed by a newline or end of document
@@ -440,16 +440,16 @@  discard block
 block discarded – undo
440 440
 			| # Special case just for <hr />. It was easier to make a special
441 441
 			  # case than to make the other regex more complicated.
442 442
 
443
-						[ ]{0,'.$less_than_tab.'}
443
+						[ ]{0,'.$less_than_tab . '}
444 444
 						<(hr)				# start tag = $2
445
-						'.$attr.'			# attributes
445
+						'.$attr . '			# attributes
446 446
 						/?>					# the matching end tag
447 447
 						[ ]*
448 448
 						(?=\n{2,}|\Z)		# followed by a blank line or end of document
449 449
 
450 450
 			| # Special case for standalone HTML comments:
451 451
 
452
-					[ ]{0,'.$less_than_tab.'}
452
+					[ ]{0,'.$less_than_tab . '}
453 453
 					(?s:
454 454
 						<!-- .*? -->
455 455
 					)
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
 			| # PHP and ASP-style processor instructions (<? and <%)
460 460
 
461
-					[ ]{0,'.$less_than_tab.'}
461
+					[ ]{0,'.$less_than_tab . '}
462 462
 					(?s:
463 463
 						<([?%])			# $2
464 464
 						.*?
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 				[ ]*		# Tailing spaces
590 590
 				$			# End of line.
591 591
 			}mx',
592
-			"\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n",
592
+			"\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n",
593 593
 			$text
594 594
 		);
595 595
 	}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		$text = preg_replace_callback('{
669 669
 			(					# wrap whole match in $1
670 670
 			  \[
671
-				('.$this->nested_brackets_re.')	# link text = $2
671
+				('.$this->nested_brackets_re . ')	# link text = $2
672 672
 			  \]
673 673
 
674 674
 			  [ ]?				# one optional space
@@ -685,14 +685,14 @@  discard block
 block discarded – undo
685 685
 		$text = preg_replace_callback('{
686 686
 			(				# wrap whole match in $1
687 687
 			  \[
688
-				('.$this->nested_brackets_re.')	# link text = $2
688
+				('.$this->nested_brackets_re . ')	# link text = $2
689 689
 			  \]
690 690
 			  \(			# literal paren
691 691
 				[ \n]*
692 692
 				(?:
693 693
 					<(.+?)>	# href = $3
694 694
 				|
695
-					('.$this->nested_url_parenthesis_re.')	# href = $4
695
+					('.$this->nested_url_parenthesis_re . ')	# href = $4
696 696
 				)
697 697
 				[ \n]*
698 698
 				(			# $5
@@ -728,9 +728,9 @@  discard block
 block discarded – undo
728 728
 	 * @return string
729 729
 	 */
730 730
 	protected function _doAnchors_reference_callback($matches) {
731
-		$whole_match =  $matches[1];
732
-		$link_text   =  $matches[2];
733
-		$link_id     =& $matches[3];
731
+		$whole_match = $matches[1];
732
+		$link_text   = $matches[2];
733
+		$link_id     = & $matches[3];
734 734
 
735 735
 		if ($link_id == "") {
736 736
 			// for shortcut links like [this][] or [this].
@@ -746,10 +746,10 @@  discard block
 block discarded – undo
746 746
 			$url = $this->encodeURLAttribute($url);
747 747
 
748 748
 			$result = "<a href=\"$url\"";
749
-			if ( isset( $this->titles[$link_id] ) ) {
749
+			if (isset($this->titles[$link_id])) {
750 750
 				$title = $this->titles[$link_id];
751 751
 				$title = $this->encodeAttribute($title);
752
-				$result .=  " title=\"$title\"";
752
+				$result .= " title=\"$title\"";
753 753
 			}
754 754
 
755 755
 			$link_text = $this->runSpanGamut($link_text);
@@ -767,9 +767,9 @@  discard block
 block discarded – undo
767 767
 	 * @return string
768 768
 	 */
769 769
 	protected function _doAnchors_inline_callback($matches) {
770
-		$link_text		=  $this->runSpanGamut($matches[2]);
771
-		$url			=  $matches[3] === '' ? $matches[4] : $matches[3];
772
-		$title			=& $matches[7];
770
+		$link_text = $this->runSpanGamut($matches[2]);
771
+		$url = $matches[3] === '' ? $matches[4] : $matches[3];
772
+		$title = & $matches[7];
773 773
 
774 774
 		// If the URL was of the form <s p a c e s> it got caught by the HTML
775 775
 		// tag parser and hashed. Need to reverse the process before using
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 		$result = "<a href=\"$url\"";
784 784
 		if (isset($title)) {
785 785
 			$title = $this->encodeAttribute($title);
786
-			$result .=  " title=\"$title\"";
786
+			$result .= " title=\"$title\"";
787 787
 		}
788 788
 
789 789
 		$link_text = $this->runSpanGamut($link_text);
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 		$text = preg_replace_callback('{
803 803
 			(				# wrap whole match in $1
804 804
 			  !\[
805
-				('.$this->nested_brackets_re.')		# alt text = $2
805
+				('.$this->nested_brackets_re . ')		# alt text = $2
806 806
 			  \]
807 807
 
808 808
 			  [ ]?				# one optional space
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 		$text = preg_replace_callback('{
822 822
 			(				# wrap whole match in $1
823 823
 			  !\[
824
-				('.$this->nested_brackets_re.')		# alt text = $2
824
+				('.$this->nested_brackets_re . ')		# alt text = $2
825 825
 			  \]
826 826
 			  \s?			# One optional whitespace character
827 827
 			  \(			# literal paren
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 				(?:
830 830
 					<(\S*)>	# src url = $3
831 831
 				|
832
-					('.$this->nested_url_parenthesis_re.')	# src url = $4
832
+					('.$this->nested_url_parenthesis_re . ')	# src url = $4
833 833
 				)
834 834
 				[ \n]*
835 835
 				(			# $5
@@ -864,17 +864,17 @@  discard block
 block discarded – undo
864 864
 		if (isset($this->urls[$link_id])) {
865 865
 			$url = $this->encodeURLAttribute($this->urls[$link_id]);
866 866
 			$result = "<img src=\"$url\" alt=\"$alt_text\"";
867
-			if(file_exists($url))
867
+			if (file_exists($url))
868 868
 			{
869 869
 				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\"";
870
+				if (isset($width)) $result .= " width=\"$width\"";
871
+				if (isset($height)) $result .= " height=\"$height\"";
872
+				if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
873 873
 			}
874 874
 			if (isset($this->titles[$link_id])) {
875 875
 				$title = $this->titles[$link_id];
876 876
 				$title = $this->encodeAttribute($title);
877
-				$result .=  " title=\"$title\"";
877
+				$result .= " title=\"$title\"";
878 878
 			}
879 879
 			$result .= $this->empty_element_suffix;
880 880
 			$result = $this->hashPart($result);
@@ -892,24 +892,24 @@  discard block
 block discarded – undo
892 892
 	 * @return string
893 893
 	 */
894 894
 	protected function _doImages_inline_callback($matches) {
895
-		$whole_match	= $matches[1];
896
-		$alt_text		= $matches[2];
897
-		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
898
-		$title			=& $matches[7];
895
+		$whole_match = $matches[1];
896
+		$alt_text = $matches[2];
897
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
898
+		$title = & $matches[7];
899 899
 
900 900
 		$alt_text = $this->encodeAttribute($alt_text);
901 901
 		$url = $this->encodeURLAttribute($url);
902 902
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
903
-		if(file_exists($url))
903
+		if (file_exists($url))
904 904
 		{
905 905
 			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\"";
906
+			if (isset($width)) $result .= " width=\"$width\"";
907
+			if (isset($height)) $result .= " height=\"$height\"";
908
+			if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
909 909
 		}
910 910
 		if (isset($title)) {
911 911
 			$title = $this->encodeAttribute($title);
912
-			$result .=  " title=\"$title\""; // $title already quoted
912
+			$result .= " title=\"$title\""; // $title already quoted
913 913
 		}
914 914
 		$result .= $this->empty_element_suffix;
915 915
 
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 		// ID attribute generation
971 971
 		$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
972 972
 
973
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[1])."</h$level>";
973
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[1]) . "</h$level>";
974 974
 		return "\n" . $this->hashBlock($block) . "\n\n";
975 975
 	}
976 976
 
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 		$idAtt = $this->_generateIdFromHeaderValue($matches[2]);
985 985
 
986 986
 		$level = strlen($matches[1]);
987
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[2])."</h$level>";
987
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[2]) . "</h$level>";
988 988
 		return "\n" . $this->hashBlock($block) . "\n\n";
989 989
 	}
990 990
 
@@ -1032,8 +1032,8 @@  discard block
 block discarded – undo
1032 1032
 			$whole_list_re = '
1033 1033
 				(								# $1 = whole list
1034 1034
 				  (								# $2
1035
-					([ ]{0,'.$less_than_tab.'})	# $3 = number of spaces
1036
-					('.$marker_re.')			# $4 = first list item marker
1035
+					([ ]{0,'.$less_than_tab . '})	# $3 = number of spaces
1036
+					('.$marker_re . ')			# $4 = first list item marker
1037 1037
 					[ ]+
1038 1038
 				  )
1039 1039
 				  (?s:.+?)
@@ -1044,13 +1044,13 @@  discard block
 block discarded – undo
1044 1044
 					  (?=\S)
1045 1045
 					  (?!						# Negative lookahead for another list item marker
1046 1046
 						[ ]*
1047
-						'.$marker_re.'[ ]+
1047
+						'.$marker_re . '[ ]+
1048 1048
 					  )
1049 1049
 					|
1050 1050
 					  (?=						# Lookahead for another kind of list
1051 1051
 					    \n
1052 1052
 						\3						# Must have the same indentation
1053
-						'.$other_marker_re.'[ ]+
1053
+						'.$other_marker_re . '[ ]+
1054 1054
 					  )
1055 1055
 				  )
1056 1056
 				)
@@ -1062,13 +1062,13 @@  discard block
 block discarded – undo
1062 1062
 			if ($this->list_level) {
1063 1063
 				$text = preg_replace_callback('{
1064 1064
 						^
1065
-						'.$whole_list_re.'
1065
+						'.$whole_list_re . '
1066 1066
 					}mx',
1067 1067
 					array($this, '_doLists_callback'), $text);
1068 1068
 			} else {
1069 1069
 				$text = preg_replace_callback('{
1070 1070
 						(?:(?<=\n)\n|\A\n?) # Must eat the newline
1071
-						'.$whole_list_re.'
1071
+						'.$whole_list_re . '
1072 1072
 					}mx',
1073 1073
 					array($this, '_doLists_callback'), $text);
1074 1074
 			}
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 		$list = $matches[1];
1093 1093
 		$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
1094 1094
 
1095
-		$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
1095
+		$marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re);
1096 1096
 
1097 1097
 		$list .= "\n";
1098 1098
 		$result = $this->processListItems($list, $marker_any_re);
@@ -1103,18 +1103,18 @@  discard block
 block discarded – undo
1103 1103
 			if ($list_type == 'ol') {
1104 1104
 				$ol_start_array = array();
1105 1105
 				$ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array);
1106
-				if ($ol_start_check){
1106
+				if ($ol_start_check) {
1107 1107
 					$ol_start = $ol_start_array[0];
1108 1108
 				}
1109 1109
 			}
1110 1110
 		}
1111 1111
 
1112
-		if ($ol_start > 1 && $list_type == 'ol'){
1112
+		if ($ol_start > 1 && $list_type == 'ol') {
1113 1113
 			$result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>");
1114 1114
 		} else {
1115 1115
 			$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
1116 1116
 		}
1117
-		return "\n". $result ."\n\n";
1117
+		return "\n" . $result . "\n\n";
1118 1118
 	}
1119 1119
 
1120 1120
 	/**
@@ -1161,12 +1161,12 @@  discard block
 block discarded – undo
1161 1161
 		$list_str = preg_replace_callback('{
1162 1162
 			(\n)?							# leading line = $1
1163 1163
 			(^[ ]*)							# leading whitespace = $2
1164
-			('.$marker_any_re.'				# list marker and space = $3
1164
+			('.$marker_any_re . '				# list marker and space = $3
1165 1165
 				(?:[ ]+|(?=\n))	# space only required if item is not empty
1166 1166
 			)
1167 1167
 			((?s:.*?))						# list item text   = $4
1168 1168
 			(?:(\n+(?=\n))|\n)				# tailing blank line = $5
1169
-			(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
1169
+			(?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n))))
1170 1170
 			}xm',
1171 1171
 			array($this, '_processListItems_callback'), $list_str);
1172 1172
 
@@ -1181,17 +1181,17 @@  discard block
 block discarded – undo
1181 1181
 	 */
1182 1182
 	protected function _processListItems_callback($matches) {
1183 1183
 		$item = $matches[4];
1184
-		$leading_line =& $matches[1];
1185
-		$leading_space =& $matches[2];
1184
+		$leading_line = & $matches[1];
1185
+		$leading_space = & $matches[2];
1186 1186
 		$marker_space = $matches[3];
1187
-		$tailing_blank_line =& $matches[5];
1187
+		$tailing_blank_line = & $matches[5];
1188 1188
 
1189 1189
 		if ($leading_line || $tailing_blank_line ||
1190 1190
 			preg_match('/\n{2,}/', $item))
1191 1191
 		{
1192 1192
 			// Replace marker with the appropriate whitespace indentation
1193 1193
 			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1194
-			$item = $this->runBlockGamut($this->outdent($item)."\n");
1194
+			$item = $this->runBlockGamut($this->outdent($item) . "\n");
1195 1195
 		} else {
1196 1196
 			// Recursion for sub-lists:
1197 1197
 			$item = $this->doLists($this->outdent($item));
@@ -1211,11 +1211,11 @@  discard block
 block discarded – undo
1211 1211
 				(?:\n\n|\A\n?)
1212 1212
 				(	            # $1 = the code block -- one or more lines, starting with a space/tab
1213 1213
 				  (?>
1214
-					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces
1214
+					[ ]{'.$this->tab_width . '}  # Lines must start with a tab or a tab-width of spaces
1215 1215
 					.*\n+
1216 1216
 				  )+
1217 1217
 				)
1218
-				((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1218
+				((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1219 1219
 			}xm',
1220 1220
 			array($this, '_doCodeBlocks_callback'), $text);
1221 1221
 
@@ -1343,8 +1343,8 @@  discard block
 block discarded – undo
1343 1343
 			// Each token is then passed to handleSpanToken.
1344 1344
 			$parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
1345 1345
 			$text_stack[0] .= $parts[0];
1346
-			$token =& $parts[1];
1347
-			$text =& $parts[2];
1346
+			$token = & $parts[1];
1347
+			$text = & $parts[2];
1348 1348
 
1349 1349
 			if (empty($token)) {
1350 1350
 				// Reached end of text span: empty stack without emitting.
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
 				} else {
1372 1372
 					// Other closing marker: close one em or strong and
1373 1373
 					// change current token state to match the other
1374
-					$token_stack[0] = str_repeat($token[0], 3-$token_len);
1374
+					$token_stack[0] = str_repeat($token[0], 3 - $token_len);
1375 1375
 					$tag = $token_len == 2 ? "strong" : "em";
1376 1376
 					$span = $text_stack[0];
1377 1377
 					$span = $this->runSpanGamut($span);
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 		}
1718 1718
 
1719 1719
 		$chars = preg_split('/(?<!^)(?!$)/', $text);
1720
-		$seed = (int)abs(crc32($text) / strlen($text)); // Deterministic seed.
1720
+		$seed = (int) abs(crc32($text) / strlen($text)); // Deterministic seed.
1721 1721
 
1722 1722
 		foreach ($chars as $key => $char) {
1723 1723
 			$ord = ord($char);
@@ -1730,9 +1730,9 @@  discard block
 block discarded – undo
1730 1730
 				if ($r > 90 && strpos('@"&>', $char) === false) {
1731 1731
 					/* do nothing */
1732 1732
 				} else if ($r < 45) {
1733
-					$chars[$key] = '&#x'.dechex($ord).';';
1733
+					$chars[$key] = '&#x' . dechex($ord) . ';';
1734 1734
 				} else {
1735
-					$chars[$key] = '&#'.$ord.';';
1735
+					$chars[$key] = '&#' . $ord . ';';
1736 1736
 				}
1737 1737
 			}
1738 1738
 		}
@@ -1754,11 +1754,11 @@  discard block
 block discarded – undo
1754 1754
 
1755 1755
 		$span_re = '{
1756 1756
 				(
1757
-					\\\\'.$this->escape_chars_re.'
1757
+					\\\\'.$this->escape_chars_re . '
1758 1758
 				|
1759 1759
 					(?<![`\\\\])
1760 1760
 					`+						# code span marker
1761
-			'.( $this->no_markup ? '' : '
1761
+			'.($this->no_markup ? '' : '
1762 1762
 				|
1763 1763
 					<!--    .*?     -->		# comment
1764 1764
 				|
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 					<[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag
1775 1775
 				|
1776 1776
 					</[-a-zA-Z0-9:_]+\s*> # closing tag
1777
-			').'
1777
+			') . '
1778 1778
 				)
1779 1779
 				}xs';
1780 1780
 
@@ -1811,10 +1811,10 @@  discard block
 block discarded – undo
1811 1811
 	protected function handleSpanToken($token, &$str) {
1812 1812
 		switch ($token[0]) {
1813 1813
 			case "\\":
1814
-				return $this->hashPart("&#". ord($token[1]). ";");
1814
+				return $this->hashPart("&#" . ord($token[1]) . ";");
1815 1815
 			case "`":
1816 1816
 				// Search for end marker in remaining text.
1817
-				if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
1817
+				if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm',
1818 1818
 					$str, $matches))
1819 1819
 				{
1820 1820
 					$str = $matches[2];
Please login to merge, or discard this 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.