Test Failed
Pull Request — lib (#351)
by Aurélien
03:33
created
Michelf/MarkdownExtra.php 2 patches
Spacing   +70 added lines, -70 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
 
@@ -1031,13 +1031,13 @@  discard block
 block discarded – undo
1031 1031
 			$url = $this->encodeURLAttribute($this->urls[$link_id]);
1032 1032
 			$result = "<img src=\"$url\" alt=\"$alt_text\"";
1033 1033
 			list($width, $height, $type, $attr) = getimagesize($url);
1034
-			if(isset($width)) $result .= " width=\"$width\"";
1035
-			if(isset($height)) $result .= " height=\"$height\"";
1036
-			if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1034
+			if (isset($width)) $result .= " width=\"$width\"";
1035
+			if (isset($height)) $result .= " height=\"$height\"";
1036
+			if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1037 1037
 			if (isset($this->titles[$link_id])) {
1038 1038
 				$title = $this->titles[$link_id];
1039 1039
 				$title = $this->encodeAttribute($title);
1040
-				$result .=  " title=\"$title\"";
1040
+				$result .= " title=\"$title\"";
1041 1041
 			}
1042 1042
 			if (isset($this->ref_attr[$link_id])) {
1043 1043
 				$result .= $this->ref_attr[$link_id];
@@ -1059,22 +1059,22 @@  discard block
 block discarded – undo
1059 1059
 	 * @return string
1060 1060
 	 */
1061 1061
 	protected function _doImages_inline_callback($matches) {
1062
-		$alt_text		= $matches[2];
1062
+		$alt_text = $matches[2];
1063 1063
 		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
1064
-		$title_quote		=& $matches[6];
1065
-		$title			=& $matches[7];
1066
-		$attr  = $this->doExtraAttributes("img", $dummy =& $matches[8]);
1064
+		$title_quote = & $matches[6];
1065
+		$title = & $matches[7];
1066
+		$attr  = $this->doExtraAttributes("img", $dummy = & $matches[8]);
1067 1067
 
1068 1068
 		$alt_text = $this->encodeAttribute($alt_text);
1069 1069
 		$url = $this->encodeURLAttribute($url);
1070 1070
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1071 1071
 		list($width, $height, $type, $attr) = getimagesize($url);
1072
-		if(isset($width)) $result .= " width=\"$width\"";
1073
-		if(isset($height)) $result .= " height=\"$height\"";
1074
-		if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1072
+		if (isset($width)) $result .= " width=\"$width\"";
1073
+		if (isset($height)) $result .= " height=\"$height\"";
1074
+		if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1075 1075
 		if (isset($title) && $title_quote) {
1076 1076
 			$title = $this->encodeAttribute($title);
1077
-			$result .=  " title=\"$title\""; // $title already quoted
1077
+			$result .= " title=\"$title\""; // $title already quoted
1078 1078
 		}
1079 1079
 		$result .= $attr;
1080 1080
 		$result .= $this->empty_element_suffix;
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 		//
1113 1113
 		$text = preg_replace_callback('{
1114 1114
 				^(\#{1,6})	# $1 = string of #\'s
1115
-				[ ]'.($this->hashtag_protection ? '+' : '*').'
1115
+				[ ]'.($this->hashtag_protection ? '+' : '*') . '
1116 1116
 				(.+?)		# $2 = Header text
1117 1117
 				[ ]*
1118 1118
 				\#*			# optional closing #\'s (not counted)
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
1141 1141
 
1142
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
1142
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId);
1143 1143
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>";
1144 1144
 		return "\n" . $this->hashBlock($block) . "\n\n";
1145 1145
 	}
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 		$level = strlen($matches[1]);
1154 1154
 
1155 1155
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
1156
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
1156
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId);
1157 1157
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>";
1158 1158
 		return "\n" . $this->hashBlock($block) . "\n\n";
1159 1159
 	}
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 	 * @return string
1225 1225
 	 */
1226 1226
 	protected function _doTable_leadingPipe_callback($matches) {
1227
-		$head		= $matches[1];
1228
-		$underline	= $matches[2];
1227
+		$head = $matches[1];
1228
+		$underline = $matches[2];
1229 1229
 		$content	= $matches[3];
1230 1230
 
1231 1231
 		$content	= preg_replace('/^ *[|]/m', '', $content);
@@ -1253,14 +1253,14 @@  discard block
 block discarded – undo
1253 1253
 	 * @return string
1254 1254
 	 */
1255 1255
 	protected function _doTable_callback($matches) {
1256
-		$head		= $matches[1];
1257
-		$underline	= $matches[2];
1258
-		$content	= $matches[3];
1256
+		$head = $matches[1];
1257
+		$underline = $matches[2];
1258
+		$content = $matches[3];
1259 1259
 
1260 1260
 		// Remove any tailing pipes for each line.
1261
-		$head		= preg_replace('/[|] *$/m', '', $head);
1262
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
1263
-		$content	= preg_replace('/[|] *$/m', '', $content);
1261
+		$head = preg_replace('/[|] *$/m', '', $head);
1262
+		$underline = preg_replace('/[|] *$/m', '', $underline);
1263
+		$content = preg_replace('/[|] *$/m', '', $content);
1264 1264
 
1265 1265
 		// Reading alignement from header underline.
1266 1266
 		$separators	= preg_split('/ *[|] */', $underline);
@@ -1277,10 +1277,10 @@  discard block
 block discarded – undo
1277 1277
 
1278 1278
 		// Parsing span elements, including code spans, character escapes,
1279 1279
 		// and inline HTML tags, so that pipes inside those gets ignored.
1280
-		$head		= $this->parseSpan($head);
1281
-		$headers	= preg_split('/ *[|] */', $head);
1282
-		$col_count	= count($headers);
1283
-		$attr       = array_pad($attr, $col_count, '');
1280
+		$head = $this->parseSpan($head);
1281
+		$headers = preg_split('/ *[|] */', $head);
1282
+		$col_count = count($headers);
1283
+		$attr = array_pad($attr, $col_count, '');
1284 1284
 
1285 1285
 		// Write column headers.
1286 1286
 		$text = "<table>\n";
@@ -1448,13 +1448,13 @@  discard block
 block discarded – undo
1448 1448
 	protected function _processDefListItems_callback_dd($matches) {
1449 1449
 		$leading_line	= $matches[1];
1450 1450
 		$marker_space	= $matches[2];
1451
-		$def			= $matches[3];
1451
+		$def = $matches[3];
1452 1452
 
1453 1453
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
1454 1454
 			// Replace marker with the appropriate whitespace indentation
1455 1455
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1456 1456
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1457
-			$def = "\n". $def ."\n";
1457
+			$def = "\n" . $def . "\n";
1458 1458
 		}
1459 1459
 		else {
1460 1460
 			$def = rtrim($def);
@@ -1514,8 +1514,8 @@  discard block
 block discarded – undo
1514 1514
 	 * @return string
1515 1515
 	 */
1516 1516
 	protected function _doFencedCodeBlocks_callback($matches) {
1517
-		$classname =& $matches[2];
1518
-		$attrs     =& $matches[3];
1517
+		$classname = & $matches[2];
1518
+		$attrs     = & $matches[3];
1519 1519
 		$codeblock = $matches[4];
1520 1520
 
1521 1521
 		if ($this->code_block_content_func) {
@@ -1537,9 +1537,9 @@  discard block
 block discarded – undo
1537 1537
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
1538 1538
 		$pre_attr_str  = $this->code_attr_on_pre ? $attr_str : '';
1539 1539
 		$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
1540
-		$codeblock  = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1540
+		$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1541 1541
 
1542
-		return "\n\n".$this->hashBlock($codeblock)."\n\n";
1542
+		return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
1543 1543
 	}
1544 1544
 
1545 1545
 	/**
@@ -1672,9 +1672,9 @@  discard block
 block discarded – undo
1672 1672
 		$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
1673 1673
 			array($this, '_appendFootnotes_callback'), $text);
1674 1674
 
1675
-		if ( ! empty( $this->footnotes_ordered ) ) {
1675
+		if (!empty($this->footnotes_ordered)) {
1676 1676
 			$this->_doFootnotes();
1677
-			if ( ! $this->omit_footnotes ) {
1677
+			if (!$this->omit_footnotes) {
1678 1678
 				$text .= "\n\n";
1679 1679
 				$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
1680 1680
 				$text .= "<hr" . $this->empty_element_suffix . "\n";
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 		// Create footnote marker only if it has a corresponding footnote *and*
1775 1775
 		// the footnote hasn't been used by another marker.
1776 1776
 		if (isset($this->footnotes[$node_id])) {
1777
-			$num =& $this->footnotes_numbers[$node_id];
1777
+			$num = & $this->footnotes_numbers[$node_id];
1778 1778
 			if (!isset($num)) {
1779 1779
 				// Transfer footnote content to the ordered list and give it its
1780 1780
 				// number
@@ -1803,8 +1803,8 @@  discard block
 block discarded – undo
1803 1803
 			$node_id = $this->encodeAttribute($node_id);
1804 1804
 
1805 1805
 			return
1806
-				"<sup id=\"fnref$ref_count_mark:$node_id\">".
1807
-				"<a href=\"#fn:$node_id\"$attr>$num</a>".
1806
+				"<sup id=\"fnref$ref_count_mark:$node_id\">" .
1807
+				"<a href=\"#fn:$node_id\"$attr>$num</a>" .
1808 1808
 				"</sup>";
1809 1809
 		}
1810 1810
 
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
 
@@ -1031,9 +1038,15 @@  discard block
 block discarded – undo
1031 1038
 			$url = $this->encodeURLAttribute($this->urls[$link_id]);
1032 1039
 			$result = "<img src=\"$url\" alt=\"$alt_text\"";
1033 1040
 			list($width, $height, $type, $attr) = getimagesize($url);
1034
-			if(isset($width)) $result .= " width=\"$width\"";
1035
-			if(isset($height)) $result .= " height=\"$height\"";
1036
-			if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1041
+			if(isset($width)) {
1042
+				$result .= " width=\"$width\"";
1043
+			}
1044
+			if(isset($height)) {
1045
+				$result .= " height=\"$height\"";
1046
+			}
1047
+			if(isset($width) && isset($height)) {
1048
+				$result .= " loading=\"lazy\"";
1049
+			}
1037 1050
 			if (isset($this->titles[$link_id])) {
1038 1051
 				$title = $this->titles[$link_id];
1039 1052
 				$title = $this->encodeAttribute($title);
@@ -1044,8 +1057,7 @@  discard block
 block discarded – undo
1044 1057
 			}
1045 1058
 			$result .= $this->empty_element_suffix;
1046 1059
 			$result = $this->hashPart($result);
1047
-		}
1048
-		else {
1060
+		} else {
1049 1061
 			// If there's no such link ID, leave intact:
1050 1062
 			$result = $whole_match;
1051 1063
 		}
@@ -1069,9 +1081,15 @@  discard block
 block discarded – undo
1069 1081
 		$url = $this->encodeURLAttribute($url);
1070 1082
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1071 1083
 		list($width, $height, $type, $attr) = getimagesize($url);
1072
-		if(isset($width)) $result .= " width=\"$width\"";
1073
-		if(isset($height)) $result .= " height=\"$height\"";
1074
-		if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
1084
+		if(isset($width)) {
1085
+			$result .= " width=\"$width\"";
1086
+		}
1087
+		if(isset($height)) {
1088
+			$result .= " height=\"$height\"";
1089
+		}
1090
+		if(isset($width) && isset($height)) {
1091
+			$result .= " loading=\"lazy\"";
1092
+		}
1075 1093
 		if (isset($title) && $title_quote) {
1076 1094
 			$title = $this->encodeAttribute($title);
1077 1095
 			$result .=  " title=\"$title\""; // $title already quoted
@@ -1265,14 +1283,15 @@  discard block
 block discarded – undo
1265 1283
 		// Reading alignement from header underline.
1266 1284
 		$separators	= preg_split('/ *[|] */', $underline);
1267 1285
 		foreach ($separators as $n => $s) {
1268
-			if (preg_match('/^ *-+: *$/', $s))
1269
-				$attr[$n] = $this->_doTable_makeAlignAttr('right');
1270
-			else if (preg_match('/^ *:-+: *$/', $s))
1271
-				$attr[$n] = $this->_doTable_makeAlignAttr('center');
1272
-			else if (preg_match('/^ *:-+ *$/', $s))
1273
-				$attr[$n] = $this->_doTable_makeAlignAttr('left');
1274
-			else
1275
-				$attr[$n] = '';
1286
+			if (preg_match('/^ *-+: *$/', $s)) {
1287
+							$attr[$n] = $this->_doTable_makeAlignAttr('right');
1288
+			} else if (preg_match('/^ *:-+: *$/', $s)) {
1289
+							$attr[$n] = $this->_doTable_makeAlignAttr('center');
1290
+			} else if (preg_match('/^ *:-+ *$/', $s)) {
1291
+							$attr[$n] = $this->_doTable_makeAlignAttr('left');
1292
+			} else {
1293
+							$attr[$n] = '';
1294
+			}
1276 1295
 		}
1277 1296
 
1278 1297
 		// Parsing span elements, including code spans, character escapes,
@@ -1455,8 +1474,7 @@  discard block
 block discarded – undo
1455 1474
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1456 1475
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1457 1476
 			$def = "\n". $def ."\n";
1458
-		}
1459
-		else {
1477
+		} else {
1460 1478
 			$def = rtrim($def);
1461 1479
 			$def = $this->runSpanGamut($this->outdent($def));
1462 1480
 		}
Please login to merge, or discard this patch.
Michelf/Markdown.php 2 patches
Spacing   +83 added lines, -83 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
@@ -865,13 +865,13 @@  discard block
 block discarded – undo
865 865
 			$url = $this->encodeURLAttribute($this->urls[$link_id]);
866 866
 			$result = "<img src=\"$url\" alt=\"$alt_text\"";
867 867
 			list($width, $height, $type, $attr) = getimagesize($url);
868
-			if(isset($width)) $result .= " width=\"$width\"";
869
-			if(isset($height)) $result .= " height=\"$height\"";
870
-			if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
868
+			if (isset($width)) $result .= " width=\"$width\"";
869
+			if (isset($height)) $result .= " height=\"$height\"";
870
+			if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
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->empty_element_suffix;
877 877
 			$result = $this->hashPart($result);
@@ -889,21 +889,21 @@  discard block
 block discarded – undo
889 889
 	 * @return string
890 890
 	 */
891 891
 	protected function _doImages_inline_callback($matches) {
892
-		$whole_match	= $matches[1];
893
-		$alt_text		= $matches[2];
894
-		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
895
-		$title			=& $matches[7];
892
+		$whole_match = $matches[1];
893
+		$alt_text = $matches[2];
894
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
895
+		$title = & $matches[7];
896 896
 
897 897
 		$alt_text = $this->encodeAttribute($alt_text);
898 898
 		$url = $this->encodeURLAttribute($url);
899 899
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
900 900
 		list($width, $height, $type, $attr) = getimagesize($url);
901
-		if(isset($width)) $result .= " width=\"$width\"";
902
-		if(isset($height)) $result .= " height=\"$height\"";
903
-		if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
901
+		if (isset($width)) $result .= " width=\"$width\"";
902
+		if (isset($height)) $result .= " height=\"$height\"";
903
+		if (isset($width) && isset($height)) $result .= " loading=\"lazy\"";
904 904
 		if (isset($title)) {
905 905
 			$title = $this->encodeAttribute($title);
906
-			$result .=  " title=\"$title\""; // $title already quoted
906
+			$result .= " title=\"$title\""; // $title already quoted
907 907
 		}
908 908
 		$result .= $this->empty_element_suffix;
909 909
 
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 		// ID attribute generation
965 965
 		$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
966 966
 
967
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[1])."</h$level>";
967
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[1]) . "</h$level>";
968 968
 		return "\n" . $this->hashBlock($block) . "\n\n";
969 969
 	}
970 970
 
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 		$idAtt = $this->_generateIdFromHeaderValue($matches[2]);
979 979
 
980 980
 		$level = strlen($matches[1]);
981
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[2])."</h$level>";
981
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[2]) . "</h$level>";
982 982
 		return "\n" . $this->hashBlock($block) . "\n\n";
983 983
 	}
984 984
 
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 			$whole_list_re = '
1027 1027
 				(								# $1 = whole list
1028 1028
 				  (								# $2
1029
-					([ ]{0,'.$less_than_tab.'})	# $3 = number of spaces
1030
-					('.$marker_re.')			# $4 = first list item marker
1029
+					([ ]{0,'.$less_than_tab . '})	# $3 = number of spaces
1030
+					('.$marker_re . ')			# $4 = first list item marker
1031 1031
 					[ ]+
1032 1032
 				  )
1033 1033
 				  (?s:.+?)
@@ -1038,13 +1038,13 @@  discard block
 block discarded – undo
1038 1038
 					  (?=\S)
1039 1039
 					  (?!						# Negative lookahead for another list item marker
1040 1040
 						[ ]*
1041
-						'.$marker_re.'[ ]+
1041
+						'.$marker_re . '[ ]+
1042 1042
 					  )
1043 1043
 					|
1044 1044
 					  (?=						# Lookahead for another kind of list
1045 1045
 					    \n
1046 1046
 						\3						# Must have the same indentation
1047
-						'.$other_marker_re.'[ ]+
1047
+						'.$other_marker_re . '[ ]+
1048 1048
 					  )
1049 1049
 				  )
1050 1050
 				)
@@ -1056,13 +1056,13 @@  discard block
 block discarded – undo
1056 1056
 			if ($this->list_level) {
1057 1057
 				$text = preg_replace_callback('{
1058 1058
 						^
1059
-						'.$whole_list_re.'
1059
+						'.$whole_list_re . '
1060 1060
 					}mx',
1061 1061
 					array($this, '_doLists_callback'), $text);
1062 1062
 			} else {
1063 1063
 				$text = preg_replace_callback('{
1064 1064
 						(?:(?<=\n)\n|\A\n?) # Must eat the newline
1065
-						'.$whole_list_re.'
1065
+						'.$whole_list_re . '
1066 1066
 					}mx',
1067 1067
 					array($this, '_doLists_callback'), $text);
1068 1068
 			}
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 		$list = $matches[1];
1087 1087
 		$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
1088 1088
 
1089
-		$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
1089
+		$marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re);
1090 1090
 
1091 1091
 		$list .= "\n";
1092 1092
 		$result = $this->processListItems($list, $marker_any_re);
@@ -1097,18 +1097,18 @@  discard block
 block discarded – undo
1097 1097
 			if ($list_type == 'ol') {
1098 1098
 				$ol_start_array = array();
1099 1099
 				$ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array);
1100
-				if ($ol_start_check){
1100
+				if ($ol_start_check) {
1101 1101
 					$ol_start = $ol_start_array[0];
1102 1102
 				}
1103 1103
 			}
1104 1104
 		}
1105 1105
 
1106
-		if ($ol_start > 1 && $list_type == 'ol'){
1106
+		if ($ol_start > 1 && $list_type == 'ol') {
1107 1107
 			$result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>");
1108 1108
 		} else {
1109 1109
 			$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
1110 1110
 		}
1111
-		return "\n". $result ."\n\n";
1111
+		return "\n" . $result . "\n\n";
1112 1112
 	}
1113 1113
 
1114 1114
 	/**
@@ -1155,12 +1155,12 @@  discard block
 block discarded – undo
1155 1155
 		$list_str = preg_replace_callback('{
1156 1156
 			(\n)?							# leading line = $1
1157 1157
 			(^[ ]*)							# leading whitespace = $2
1158
-			('.$marker_any_re.'				# list marker and space = $3
1158
+			('.$marker_any_re . '				# list marker and space = $3
1159 1159
 				(?:[ ]+|(?=\n))	# space only required if item is not empty
1160 1160
 			)
1161 1161
 			((?s:.*?))						# list item text   = $4
1162 1162
 			(?:(\n+(?=\n))|\n)				# tailing blank line = $5
1163
-			(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
1163
+			(?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n))))
1164 1164
 			}xm',
1165 1165
 			array($this, '_processListItems_callback'), $list_str);
1166 1166
 
@@ -1175,17 +1175,17 @@  discard block
 block discarded – undo
1175 1175
 	 */
1176 1176
 	protected function _processListItems_callback($matches) {
1177 1177
 		$item = $matches[4];
1178
-		$leading_line =& $matches[1];
1179
-		$leading_space =& $matches[2];
1178
+		$leading_line = & $matches[1];
1179
+		$leading_space = & $matches[2];
1180 1180
 		$marker_space = $matches[3];
1181
-		$tailing_blank_line =& $matches[5];
1181
+		$tailing_blank_line = & $matches[5];
1182 1182
 
1183 1183
 		if ($leading_line || $tailing_blank_line ||
1184 1184
 			preg_match('/\n{2,}/', $item))
1185 1185
 		{
1186 1186
 			// Replace marker with the appropriate whitespace indentation
1187 1187
 			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1188
-			$item = $this->runBlockGamut($this->outdent($item)."\n");
1188
+			$item = $this->runBlockGamut($this->outdent($item) . "\n");
1189 1189
 		} else {
1190 1190
 			// Recursion for sub-lists:
1191 1191
 			$item = $this->doLists($this->outdent($item));
@@ -1205,11 +1205,11 @@  discard block
 block discarded – undo
1205 1205
 				(?:\n\n|\A\n?)
1206 1206
 				(	            # $1 = the code block -- one or more lines, starting with a space/tab
1207 1207
 				  (?>
1208
-					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces
1208
+					[ ]{'.$this->tab_width . '}  # Lines must start with a tab or a tab-width of spaces
1209 1209
 					.*\n+
1210 1210
 				  )+
1211 1211
 				)
1212
-				((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1212
+				((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1213 1213
 			}xm',
1214 1214
 			array($this, '_doCodeBlocks_callback'), $text);
1215 1215
 
@@ -1337,8 +1337,8 @@  discard block
 block discarded – undo
1337 1337
 			// Each token is then passed to handleSpanToken.
1338 1338
 			$parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
1339 1339
 			$text_stack[0] .= $parts[0];
1340
-			$token =& $parts[1];
1341
-			$text =& $parts[2];
1340
+			$token = & $parts[1];
1341
+			$text = & $parts[2];
1342 1342
 
1343 1343
 			if (empty($token)) {
1344 1344
 				// Reached end of text span: empty stack without emitting.
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 				} else {
1366 1366
 					// Other closing marker: close one em or strong and
1367 1367
 					// change current token state to match the other
1368
-					$token_stack[0] = str_repeat($token[0], 3-$token_len);
1368
+					$token_stack[0] = str_repeat($token[0], 3 - $token_len);
1369 1369
 					$tag = $token_len == 2 ? "strong" : "em";
1370 1370
 					$span = $text_stack[0];
1371 1371
 					$span = $this->runSpanGamut($span);
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 		}
1712 1712
 
1713 1713
 		$chars = preg_split('/(?<!^)(?!$)/', $text);
1714
-		$seed = (int)abs(crc32($text) / strlen($text)); // Deterministic seed.
1714
+		$seed = (int) abs(crc32($text) / strlen($text)); // Deterministic seed.
1715 1715
 
1716 1716
 		foreach ($chars as $key => $char) {
1717 1717
 			$ord = ord($char);
@@ -1724,9 +1724,9 @@  discard block
 block discarded – undo
1724 1724
 				if ($r > 90 && strpos('@"&>', $char) === false) {
1725 1725
 					/* do nothing */
1726 1726
 				} else if ($r < 45) {
1727
-					$chars[$key] = '&#x'.dechex($ord).';';
1727
+					$chars[$key] = '&#x' . dechex($ord) . ';';
1728 1728
 				} else {
1729
-					$chars[$key] = '&#'.$ord.';';
1729
+					$chars[$key] = '&#' . $ord . ';';
1730 1730
 				}
1731 1731
 			}
1732 1732
 		}
@@ -1748,11 +1748,11 @@  discard block
 block discarded – undo
1748 1748
 
1749 1749
 		$span_re = '{
1750 1750
 				(
1751
-					\\\\'.$this->escape_chars_re.'
1751
+					\\\\'.$this->escape_chars_re . '
1752 1752
 				|
1753 1753
 					(?<![`\\\\])
1754 1754
 					`+						# code span marker
1755
-			'.( $this->no_markup ? '' : '
1755
+			'.($this->no_markup ? '' : '
1756 1756
 				|
1757 1757
 					<!--    .*?     -->		# comment
1758 1758
 				|
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
 					<[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag
1769 1769
 				|
1770 1770
 					</[-a-zA-Z0-9:_]+\s*> # closing tag
1771
-			').'
1771
+			') . '
1772 1772
 				)
1773 1773
 				}xs';
1774 1774
 
@@ -1805,10 +1805,10 @@  discard block
 block discarded – undo
1805 1805
 	protected function handleSpanToken($token, &$str) {
1806 1806
 		switch ($token[0]) {
1807 1807
 			case "\\":
1808
-				return $this->hashPart("&#". ord($token[1]). ";");
1808
+				return $this->hashPart("&#" . ord($token[1]) . ";");
1809 1809
 			case "`":
1810 1810
 				// Search for end marker in remaining text.
1811
-				if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
1811
+				if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm',
1812 1812
 					$str, $matches))
1813 1813
 				{
1814 1814
 					$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
 
@@ -865,9 +866,15 @@  discard block
 block discarded – undo
865 866
 			$url = $this->encodeURLAttribute($this->urls[$link_id]);
866 867
 			$result = "<img src=\"$url\" alt=\"$alt_text\"";
867 868
 			list($width, $height, $type, $attr) = getimagesize($url);
868
-			if(isset($width)) $result .= " width=\"$width\"";
869
-			if(isset($height)) $result .= " height=\"$height\"";
870
-			if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
869
+			if(isset($width)) {
870
+				$result .= " width=\"$width\"";
871
+			}
872
+			if(isset($height)) {
873
+				$result .= " height=\"$height\"";
874
+			}
875
+			if(isset($width) && isset($height)) {
876
+				$result .= " loading=\"lazy\"";
877
+			}
871 878
 			if (isset($this->titles[$link_id])) {
872 879
 				$title = $this->titles[$link_id];
873 880
 				$title = $this->encodeAttribute($title);
@@ -898,9 +905,15 @@  discard block
 block discarded – undo
898 905
 		$url = $this->encodeURLAttribute($url);
899 906
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
900 907
 		list($width, $height, $type, $attr) = getimagesize($url);
901
-		if(isset($width)) $result .= " width=\"$width\"";
902
-		if(isset($height)) $result .= " height=\"$height\"";
903
-		if(isset($width) && isset($height)) $result .= " loading=\"lazy\"";
908
+		if(isset($width)) {
909
+			$result .= " width=\"$width\"";
910
+		}
911
+		if(isset($height)) {
912
+			$result .= " height=\"$height\"";
913
+		}
914
+		if(isset($width) && isset($height)) {
915
+			$result .= " loading=\"lazy\"";
916
+		}
904 917
 		if (isset($title)) {
905 918
 			$title = $this->encodeAttribute($title);
906 919
 			$result .=  " title=\"$title\""; // $title already quoted
Please login to merge, or discard this patch.