Passed
Pull Request — lib (#309)
by Nico
03:58
created
Michelf/MarkdownExtra.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -154,10 +154,10 @@
 block discarded – undo
154 154
 	 */
155 155
 	protected $footnote_counter = 1;
156 156
 
157
-    /**
158
-     * Ref attribute for links
159
-     * @var array
160
-     */
157
+	/**
158
+	 * Ref attribute for links
159
+	 * @var array
160
+	 */
161 161
 	protected $ref_attr = array();
162 162
 
163 163
 	/**
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		$this->abbr_desciptions = array();
195 195
 		$this->abbr_word_re = '';
196 196
 
197
-		if ( ! $this->omit_footnotes )
197
+		if (!$this->omit_footnotes)
198 198
 			$this->footnotes_assembled = "";
199 199
 
200 200
 		parent::teardown();
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 		// Compose attributes as string
263 263
 		$attr_str = "";
264 264
 		if (!empty($id)) {
265
-			$attr_str .= ' id="'.$this->encodeAttribute($id) .'"';
265
+			$attr_str .= ' id="' . $this->encodeAttribute($id) . '"';
266 266
 		}
267 267
 		if (!empty($classes)) {
268
-			$attr_str .= ' class="'. implode(" ", $classes) . '"';
268
+			$attr_str .= ' class="' . implode(" ", $classes) . '"';
269 269
 		}
270 270
 		if (!$this->no_markup && !empty($attributes)) {
271
-			$attr_str .= ' '.implode(" ", $attributes);
271
+			$attr_str .= ' ' . implode(" ", $attributes);
272 272
 		}
273 273
 		return $attr_str;
274 274
 	}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 		// Link defs are in the form: ^[id]: url "optional title"
286 286
 		$text = preg_replace_callback('{
287
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
287
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
288 288
 							  [ ]*
289 289
 							  \n?				# maybe *one* newline
290 290
 							  [ ]*
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 								[")]
304 304
 								[ ]*
305 305
 							)?	# title is optional
306
-					(?:[ ]* '.$this->id_class_attr_catch_re.' )?  # $5 = extra id & class attr
306
+					(?:[ ]* '.$this->id_class_attr_catch_re . ' )?  # $5 = extra id & class attr
307 307
 							(?:\n+|\Z)
308 308
 			}xm',
309 309
 			array($this, '_stripLinkDefinitions_callback'),
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 		$link_id = strtolower($matches[1]);
321 321
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
322 322
 		$this->urls[$link_id] = $url;
323
-		$this->titles[$link_id] =& $matches[4];
324
-		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]);
323
+		$this->titles[$link_id] = & $matches[4];
324
+		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]);
325 325
 		return ''; // String that will replace the block
326 326
 	}
327 327
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		}
385 385
 
386 386
 		// Call the HTML-in-Markdown hasher.
387
-		list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
387
+		list($text,) = $this->_hashHTMLBlocks_inMarkdown($text);
388 388
 
389 389
 		return $text;
390 390
 	}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 					<\?.*?\?> | <%.*?%>	# Processing instruction
462 462
 				|
463 463
 					<!\[CDATA\[.*?\]\]>	# CData Block
464
-				' . ( !$span ? ' # If not in span.
464
+				' . (!$span ? ' # If not in span.
465 465
 				|
466 466
 					# Indented code block
467 467
 					(?: ^[ ]*\n | ^ | \n[ ]*\n )
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 					(?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes
480 480
 					[ ]*
481 481
 					(?= \n )
482
-				' : '' ) . ' # End (if not is span).
482
+				' : '') . ' # End (if not is span).
483 483
 				|
484 484
 					# Code span marker
485 485
 					# Note, this regex needs to go after backtick fenced
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 			}xs';
491 491
 
492 492
 
493
-		$depth = 0;		// Current depth inside the tag tree.
494
-		$parsed = "";	// Parsed text that will be returned.
493
+		$depth = 0; // Current depth inside the tag tree.
494
+		$parsed = ""; // Parsed text that will be returned.
495 495
 
496 496
 		// Loop through every tag until we find the closing tag of the parent
497 497
 		// or loop until reaching the end of text if no parent tag specified.
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 			//            Opening Context Block tag (like ins and del)
569 569
 			//               used as a block tag (tag is alone on it's line).
570 570
 			else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) ||
571
-				(	preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
571
+				(preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
572 572
 					preg_match($newline_before_re, $parsed) &&
573
-					preg_match($newline_after_re, $text)	)
573
+					preg_match($newline_after_re, $text))
574 574
 				)
575 575
 			{
576 576
 				// Need to parse tag and following text using the HTML parser.
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 				// Increase/decrease nested tag count.
601 601
 				if ($tag{1} === '/') {
602 602
 					$depth--;
603
-				} else if ($tag{strlen($tag)-2} !== '/') {
603
+				} else if ($tag{strlen($tag) - 2} !== '/') {
604 604
 					$depth++;
605 605
 				}
606 606
 
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 				)
678 678
 			}xs';
679 679
 
680
-		$original_text = $text;		// Save original text in case of faliure.
680
+		$original_text = $text; // Save original text in case of faliure.
681 681
 
682
-		$depth		= 0;	// Current depth inside the tag tree.
683
-		$block_text	= "";	// Temporary text holder for current text.
684
-		$parsed		= "";	// Parsed text that will be returned.
682
+		$depth = 0; // Current depth inside the tag tree.
683
+		$block_text = ""; // Temporary text holder for current text.
684
+		$parsed = ""; // Parsed text that will be returned.
685 685
 		$base_tag_name_re = '';
686 686
 
687 687
 		// Get the name of the starting tag.
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
724 724
 					if ($tag{1} === '/') {
725 725
 						$depth--;
726
-					} else if ($tag{strlen($tag)-2} !== '/') {
726
+					} else if ($tag{strlen($tag) - 2} !== '/') {
727 727
 						$depth++;
728 728
 					}
729 729
 				}
@@ -877,9 +877,9 @@  discard block
 block discarded – undo
877 877
 	 * @return string
878 878
 	 */
879 879
 	protected function _doAnchors_reference_callback($matches) {
880
-		$whole_match =  $matches[1];
881
-		$link_text   =  $matches[2];
882
-		$link_id     =& $matches[3];
880
+		$whole_match = $matches[1];
881
+		$link_text   = $matches[2];
882
+		$link_id     = & $matches[3];
883 883
 
884 884
 		if ($link_id == "") {
885 885
 			// for shortcut links like [this][] or [this].
@@ -895,10 +895,10 @@  discard block
 block discarded – undo
895 895
 			$url = $this->encodeURLAttribute($url);
896 896
 
897 897
 			$result = "<a href=\"$url\"";
898
-			if ( isset( $this->titles[$link_id] ) ) {
898
+			if (isset($this->titles[$link_id])) {
899 899
 				$title = $this->titles[$link_id];
900 900
 				$title = $this->encodeAttribute($title);
901
-				$result .=  " title=\"$title\"";
901
+				$result .= " title=\"$title\"";
902 902
 			}
903 903
 			if (isset($this->ref_attr[$link_id]))
904 904
 				$result .= $this->ref_attr[$link_id];
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
 	 * @return string
920 920
 	 */
921 921
 	protected function _doAnchors_inline_callback($matches) {
922
-		$link_text		=  $this->runSpanGamut($matches[2]);
923
-		$url			=  $matches[3] === '' ? $matches[4] : $matches[3];
924
-		$title			=& $matches[7];
925
-		$attr  = $this->doExtraAttributes("a", $dummy =& $matches[8]);
922
+		$link_text = $this->runSpanGamut($matches[2]);
923
+		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
924
+		$title = & $matches[7];
925
+		$attr  = $this->doExtraAttributes("a", $dummy = & $matches[8]);
926 926
 
927 927
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
928 928
 		// tag parser and hashed. Need to reverse the process before using the URL.
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 		$result = "<a href=\"$url\"";
936 936
 		if (isset($title)) {
937 937
 			$title = $this->encodeAttribute($title);
938
-			$result .=  " title=\"$title\"";
938
+			$result .= " title=\"$title\"";
939 939
 		}
940 940
 		$result .= $attr;
941 941
 
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 			if (isset($this->titles[$link_id])) {
1022 1022
 				$title = $this->titles[$link_id];
1023 1023
 				$title = $this->encodeAttribute($title);
1024
-				$result .=  " title=\"$title\"";
1024
+				$result .= " title=\"$title\"";
1025 1025
 			}
1026 1026
 			if (isset($this->ref_attr[$link_id])) {
1027 1027
 				$result .= $this->ref_attr[$link_id];
@@ -1043,17 +1043,17 @@  discard block
 block discarded – undo
1043 1043
 	 * @return string
1044 1044
 	 */
1045 1045
 	protected function _doImages_inline_callback($matches) {
1046
-		$alt_text		= $matches[2];
1046
+		$alt_text = $matches[2];
1047 1047
 		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
1048
-		$title			=& $matches[7];
1049
-		$attr  = $this->doExtraAttributes("img", $dummy =& $matches[8]);
1048
+		$title = & $matches[7];
1049
+		$attr  = $this->doExtraAttributes("img", $dummy = & $matches[8]);
1050 1050
 
1051 1051
 		$alt_text = $this->encodeAttribute($alt_text);
1052 1052
 		$url = $this->encodeURLAttribute($url);
1053 1053
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1054 1054
 		if (isset($title)) {
1055 1055
 			$title = $this->encodeAttribute($title);
1056
-			$result .=  " title=\"$title\""; // $title already quoted
1056
+			$result .= " title=\"$title\""; // $title already quoted
1057 1057
 		}
1058 1058
 		$result .= $attr;
1059 1059
 		$result .= $this->empty_element_suffix;
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 		//
1092 1092
 		$text = preg_replace_callback('{
1093 1093
 				^(\#{1,6})	# $1 = string of #\'s
1094
-				[ ]'.($this->hashtag_protection ? '+' : '*').'
1094
+				[ ]'.($this->hashtag_protection ? '+' : '*') . '
1095 1095
 				(.+?)		# $2 = Header text
1096 1096
 				[ ]*
1097 1097
 				\#*			# optional closing #\'s (not counted)
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
1120 1120
 
1121
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
1121
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId);
1122 1122
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>";
1123 1123
 		return "\n" . $this->hashBlock($block) . "\n\n";
1124 1124
 	}
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 		$level = strlen($matches[1]);
1133 1133
 
1134 1134
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
1135
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
1135
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId);
1136 1136
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>";
1137 1137
 		return "\n" . $this->hashBlock($block) . "\n\n";
1138 1138
 	}
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
 	 * @return string
1204 1204
 	 */
1205 1205
 	protected function _doTable_leadingPipe_callback($matches) {
1206
-		$head		= $matches[1];
1207
-		$underline	= $matches[2];
1206
+		$head = $matches[1];
1207
+		$underline = $matches[2];
1208 1208
 		$content	= $matches[3];
1209 1209
 
1210 1210
 		$content	= preg_replace('/^ *[|]/m', '', $content);
@@ -1233,14 +1233,14 @@  discard block
 block discarded – undo
1233 1233
 	 * @return string
1234 1234
 	 */
1235 1235
 	protected function _doTable_callback($matches) {
1236
-		$head		= $matches[1];
1237
-		$underline	= $matches[2];
1238
-		$content	= $matches[3];
1236
+		$head = $matches[1];
1237
+		$underline = $matches[2];
1238
+		$content = $matches[3];
1239 1239
 
1240 1240
 		// Remove any tailing pipes for each line.
1241
-		$head		= preg_replace('/[|] *$/m', '', $head);
1242
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
1243
-		$content	= preg_replace('/[|] *$/m', '', $content);
1241
+		$head = preg_replace('/[|] *$/m', '', $head);
1242
+		$underline = preg_replace('/[|] *$/m', '', $underline);
1243
+		$content = preg_replace('/[|] *$/m', '', $content);
1244 1244
 
1245 1245
 		// Reading alignement from header underline.
1246 1246
 		$separators	= preg_split('/ *[|] */', $underline);
@@ -1257,10 +1257,10 @@  discard block
 block discarded – undo
1257 1257
 
1258 1258
 		// Parsing span elements, including code spans, character escapes,
1259 1259
 		// and inline HTML tags, so that pipes inside those gets ignored.
1260
-		$head		= $this->parseSpan($head);
1261
-		$headers	= preg_split('/ *[|] */', $head);
1262
-		$col_count	= count($headers);
1263
-		$attr       = array_pad($attr, $col_count, '');
1260
+		$head = $this->parseSpan($head);
1261
+		$headers = preg_split('/ *[|] */', $head);
1262
+		$col_count = count($headers);
1263
+		$attr = array_pad($attr, $col_count, '');
1264 1264
 
1265 1265
 		// Write column headers.
1266 1266
 		$text = "<table>\n";
@@ -1428,13 +1428,13 @@  discard block
 block discarded – undo
1428 1428
 	protected function _processDefListItems_callback_dd($matches) {
1429 1429
 		$leading_line	= $matches[1];
1430 1430
 		$marker_space	= $matches[2];
1431
-		$def			= $matches[3];
1431
+		$def = $matches[3];
1432 1432
 
1433 1433
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
1434 1434
 			// Replace marker with the appropriate whitespace indentation
1435 1435
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1436 1436
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1437
-			$def = "\n". $def ."\n";
1437
+			$def = "\n" . $def . "\n";
1438 1438
 		}
1439 1439
 		else {
1440 1440
 			$def = rtrim($def);
@@ -1494,8 +1494,8 @@  discard block
 block discarded – undo
1494 1494
 	 * @return string
1495 1495
 	 */
1496 1496
 	protected function _doFencedCodeBlocks_callback($matches) {
1497
-		$classname =& $matches[2];
1498
-		$attrs     =& $matches[3];
1497
+		$classname = & $matches[2];
1498
+		$attrs     = & $matches[3];
1499 1499
 		$codeblock = $matches[4];
1500 1500
 
1501 1501
 		if ($this->code_block_content_func) {
@@ -1517,9 +1517,9 @@  discard block
 block discarded – undo
1517 1517
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
1518 1518
 		$pre_attr_str  = $this->code_attr_on_pre ? $attr_str : '';
1519 1519
 		$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
1520
-		$codeblock  = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1520
+		$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1521 1521
 
1522
-		return "\n\n".$this->hashBlock($codeblock)."\n\n";
1522
+		return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
1523 1523
 	}
1524 1524
 
1525 1525
 	/**
@@ -1652,9 +1652,9 @@  discard block
 block discarded – undo
1652 1652
 		$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
1653 1653
 			array($this, '_appendFootnotes_callback'), $text);
1654 1654
 
1655
-		if ( ! empty( $this->footnotes_ordered ) ) {
1655
+		if (!empty($this->footnotes_ordered)) {
1656 1656
 			$this->_doFootnotes();
1657
-			if ( ! $this->omit_footnotes ) {
1657
+			if (!$this->omit_footnotes) {
1658 1658
 				$text .= "\n\n";
1659 1659
 				$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
1660 1660
 				$text .= "<hr" . $this->empty_element_suffix . "\n";
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 		// Create footnote marker only if it has a corresponding footnote *and*
1737 1737
 		// the footnote hasn't been used by another marker.
1738 1738
 		if (isset($this->footnotes[$node_id])) {
1739
-			$num =& $this->footnotes_numbers[$node_id];
1739
+			$num = & $this->footnotes_numbers[$node_id];
1740 1740
 			if (!isset($num)) {
1741 1741
 				// Transfer footnote content to the ordered list and give it its
1742 1742
 				// number
@@ -1765,8 +1765,8 @@  discard block
 block discarded – undo
1765 1765
 			$node_id = $this->encodeAttribute($node_id);
1766 1766
 
1767 1767
 			return
1768
-				"<sup id=\"fnref$ref_count_mark:$node_id\">".
1769
-				"<a href=\"#fn:$node_id\"$attr>$num</a>".
1768
+				"<sup id=\"fnref$ref_count_mark:$node_id\">" .
1769
+				"<a href=\"#fn:$node_id\"$attr>$num</a>" .
1770 1770
 				"</sup>";
1771 1771
 		}
1772 1772
 
Please login to merge, or discard this patch.