Passed
Pull Request — lib (#393)
by
unknown
01:26
created
Michelf/MarkdownExtra.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$this->abbr_desciptions = array();
189 189
 		$this->abbr_word_re = '';
190 190
 
191
-		if ( ! $this->omit_footnotes )
191
+		if (!$this->omit_footnotes)
192 192
 			$this->footnotes_assembled = null;
193 193
 
194 194
 		parent::teardown();
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 		// Compose attributes as string
254 254
 		$attr_str = "";
255 255
 		if (!empty($id)) {
256
-			$attr_str .= ' id="'.$this->encodeAttribute($id) .'"';
256
+			$attr_str .= ' id="' . $this->encodeAttribute($id) . '"';
257 257
 		}
258 258
 		if (!empty($classes)) {
259
-			$attr_str .= ' class="'. implode(" ", $classes) . '"';
259
+			$attr_str .= ' class="' . implode(" ", $classes) . '"';
260 260
 		}
261 261
 		if (!$this->no_markup && !empty($attributes)) {
262
-			$attr_str .= ' '.implode(" ", $attributes);
262
+			$attr_str .= ' ' . implode(" ", $attributes);
263 263
 		}
264 264
 		return $attr_str;
265 265
 	}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 		// Link defs are in the form: ^[id]: url "optional title"
277 277
 		$text = preg_replace_callback('{
278
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
278
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
279 279
 							  [ ]*
280 280
 							  \n?				# maybe *one* newline
281 281
 							  [ ]*
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 								[")]
295 295
 								[ ]*
296 296
 							)?	# title is optional
297
-					(?:[ ]* '.$this->id_class_attr_catch_re.' )?  # $5 = extra id & class attr
297
+					(?:[ ]* '.$this->id_class_attr_catch_re . ' )?  # $5 = extra id & class attr
298 298
 							(?:\n+|\Z)
299 299
 			}xm',
300 300
 			array($this, '_stripLinkDefinitions_callback'),
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 		$link_id = strtolower($matches[1]);
312 312
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
313 313
 		$this->urls[$link_id] = $url;
314
-		$this->titles[$link_id] =& $matches[4];
315
-		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]);
314
+		$this->titles[$link_id] = & $matches[4];
315
+		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]);
316 316
 		return ''; // String that will replace the block
317 317
 	}
318 318
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 		}
370 370
 
371 371
 		// Call the HTML-in-Markdown hasher.
372
-		list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
372
+		list($text,) = $this->_hashHTMLBlocks_inMarkdown($text);
373 373
 
374 374
 		return $text;
375 375
 	}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 					<\?.*?\?> | <%.*?%>	# Processing instruction
447 447
 				|
448 448
 					<!\[CDATA\[.*?\]\]>	# CData Block
449
-				' . ( !$span ? ' # If not in span.
449
+				' . (!$span ? ' # If not in span.
450 450
 				|
451 451
 					# Indented code block
452 452
 					(?: ^[ ]*\n | ^ | \n[ ]*\n )
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 					(?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes
465 465
 					[ ]*
466 466
 					(?= \n )
467
-				' : '' ) . ' # End (if not is span).
467
+				' : '') . ' # End (if not is span).
468 468
 				|
469 469
 					# Code span marker
470 470
 					# Note, this regex needs to go after backtick fenced
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 			}xs';
476 476
 
477 477
 
478
-		$depth = 0;		// Current depth inside the tag tree.
479
-		$parsed = "";	// Parsed text that will be returned.
478
+		$depth = 0; // Current depth inside the tag tree.
479
+		$parsed = ""; // Parsed text that will be returned.
480 480
 
481 481
 		// Loop through every tag until we find the closing tag of the parent
482 482
 		// or loop until reaching the end of text if no parent tag specified.
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 			//            Opening Context Block tag (like ins and del)
554 554
 			//               used as a block tag (tag is alone on it's line).
555 555
 			else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) ||
556
-				(	preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
556
+				(preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
557 557
 					preg_match($newline_before_re, $parsed) &&
558
-					preg_match($newline_after_re, $text)	)
558
+					preg_match($newline_after_re, $text))
559 559
 				)
560 560
 			{
561 561
 				// Need to parse tag and following text using the HTML parser.
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 				// Increase/decrease nested tag count.
586 586
 				if ($tag[1] === '/') {
587 587
 					$depth--;
588
-				} else if ($tag[strlen($tag)-2] !== '/') {
588
+				} else if ($tag[strlen($tag) - 2] !== '/') {
589 589
 					$depth++;
590 590
 				}
591 591
 
@@ -663,11 +663,11 @@  discard block
 block discarded – undo
663 663
 				)
664 664
 			}xs';
665 665
 
666
-		$original_text = $text;		// Save original text in case of faliure.
666
+		$original_text = $text; // Save original text in case of faliure.
667 667
 
668
-		$depth		= 0;	// Current depth inside the tag tree.
669
-		$block_text	= "";	// Temporary text holder for current text.
670
-		$parsed		= "";	// Parsed text that will be returned.
668
+		$depth = 0; // Current depth inside the tag tree.
669
+		$block_text = ""; // Temporary text holder for current text.
670
+		$parsed = ""; // Parsed text that will be returned.
671 671
 		$base_tag_name_re = '';
672 672
 
673 673
 		// Get the name of the starting tag.
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
710 710
 					if ($tag[1] === '/') {
711 711
 						$depth--;
712
-					} else if ($tag[strlen($tag)-2] !== '/') {
712
+					} else if ($tag[strlen($tag) - 2] !== '/') {
713 713
 						$depth++;
714 714
 					}
715 715
 				}
@@ -863,9 +863,9 @@  discard block
 block discarded – undo
863 863
 	 * @return string
864 864
 	 */
865 865
 	protected function _doAnchors_reference_callback($matches) {
866
-		$whole_match =  $matches[1];
867
-		$link_text   =  $matches[2];
868
-		$link_id     =& $matches[3];
866
+		$whole_match = $matches[1];
867
+		$link_text   = $matches[2];
868
+		$link_id     = & $matches[3];
869 869
 
870 870
 		if ($link_id == "") {
871 871
 			// for shortcut links like [this][] or [this].
@@ -881,10 +881,10 @@  discard block
 block discarded – undo
881 881
 			$url = $this->encodeURLAttribute($url);
882 882
 
883 883
 			$result = "<a href=\"$url\"";
884
-			if ( isset( $this->titles[$link_id] ) ) {
884
+			if (isset($this->titles[$link_id])) {
885 885
 				$title = $this->titles[$link_id];
886 886
 				$title = $this->encodeAttribute($title);
887
-				$result .=  " title=\"$title\"";
887
+				$result .= " title=\"$title\"";
888 888
 			}
889 889
 			if (isset($this->ref_attr[$link_id]))
890 890
 				$result .= $this->ref_attr[$link_id];
@@ -905,11 +905,11 @@  discard block
 block discarded – undo
905 905
 	 * @return string
906 906
 	 */
907 907
 	protected function _doAnchors_inline_callback($matches) {
908
-		$link_text		=  $this->runSpanGamut($matches[2]);
909
-		$url			=  $matches[3] === '' ? $matches[4] : $matches[3];
910
-		$title_quote		=& $matches[6];
911
-		$title			=& $matches[7];
912
-		$attr  = $this->doExtraAttributes("a", $dummy =& $matches[8]);
908
+		$link_text = $this->runSpanGamut($matches[2]);
909
+		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
910
+		$title_quote = & $matches[6];
911
+		$title = & $matches[7];
912
+		$attr  = $this->doExtraAttributes("a", $dummy = & $matches[8]);
913 913
 
914 914
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
915 915
 		// tag parser and hashed. Need to reverse the process before using the URL.
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 		$result = "<a href=\"$url\"";
923 923
 		if (isset($title) && $title_quote) {
924 924
 			$title = $this->encodeAttribute($title);
925
-			$result .=  " title=\"$title\"";
925
+			$result .= " title=\"$title\"";
926 926
 		}
927 927
 		$result .= $attr;
928 928
 
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			if (isset($this->titles[$link_id])) {
1009 1009
 				$title = $this->titles[$link_id];
1010 1010
 				$title = $this->encodeAttribute($title);
1011
-				$result .=  " title=\"$title\"";
1011
+				$result .= " title=\"$title\"";
1012 1012
 			}
1013 1013
 			if (isset($this->ref_attr[$link_id])) {
1014 1014
 				$result .= $this->ref_attr[$link_id];
@@ -1030,18 +1030,18 @@  discard block
 block discarded – undo
1030 1030
 	 * @return string
1031 1031
 	 */
1032 1032
 	protected function _doImages_inline_callback($matches) {
1033
-		$alt_text		= $matches[2];
1033
+		$alt_text = $matches[2];
1034 1034
 		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
1035
-		$title_quote		=& $matches[6];
1036
-		$title			=& $matches[7];
1037
-		$attr  = $this->doExtraAttributes("img", $dummy =& $matches[8]);
1035
+		$title_quote = & $matches[6];
1036
+		$title = & $matches[7];
1037
+		$attr  = $this->doExtraAttributes("img", $dummy = & $matches[8]);
1038 1038
 
1039 1039
 		$alt_text = $this->encodeAttribute($alt_text);
1040 1040
 		$url = $this->encodeURLAttribute($url);
1041 1041
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1042 1042
 		if (isset($title) && $title_quote) {
1043 1043
 			$title = $this->encodeAttribute($title);
1044
-			$result .=  " title=\"$title\""; // $title already quoted
1044
+			$result .= " title=\"$title\""; // $title already quoted
1045 1045
 		}
1046 1046
 		$result .= $attr;
1047 1047
 		$result .= $this->empty_element_suffix;
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 		//
1080 1080
 		$text = preg_replace_callback('{
1081 1081
 				^(\#{1,6})	# $1 = string of #\'s
1082
-				[ ]'.($this->hashtag_protection ? '+' : '*').'
1082
+				[ ]'.($this->hashtag_protection ? '+' : '*') . '
1083 1083
 				(.+?)		# $2 = Header text
1084 1084
 				[ ]*
1085 1085
 				\#*			# optional closing #\'s (not counted)
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 
1107 1107
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
1108 1108
 
1109
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
1109
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId);
1110 1110
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>";
1111 1111
 		return "\n" . $this->hashBlock($block) . "\n\n";
1112 1112
 	}
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 		$level = strlen($matches[1]);
1121 1121
 
1122 1122
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
1123
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
1123
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId);
1124 1124
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>";
1125 1125
 		return "\n" . $this->hashBlock($block) . "\n\n";
1126 1126
 	}
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 						[|] .* \n			# Row content.
1155 1155
 					)*
1156 1156
 				)
1157
-				('.$this->id_class_attr_catch_re.')?	 # $4 = id/class attributes
1157
+				('.$this->id_class_attr_catch_re . ')?	 # $4 = id/class attributes
1158 1158
 				(?=\n|\Z)					# Stop at final double newline.
1159 1159
 			}xm',
1160 1160
 			array($this, '_doTable_leadingPipe_callback'), $text);
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 						.* [|] .* \n		# Row content
1180 1180
 					)*
1181 1181
 				)
1182
-				('.$this->id_class_attr_catch_re.')?	 # $4 = id/class attributes
1182
+				('.$this->id_class_attr_catch_re . ')?	 # $4 = id/class attributes
1183 1183
 				(?=\n|\Z)					# Stop at final double newline.
1184 1184
 			}xm',
1185 1185
 			array($this, '_DoTable_callback'), $text);
@@ -1193,10 +1193,10 @@  discard block
 block discarded – undo
1193 1193
 	 * @return string
1194 1194
 	 */
1195 1195
 	protected function _doTable_leadingPipe_callback($matches) {
1196
-		$head		= $matches[1];
1197
-		$underline	= $matches[2];
1196
+		$head = $matches[1];
1197
+		$underline = $matches[2];
1198 1198
 		$content	= $matches[3];
1199
-		$id_class	= $matches[4] ?? null;
1199
+		$id_class = $matches[4] ?? null;
1200 1200
 
1201 1201
 		$content	= preg_replace('/^ *[|]/m', '', $content);
1202 1202
 
@@ -1223,16 +1223,16 @@  discard block
 block discarded – undo
1223 1223
 	 * @return string
1224 1224
 	 */
1225 1225
 	protected function _doTable_callback($matches) {
1226
-		$head		= $matches[1];
1227
-		$underline	= $matches[2];
1228
-		$content	= $matches[3];
1229
-		$id_class	= $matches[4] ?? null;
1226
+		$head = $matches[1];
1227
+		$underline = $matches[2];
1228
+		$content = $matches[3];
1229
+		$id_class = $matches[4] ?? null;
1230 1230
 		$attr		= [];
1231 1231
 
1232 1232
 		// Remove any tailing pipes for each line.
1233 1233
 		$head		= preg_replace('/[|] *$/m', '', $head);
1234
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
1235
-		$content	= preg_replace('/[|] *$/m', '', $content);
1234
+		$underline = preg_replace('/[|] *$/m', '', $underline);
1235
+		$content = preg_replace('/[|] *$/m', '', $content);
1236 1236
 
1237 1237
 		// Reading alignement from header underline.
1238 1238
 		$separators	= preg_split('/ *[|] */', $underline);
@@ -1249,10 +1249,10 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 		// Parsing span elements, including code spans, character escapes,
1251 1251
 		// and inline HTML tags, so that pipes inside those gets ignored.
1252
-		$head		= $this->parseSpan($head);
1253
-		$headers	= preg_split('/ *[|] */', $head);
1254
-		$col_count	= count($headers);
1255
-		$attr       = array_pad($attr, $col_count, '');
1252
+		$head = $this->parseSpan($head);
1253
+		$headers = preg_split('/ *[|] */', $head);
1254
+		$col_count = count($headers);
1255
+		$attr = array_pad($attr, $col_count, '');
1256 1256
 
1257 1257
 		// Write column headers.
1258 1258
 		$table_attr_str = $this->doExtraAttributes('table', $id_class, null, []);
@@ -1421,13 +1421,13 @@  discard block
 block discarded – undo
1421 1421
 	protected function _processDefListItems_callback_dd($matches) {
1422 1422
 		$leading_line	= $matches[1];
1423 1423
 		$marker_space	= $matches[2];
1424
-		$def			= $matches[3];
1424
+		$def = $matches[3];
1425 1425
 
1426 1426
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
1427 1427
 			// Replace marker with the appropriate whitespace indentation
1428 1428
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1429 1429
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1430
-			$def = "\n". $def ."\n";
1430
+			$def = "\n" . $def . "\n";
1431 1431
 		}
1432 1432
 		else {
1433 1433
 			$def = rtrim($def);
@@ -1487,8 +1487,8 @@  discard block
 block discarded – undo
1487 1487
 	 * @return string
1488 1488
 	 */
1489 1489
 	protected function _doFencedCodeBlocks_callback($matches) {
1490
-		$classname =& $matches[2];
1491
-		$attrs     =& $matches[3];
1490
+		$classname = & $matches[2];
1491
+		$attrs     = & $matches[3];
1492 1492
 		$codeblock = $matches[4];
1493 1493
 
1494 1494
 		if ($this->code_block_content_func) {
@@ -1510,9 +1510,9 @@  discard block
 block discarded – undo
1510 1510
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
1511 1511
 		$pre_attr_str  = $this->code_attr_on_pre ? $attr_str : '';
1512 1512
 		$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
1513
-		$codeblock  = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1513
+		$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1514 1514
 
1515
-		return "\n\n".$this->hashBlock($codeblock)."\n\n";
1515
+		return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
1516 1516
 	}
1517 1517
 
1518 1518
 	/**
@@ -1645,9 +1645,9 @@  discard block
 block discarded – undo
1645 1645
 		$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
1646 1646
 			array($this, '_appendFootnotes_callback'), $text);
1647 1647
 
1648
-		if ( ! empty( $this->footnotes_ordered ) ) {
1648
+		if (!empty($this->footnotes_ordered)) {
1649 1649
 			$this->_doFootnotes();
1650
-			if ( ! $this->omit_footnotes ) {
1650
+			if (!$this->omit_footnotes) {
1651 1651
 				$text .= "\n\n";
1652 1652
 				$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
1653 1653
 				$text .= "<hr" . $this->empty_element_suffix . "\n";
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 		// Create footnote marker only if it has a corresponding footnote *and*
1748 1748
 		// the footnote hasn't been used by another marker.
1749 1749
 		if (isset($this->footnotes[$node_id])) {
1750
-			$num =& $this->footnotes_numbers[$node_id];
1750
+			$num = & $this->footnotes_numbers[$node_id];
1751 1751
 			if (!isset($num)) {
1752 1752
 				// Transfer footnote content to the ordered list and give it its
1753 1753
 				// number
@@ -1776,8 +1776,8 @@  discard block
 block discarded – undo
1776 1776
 			$node_id = $this->encodeAttribute($node_id);
1777 1777
 
1778 1778
 			return
1779
-				"<sup id=\"fnref$ref_count_mark:$node_id\">".
1780
-				"<a href=\"#fn:$node_id\"$attr>$num</a>".
1779
+				"<sup id=\"fnref$ref_count_mark:$node_id\">" .
1780
+				"<a href=\"#fn:$node_id\"$attr>$num</a>" .
1781 1781
 				"</sup>";
1782 1782
 		}
1783 1783
 
Please login to merge, or discard this patch.