Passed
Pull Request — lib (#313)
by
unknown
02:47
created
Michelf/MarkdownExtra.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		$this->abbr_desciptions = array();
202 202
 		$this->abbr_word_re = '';
203 203
 
204
-		if ( ! $this->omit_footnotes )
204
+		if (!$this->omit_footnotes)
205 205
 			$this->footnotes_assembled = null;
206 206
 
207 207
 		parent::teardown();
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 		// Compose attributes as string
270 270
 		$attr_str = "";
271 271
 		if (!empty($id)) {
272
-			$attr_str .= ' id="'.$this->encodeAttribute($id) .'"';
272
+			$attr_str .= ' id="' . $this->encodeAttribute($id) . '"';
273 273
 		}
274 274
 		if (!empty($classes)) {
275
-			$attr_str .= ' class="'. implode(" ", $classes) . '"';
275
+			$attr_str .= ' class="' . implode(" ", $classes) . '"';
276 276
 		}
277 277
 		if (!$this->no_markup && !empty($attributes)) {
278
-			$attr_str .= ' '.implode(" ", $attributes);
278
+			$attr_str .= ' ' . implode(" ", $attributes);
279 279
 		}
280 280
 		return $attr_str;
281 281
 	}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
 		// Link defs are in the form: ^[id]: url "optional title"
293 293
 		$text = preg_replace_callback('{
294
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
294
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
295 295
 							  [ ]*
296 296
 							  \n?				# maybe *one* newline
297 297
 							  [ ]*
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 								[")]
311 311
 								[ ]*
312 312
 							)?	# title is optional
313
-					(?:[ ]* '.$this->id_class_attr_catch_re.' )?  # $5 = extra id & class attr
313
+					(?:[ ]* '.$this->id_class_attr_catch_re . ' )?  # $5 = extra id & class attr
314 314
 							(?:\n+|\Z)
315 315
 			}xm',
316 316
 			array($this, '_stripLinkDefinitions_callback'),
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 		$link_id = strtolower($matches[1]);
328 328
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
329 329
 		$this->urls[$link_id] = $url;
330
-		$this->titles[$link_id] =& $matches[4];
331
-		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]);
330
+		$this->titles[$link_id] = & $matches[4];
331
+		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]);
332 332
 		return ''; // String that will replace the block
333 333
 	}
334 334
 
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		}
392 392
 
393 393
 		// Call the HTML-in-Markdown hasher.
394
-		list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
394
+		list($text,) = $this->_hashHTMLBlocks_inMarkdown($text);
395 395
 
396 396
 		return $text;
397 397
 	}
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 					<\?.*?\?> | <%.*?%>	# Processing instruction
469 469
 				|
470 470
 					<!\[CDATA\[.*?\]\]>	# CData Block
471
-				' . ( !$span ? ' # If not in span.
471
+				' . (!$span ? ' # If not in span.
472 472
 				|
473 473
 					# Indented code block
474 474
 					(?: ^[ ]*\n | ^ | \n[ ]*\n )
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 					(?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes
487 487
 					[ ]*
488 488
 					(?= \n )
489
-				' : '' ) . ' # End (if not is span).
489
+				' : '') . ' # End (if not is span).
490 490
 				|
491 491
 					# Code span marker
492 492
 					# Note, this regex needs to go after backtick fenced
@@ -497,8 +497,8 @@  discard block
 block discarded – undo
497 497
 			}xs';
498 498
 
499 499
 
500
-		$depth = 0;		// Current depth inside the tag tree.
501
-		$parsed = "";	// Parsed text that will be returned.
500
+		$depth = 0; // Current depth inside the tag tree.
501
+		$parsed = ""; // Parsed text that will be returned.
502 502
 
503 503
 		// Loop through every tag until we find the closing tag of the parent
504 504
 		// or loop until reaching the end of text if no parent tag specified.
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
 			//            Opening Context Block tag (like ins and del)
576 576
 			//               used as a block tag (tag is alone on it's line).
577 577
 			else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) ||
578
-				(	preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
578
+				(preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
579 579
 					preg_match($newline_before_re, $parsed) &&
580
-					preg_match($newline_after_re, $text)	)
580
+					preg_match($newline_after_re, $text))
581 581
 				)
582 582
 			{
583 583
 				// Need to parse tag and following text using the HTML parser.
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 				// Increase/decrease nested tag count.
608 608
 				if ($tag{1} === '/') {
609 609
 					$depth--;
610
-				} else if ($tag{strlen($tag)-2} !== '/') {
610
+				} else if ($tag{strlen($tag) - 2} !== '/') {
611 611
 					$depth++;
612 612
 				}
613 613
 
@@ -684,11 +684,11 @@  discard block
 block discarded – undo
684 684
 				)
685 685
 			}xs';
686 686
 
687
-		$original_text = $text;		// Save original text in case of faliure.
687
+		$original_text = $text; // Save original text in case of faliure.
688 688
 
689
-		$depth		= 0;	// Current depth inside the tag tree.
690
-		$block_text	= "";	// Temporary text holder for current text.
691
-		$parsed		= "";	// Parsed text that will be returned.
689
+		$depth = 0; // Current depth inside the tag tree.
690
+		$block_text = ""; // Temporary text holder for current text.
691
+		$parsed = ""; // Parsed text that will be returned.
692 692
 		$base_tag_name_re = '';
693 693
 
694 694
 		// Get the name of the starting tag.
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
731 731
 					if ($tag{1} === '/') {
732 732
 						$depth--;
733
-					} else if ($tag{strlen($tag)-2} !== '/') {
733
+					} else if ($tag{strlen($tag) - 2} !== '/') {
734 734
 						$depth++;
735 735
 					}
736 736
 				}
@@ -884,9 +884,9 @@  discard block
 block discarded – undo
884 884
 	 * @return string
885 885
 	 */
886 886
 	protected function _doAnchors_reference_callback($matches) {
887
-		$whole_match =  $matches[1];
888
-		$link_text   =  $matches[2];
889
-		$link_id     =& $matches[3];
887
+		$whole_match = $matches[1];
888
+		$link_text   = $matches[2];
889
+		$link_id     = & $matches[3];
890 890
 
891 891
 		if ($link_id == "") {
892 892
 			// for shortcut links like [this][] or [this].
@@ -902,10 +902,10 @@  discard block
 block discarded – undo
902 902
 			$url = $this->encodeURLAttribute($url);
903 903
 
904 904
 			$result = "<a href=\"$url\"";
905
-			if ( isset( $this->titles[$link_id] ) ) {
905
+			if (isset($this->titles[$link_id])) {
906 906
 				$title = $this->titles[$link_id];
907 907
 				$title = $this->encodeAttribute($title);
908
-				$result .=  " title=\"$title\"";
908
+				$result .= " title=\"$title\"";
909 909
 			}
910 910
 			if (isset($this->ref_attr[$link_id]))
911 911
 				$result .= $this->ref_attr[$link_id];
@@ -926,10 +926,10 @@  discard block
 block discarded – undo
926 926
 	 * @return string
927 927
 	 */
928 928
 	protected function _doAnchors_inline_callback($matches) {
929
-		$link_text		=  $this->runSpanGamut($matches[2]);
930
-		$url			=  $matches[3] === '' ? $matches[4] : $matches[3];
931
-		$title			=& $matches[7];
932
-		$attr  = $this->doExtraAttributes("a", $dummy =& $matches[8]);
929
+		$link_text = $this->runSpanGamut($matches[2]);
930
+		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
931
+		$title = & $matches[7];
932
+		$attr  = $this->doExtraAttributes("a", $dummy = & $matches[8]);
933 933
 
934 934
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
935 935
 		// tag parser and hashed. Need to reverse the process before using the URL.
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 		$result = "<a href=\"$url\"";
943 943
 		if (isset($title)) {
944 944
 			$title = $this->encodeAttribute($title);
945
-			$result .=  " title=\"$title\"";
945
+			$result .= " title=\"$title\"";
946 946
 		}
947 947
 		$result .= $attr;
948 948
 
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			if (isset($this->titles[$link_id])) {
1029 1029
 				$title = $this->titles[$link_id];
1030 1030
 				$title = $this->encodeAttribute($title);
1031
-				$result .=  " title=\"$title\"";
1031
+				$result .= " title=\"$title\"";
1032 1032
 			}
1033 1033
 			if (isset($this->ref_attr[$link_id])) {
1034 1034
 				$result .= $this->ref_attr[$link_id];
@@ -1050,17 +1050,17 @@  discard block
 block discarded – undo
1050 1050
 	 * @return string
1051 1051
 	 */
1052 1052
 	protected function _doImages_inline_callback($matches) {
1053
-		$alt_text		= $matches[2];
1053
+		$alt_text = $matches[2];
1054 1054
 		$url			= $matches[3] === '' ? $matches[4] : $matches[3];
1055
-		$title			=& $matches[7];
1056
-		$attr  = $this->doExtraAttributes("img", $dummy =& $matches[8]);
1055
+		$title = & $matches[7];
1056
+		$attr  = $this->doExtraAttributes("img", $dummy = & $matches[8]);
1057 1057
 
1058 1058
 		$alt_text = $this->encodeAttribute($alt_text);
1059 1059
 		$url = $this->encodeURLAttribute($url);
1060 1060
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1061 1061
 		if (isset($title)) {
1062 1062
 			$title = $this->encodeAttribute($title);
1063
-			$result .=  " title=\"$title\""; // $title already quoted
1063
+			$result .= " title=\"$title\""; // $title already quoted
1064 1064
 		}
1065 1065
 		$result .= $attr;
1066 1066
 		$result .= $this->empty_element_suffix;
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		//
1099 1099
 		$text = preg_replace_callback('{
1100 1100
 				^(\#{1,6})	# $1 = string of #\'s
1101
-				[ ]'.($this->hashtag_protection ? '+' : '*').'
1101
+				[ ]'.($this->hashtag_protection ? '+' : '*') . '
1102 1102
 				(.+?)		# $2 = Header text
1103 1103
 				[ ]*
1104 1104
 				\#*			# optional closing #\'s (not counted)
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 
1126 1126
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
1127 1127
 
1128
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
1128
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId);
1129 1129
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>";
1130 1130
 		return "\n" . $this->hashBlock($block) . "\n\n";
1131 1131
 	}
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 		$level = strlen($matches[1]);
1140 1140
 
1141 1141
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
1142
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
1142
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId);
1143 1143
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>";
1144 1144
 		return "\n" . $this->hashBlock($block) . "\n\n";
1145 1145
 	}
@@ -1210,8 +1210,8 @@  discard block
 block discarded – undo
1210 1210
 	 * @return string
1211 1211
 	 */
1212 1212
 	protected function _doTable_leadingPipe_callback($matches) {
1213
-		$head		= $matches[1];
1214
-		$underline	= $matches[2];
1213
+		$head = $matches[1];
1214
+		$underline = $matches[2];
1215 1215
 		$content	= $matches[3];
1216 1216
 
1217 1217
 		$content	= preg_replace('/^ *[|]/m', '', $content);
@@ -1240,14 +1240,14 @@  discard block
 block discarded – undo
1240 1240
 	 * @return string
1241 1241
 	 */
1242 1242
 	protected function _doTable_callback($matches) {
1243
-		$head		= $matches[1];
1244
-		$underline	= $matches[2];
1245
-		$content	= $matches[3];
1243
+		$head = $matches[1];
1244
+		$underline = $matches[2];
1245
+		$content = $matches[3];
1246 1246
 
1247 1247
 		// Remove any tailing pipes for each line.
1248
-		$head		= preg_replace('/[|] *$/m', '', $head);
1249
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
1250
-		$content	= preg_replace('/[|] *$/m', '', $content);
1248
+		$head = preg_replace('/[|] *$/m', '', $head);
1249
+		$underline = preg_replace('/[|] *$/m', '', $underline);
1250
+		$content = preg_replace('/[|] *$/m', '', $content);
1251 1251
 
1252 1252
 		// Reading alignement from header underline.
1253 1253
 		$separators	= preg_split('/ *[|] */', $underline);
@@ -1264,10 +1264,10 @@  discard block
 block discarded – undo
1264 1264
 
1265 1265
 		// Parsing span elements, including code spans, character escapes,
1266 1266
 		// and inline HTML tags, so that pipes inside those gets ignored.
1267
-		$head		= $this->parseSpan($head);
1268
-		$headers	= preg_split('/ *[|] */', $head);
1269
-		$col_count	= count($headers);
1270
-		$attr       = array_pad($attr, $col_count, '');
1267
+		$head = $this->parseSpan($head);
1268
+		$headers = preg_split('/ *[|] */', $head);
1269
+		$col_count = count($headers);
1270
+		$attr = array_pad($attr, $col_count, '');
1271 1271
 
1272 1272
 		// Write column headers.
1273 1273
 		$text = "<table>\n";
@@ -1435,13 +1435,13 @@  discard block
 block discarded – undo
1435 1435
 	protected function _processDefListItems_callback_dd($matches) {
1436 1436
 		$leading_line	= $matches[1];
1437 1437
 		$marker_space	= $matches[2];
1438
-		$def			= $matches[3];
1438
+		$def = $matches[3];
1439 1439
 
1440 1440
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
1441 1441
 			// Replace marker with the appropriate whitespace indentation
1442 1442
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1443 1443
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1444
-			$def = "\n". $def ."\n";
1444
+			$def = "\n" . $def . "\n";
1445 1445
 		}
1446 1446
 		else {
1447 1447
 			$def = rtrim($def);
@@ -1501,8 +1501,8 @@  discard block
 block discarded – undo
1501 1501
 	 * @return string
1502 1502
 	 */
1503 1503
 	protected function _doFencedCodeBlocks_callback($matches) {
1504
-		$classname =& $matches[2];
1505
-		$attrs     =& $matches[3];
1504
+		$classname = & $matches[2];
1505
+		$attrs     = & $matches[3];
1506 1506
 		$codeblock = $matches[4];
1507 1507
 
1508 1508
 		if ($this->code_block_content_func) {
@@ -1524,9 +1524,9 @@  discard block
 block discarded – undo
1524 1524
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
1525 1525
 		$pre_attr_str  = $this->code_attr_on_pre ? $attr_str : '';
1526 1526
 		$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
1527
-		$codeblock  = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1527
+		$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1528 1528
 
1529
-		return "\n\n".$this->hashBlock($codeblock)."\n\n";
1529
+		return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
1530 1530
 	}
1531 1531
 
1532 1532
 	/**
@@ -1659,9 +1659,9 @@  discard block
 block discarded – undo
1659 1659
 		$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
1660 1660
 			array($this, '_appendFootnotes_callback'), $text);
1661 1661
 
1662
-		if ( ! empty( $this->footnotes_ordered ) ) {
1662
+		if (!empty($this->footnotes_ordered)) {
1663 1663
 			$this->_doFootnotes();
1664
-			if ( ! $this->omit_footnotes ) {
1664
+			if (!$this->omit_footnotes) {
1665 1665
 				$text .= "\n\n";
1666 1666
 				$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
1667 1667
 				$text .= "<hr" . $this->empty_element_suffix . "\n";
@@ -1712,12 +1712,12 @@  discard block
 block discarded – undo
1712 1712
 
1713 1713
 			// Prepare backlink, multiple backlinks if multiple references
1714 1714
 			$label = !empty($this->fn_backlink_label)
1715
-				? ' aria-label="'.$this->buildFootnoteLabel($num, 1).'"'
1715
+				? ' aria-label="' . $this->buildFootnoteLabel($num, 1) . '"'
1716 1716
 				: '';
1717 1717
 			$backlink = "<a href=\"#fnref:$note_id\"{$attr}{$label}>$backlink_text</a>";
1718 1718
 			for ($ref_num = 2; $ref_num <= $ref_count; ++$ref_num) {
1719 1719
 				if (!empty($this->fn_backlink_label)) {
1720
-					$label = ' aria-label="'.$this->buildFootnoteLabel($num, $ref_num).'"';
1720
+					$label = ' aria-label="' . $this->buildFootnoteLabel($num, $ref_num) . '"';
1721 1721
 				}
1722 1722
 				$backlink .= " <a href=\"#fnref$ref_num:$note_id\"{$attr}{$label}>$backlink_text</a>";
1723 1723
 			}
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 		// Create footnote marker only if it has a corresponding footnote *and*
1749 1749
 		// the footnote hasn't been used by another marker.
1750 1750
 		if (isset($this->footnotes[$node_id])) {
1751
-			$num =& $this->footnotes_numbers[$node_id];
1751
+			$num = & $this->footnotes_numbers[$node_id];
1752 1752
 			if (!isset($num)) {
1753 1753
 				// Transfer footnote content to the ordered list and give it its
1754 1754
 				// number
@@ -1777,8 +1777,8 @@  discard block
 block discarded – undo
1777 1777
 			$node_id = $this->encodeAttribute($node_id);
1778 1778
 
1779 1779
 			return
1780
-				"<sup id=\"fnref$ref_count_mark:$node_id\">".
1781
-				"<a href=\"#fn:$node_id\"$attr>$num</a>".
1780
+				"<sup id=\"fnref$ref_count_mark:$node_id\">" .
1781
+				"<a href=\"#fn:$node_id\"$attr>$num</a>" .
1782 1782
 				"</sup>";
1783 1783
 		}
1784 1784
 
Please login to merge, or discard this patch.