Passed
Pull Request — lib (#298)
by Michael
02:55
created
Readme.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 // you like.
6 6
 
7 7
 // Install PSR-4-compatible class autoloader
8
-spl_autoload_register(function($class){
9
-	require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
8
+spl_autoload_register(function($class) {
9
+	require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')) . '.php';
10 10
 });
11 11
 // If using Composer, use this instead:
12 12
 //require 'vendor/autoloader.php';
Please login to merge, or discard this patch.
Michelf/MarkdownExtra.php 1 patch
Spacing   +64 added lines, -64 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();
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 		// Compose attributes as string
253 253
 		$attr_str = "";
254 254
 		if (!empty($id)) {
255
-			$attr_str .= ' id="'.$this->encodeAttribute($id) .'"';
255
+			$attr_str .= ' id="' . $this->encodeAttribute($id) . '"';
256 256
 		}
257 257
 		if (!empty($classes)) {
258
-			$attr_str .= ' class="'. implode(" ", $classes) . '"';
258
+			$attr_str .= ' class="' . implode(" ", $classes) . '"';
259 259
 		}
260 260
 		if (!$this->no_markup && !empty($attributes)) {
261
-			$attr_str .= ' '.implode(" ", $attributes);
261
+			$attr_str .= ' ' . implode(" ", $attributes);
262 262
 		}
263 263
 		return $attr_str;
264 264
 	}
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
 		// Link defs are in the form: ^[id]: url "optional title"
276 276
 		$text = preg_replace_callback('{
277
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
277
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
278 278
 							  [ ]*
279 279
 							  \n?				# maybe *one* newline
280 280
 							  [ ]*
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 								[")]
294 294
 								[ ]*
295 295
 							)?	# title is optional
296
-					(?:[ ]* '.$this->id_class_attr_catch_re.' )?  # $5 = extra id & class attr
296
+					(?:[ ]* '.$this->id_class_attr_catch_re . ' )?  # $5 = extra id & class attr
297 297
 							(?:\n+|\Z)
298 298
 			}xm',
299 299
 			array($this, '_stripLinkDefinitions_callback'),
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 		$link_id = strtolower($matches[1]);
311 311
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
312 312
 		$this->urls[$link_id] = $url;
313
-		$this->titles[$link_id] =& $matches[4];
314
-		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]);
313
+		$this->titles[$link_id] = & $matches[4];
314
+		$this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]);
315 315
 		return ''; // String that will replace the block
316 316
 	}
317 317
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		}
375 375
 
376 376
 		// Call the HTML-in-Markdown hasher.
377
-		list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
377
+		list($text,) = $this->_hashHTMLBlocks_inMarkdown($text);
378 378
 
379 379
 		return $text;
380 380
 	}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 					<\?.*?\?> | <%.*?%>	# Processing instruction
452 452
 				|
453 453
 					<!\[CDATA\[.*?\]\]>	# CData Block
454
-				' . ( !$span ? ' # If not in span.
454
+				' . (!$span ? ' # If not in span.
455 455
 				|
456 456
 					# Indented code block
457 457
 					(?: ^[ ]*\n | ^ | \n[ ]*\n )
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 					(?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes
470 470
 					[ ]*
471 471
 					(?= \n )
472
-				' : '' ) . ' # End (if not is span).
472
+				' : '') . ' # End (if not is span).
473 473
 				|
474 474
 					# Code span marker
475 475
 					# Note, this regex needs to go after backtick fenced
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 			}xs';
481 481
 
482 482
 
483
-		$depth = 0;		// Current depth inside the tag tree.
484
-		$parsed = "";	// Parsed text that will be returned.
483
+		$depth = 0; // Current depth inside the tag tree.
484
+		$parsed = ""; // Parsed text that will be returned.
485 485
 
486 486
 		// Loop through every tag until we find the closing tag of the parent
487 487
 		// or loop until reaching the end of text if no parent tag specified.
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 			//            Opening Context Block tag (like ins and del)
560 560
 			//               used as a block tag (tag is alone on it's line).
561 561
 			else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) ||
562
-				(	preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
562
+				(preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
563 563
 					preg_match($newline_before_re, $parsed) &&
564
-					preg_match($newline_after_re, $text)	)
564
+					preg_match($newline_after_re, $text))
565 565
 				)
566 566
 			{
567 567
 				// Need to parse tag and following text using the HTML parser.
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			{
591 591
 				// Increase/decrease nested tag count.
592 592
 				if ($tag{1} == '/')						$depth--;
593
-				else if ($tag{strlen($tag)-2} != '/')	$depth++;
593
+				else if ($tag{strlen($tag) - 2} != '/')	$depth++;
594 594
 
595 595
 				if ($depth < 0) {
596 596
 					// Going out of parent element. Clean up and break so we
@@ -665,11 +665,11 @@  discard block
 block discarded – undo
665 665
 				)
666 666
 			}xs';
667 667
 
668
-		$original_text = $text;		// Save original text in case of faliure.
668
+		$original_text = $text; // Save original text in case of faliure.
669 669
 
670
-		$depth		= 0;	// Current depth inside the tag tree.
671
-		$block_text	= "";	// Temporary text holder for current text.
672
-		$parsed		= "";	// Parsed text that will be returned.
670
+		$depth = 0; // Current depth inside the tag tree.
671
+		$block_text = ""; // Temporary text holder for current text.
672
+		$parsed = ""; // Parsed text that will be returned.
673 673
 
674 674
 		// Get the name of the starting tag.
675 675
 		// (This pattern makes $base_tag_name_re safe without quoting.)
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 				// the tag's name match base tag's.
710 710
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
711 711
 					if ($tag{1} == '/')						$depth--;
712
-					else if ($tag{strlen($tag)-2} != '/')	$depth++;
712
+					else if ($tag{strlen($tag) - 2} != '/')	$depth++;
713 713
 				}
714 714
 
715 715
 				// Check for `markdown="1"` attribute and handle it.
@@ -858,9 +858,9 @@  discard block
 block discarded – undo
858 858
 	 * @return string
859 859
 	 */
860 860
 	protected function _doAnchors_reference_callback($matches) {
861
-		$whole_match =  $matches[1];
862
-		$link_text   =  $matches[2];
863
-		$link_id     =& $matches[3];
861
+		$whole_match = $matches[1];
862
+		$link_text   = $matches[2];
863
+		$link_id     = & $matches[3];
864 864
 
865 865
 		if ($link_id == "") {
866 866
 			// for shortcut links like [this][] or [this].
@@ -876,10 +876,10 @@  discard block
 block discarded – undo
876 876
 			$url = $this->encodeURLAttribute($url);
877 877
 
878 878
 			$result = "<a href=\"$url\"";
879
-			if ( isset( $this->titles[$link_id] ) ) {
879
+			if (isset($this->titles[$link_id])) {
880 880
 				$title = $this->titles[$link_id];
881 881
 				$title = $this->encodeAttribute($title);
882
-				$result .=  " title=\"$title\"";
882
+				$result .= " title=\"$title\"";
883 883
 			}
884 884
 			if (isset($this->ref_attr[$link_id]))
885 885
 				$result .= $this->ref_attr[$link_id];
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
 	 * @return string
901 901
 	 */
902 902
 	protected function _doAnchors_inline_callback($matches) {
903
-		$whole_match	=  $matches[1];
904
-		$link_text		=  $this->runSpanGamut($matches[2]);
905
-		$url			=  $matches[3] == '' ? $matches[4] : $matches[3];
906
-		$title			=& $matches[7];
907
-		$attr  = $this->doExtraAttributes("a", $dummy =& $matches[8]);
903
+		$whole_match = $matches[1];
904
+		$link_text = $this->runSpanGamut($matches[2]);
905
+		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
906
+		$title = & $matches[7];
907
+		$attr  = $this->doExtraAttributes("a", $dummy = & $matches[8]);
908 908
 
909 909
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
910 910
 		// tag parser and hashed. Need to reverse the process before using the URL.
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 		$result = "<a href=\"$url\"";
918 918
 		if (isset($title)) {
919 919
 			$title = $this->encodeAttribute($title);
920
-			$result .=  " title=\"$title\"";
920
+			$result .= " title=\"$title\"";
921 921
 		}
922 922
 		$result .= $attr;
923 923
 
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 			if (isset($this->titles[$link_id])) {
1004 1004
 				$title = $this->titles[$link_id];
1005 1005
 				$title = $this->encodeAttribute($title);
1006
-				$result .=  " title=\"$title\"";
1006
+				$result .= " title=\"$title\"";
1007 1007
 			}
1008 1008
 			if (isset($this->ref_attr[$link_id]))
1009 1009
 				$result .= $this->ref_attr[$link_id];
@@ -1024,18 +1024,18 @@  discard block
 block discarded – undo
1024 1024
 	 * @return string
1025 1025
 	 */
1026 1026
 	protected function _doImages_inline_callback($matches) {
1027
-		$whole_match	= $matches[1];
1028
-		$alt_text		= $matches[2];
1027
+		$whole_match = $matches[1];
1028
+		$alt_text = $matches[2];
1029 1029
 		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
1030
-		$title			=& $matches[7];
1031
-		$attr  = $this->doExtraAttributes("img", $dummy =& $matches[8]);
1030
+		$title = & $matches[7];
1031
+		$attr  = $this->doExtraAttributes("img", $dummy = & $matches[8]);
1032 1032
 
1033 1033
 		$alt_text = $this->encodeAttribute($alt_text);
1034 1034
 		$url = $this->encodeURLAttribute($url);
1035 1035
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
1036 1036
 		if (isset($title)) {
1037 1037
 			$title = $this->encodeAttribute($title);
1038
-			$result .=  " title=\"$title\""; // $title already quoted
1038
+			$result .= " title=\"$title\""; // $title already quoted
1039 1039
 		}
1040 1040
 		$result .= $attr;
1041 1041
 		$result .= $this->empty_element_suffix;
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 		//
1074 1074
 		$text = preg_replace_callback('{
1075 1075
 				^(\#{1,6})	# $1 = string of #\'s
1076
-				[ ]'.($this->hashtag_protection ? '+' : '*').'
1076
+				[ ]'.($this->hashtag_protection ? '+' : '*') . '
1077 1077
 				(.+?)		# $2 = Header text
1078 1078
 				[ ]*
1079 1079
 				\#*			# optional closing #\'s (not counted)
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 
1101 1101
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
1102 1102
 
1103
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
1103
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId);
1104 1104
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>";
1105 1105
 		return "\n" . $this->hashBlock($block) . "\n\n";
1106 1106
 	}
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 		$level = strlen($matches[1]);
1115 1115
 
1116 1116
 		$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
1117
-		$attr  = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
1117
+		$attr  = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId);
1118 1118
 		$block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>";
1119 1119
 		return "\n" . $this->hashBlock($block) . "\n\n";
1120 1120
 	}
@@ -1185,8 +1185,8 @@  discard block
 block discarded – undo
1185 1185
 	 * @return string
1186 1186
 	 */
1187 1187
 	protected function _doTable_leadingPipe_callback($matches) {
1188
-		$head		= $matches[1];
1189
-		$underline	= $matches[2];
1188
+		$head = $matches[1];
1189
+		$underline = $matches[2];
1190 1190
 		$content	= $matches[3];
1191 1191
 
1192 1192
 		$content	= preg_replace('/^ *[|]/m', '', $content);
@@ -1215,14 +1215,14 @@  discard block
 block discarded – undo
1215 1215
 	 * @return string
1216 1216
 	 */
1217 1217
 	protected function _doTable_callback($matches) {
1218
-		$head		= $matches[1];
1219
-		$underline	= $matches[2];
1220
-		$content	= $matches[3];
1218
+		$head = $matches[1];
1219
+		$underline = $matches[2];
1220
+		$content = $matches[3];
1221 1221
 
1222 1222
 		// Remove any tailing pipes for each line.
1223
-		$head		= preg_replace('/[|] *$/m', '', $head);
1224
-		$underline	= preg_replace('/[|] *$/m', '', $underline);
1225
-		$content	= preg_replace('/[|] *$/m', '', $content);
1223
+		$head = preg_replace('/[|] *$/m', '', $head);
1224
+		$underline = preg_replace('/[|] *$/m', '', $underline);
1225
+		$content = preg_replace('/[|] *$/m', '', $content);
1226 1226
 
1227 1227
 		// Reading alignement from header underline.
1228 1228
 		$separators	= preg_split('/ *[|] */', $underline);
@@ -1239,10 +1239,10 @@  discard block
 block discarded – undo
1239 1239
 
1240 1240
 		// Parsing span elements, including code spans, character escapes,
1241 1241
 		// and inline HTML tags, so that pipes inside those gets ignored.
1242
-		$head		= $this->parseSpan($head);
1243
-		$headers	= preg_split('/ *[|] */', $head);
1244
-		$col_count	= count($headers);
1245
-		$attr       = array_pad($attr, $col_count, '');
1242
+		$head = $this->parseSpan($head);
1243
+		$headers = preg_split('/ *[|] */', $head);
1244
+		$col_count = count($headers);
1245
+		$attr = array_pad($attr, $col_count, '');
1246 1246
 
1247 1247
 		// Write column headers.
1248 1248
 		$text = "<table>\n";
@@ -1408,13 +1408,13 @@  discard block
 block discarded – undo
1408 1408
 	protected function _processDefListItems_callback_dd($matches) {
1409 1409
 		$leading_line	= $matches[1];
1410 1410
 		$marker_space	= $matches[2];
1411
-		$def			= $matches[3];
1411
+		$def = $matches[3];
1412 1412
 
1413 1413
 		if ($leading_line || preg_match('/\n{2,}/', $def)) {
1414 1414
 			// Replace marker with the appropriate whitespace indentation
1415 1415
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1416 1416
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1417
-			$def = "\n". $def ."\n";
1417
+			$def = "\n" . $def . "\n";
1418 1418
 		}
1419 1419
 		else {
1420 1420
 			$def = rtrim($def);
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
 	 * @return string
1477 1477
 	 */
1478 1478
 	protected function _doFencedCodeBlocks_callback($matches) {
1479
-		$classname =& $matches[2];
1480
-		$attrs     =& $matches[3];
1479
+		$classname = & $matches[2];
1480
+		$attrs     = & $matches[3];
1481 1481
 		$codeblock = $matches[4];
1482 1482
 
1483 1483
 		if ($this->code_block_content_func) {
@@ -1498,9 +1498,9 @@  discard block
 block discarded – undo
1498 1498
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
1499 1499
 		$pre_attr_str  = $this->code_attr_on_pre ? $attr_str : '';
1500 1500
 		$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
1501
-		$codeblock  = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1501
+		$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
1502 1502
 
1503
-		return "\n\n".$this->hashBlock($codeblock)."\n\n";
1503
+		return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
1504 1504
 	}
1505 1505
 
1506 1506
 	/**
@@ -1633,9 +1633,9 @@  discard block
 block discarded – undo
1633 1633
 		$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
1634 1634
 			array($this, '_appendFootnotes_callback'), $text);
1635 1635
 
1636
-		if ( ! empty( $this->footnotes_ordered ) ) {
1636
+		if (!empty($this->footnotes_ordered)) {
1637 1637
 			$this->_doFootnotes();
1638
-			if ( ! $this->omit_footnotes ) {
1638
+			if (!$this->omit_footnotes) {
1639 1639
 				$text .= "\n\n";
1640 1640
 				$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
1641 1641
 				$text .= "<hr" . $this->empty_element_suffix . "\n";
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 		// Create footnote marker only if it has a corresponding footnote *and*
1718 1718
 		// the footnote hasn't been used by another marker.
1719 1719
 		if (isset($this->footnotes[$node_id])) {
1720
-			$num =& $this->footnotes_numbers[$node_id];
1720
+			$num = & $this->footnotes_numbers[$node_id];
1721 1721
 			if (!isset($num)) {
1722 1722
 				// Transfer footnote content to the ordered list and give it its
1723 1723
 				// number
@@ -1746,8 +1746,8 @@  discard block
 block discarded – undo
1746 1746
 			$node_id = $this->encodeAttribute($node_id);
1747 1747
 
1748 1748
 			return
1749
-				"<sup id=\"fnref$ref_count_mark:$node_id\">".
1750
-				"<a href=\"#fn:$node_id\"$attr>$num</a>".
1749
+				"<sup id=\"fnref$ref_count_mark:$node_id\">" .
1750
+				"<a href=\"#fn:$node_id\"$attr>$num</a>" .
1751 1751
 				"</sup>";
1752 1752
 		}
1753 1753
 
Please login to merge, or discard this patch.
Michelf/Markdown.php 1 patch
Spacing   +78 added lines, -78 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,15 +157,15 @@  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 167
 		// Test change
168
-		$this->escape_chars_re = '['.preg_quote($this->escape_chars).']';
168
+		$this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']';
169 169
 
170 170
 		// Sort document, block, and span gamut in ascendent priority order.
171 171
 		asort($this->document_gamut);
@@ -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
 							  [ ]*
@@ -320,7 +320,7 @@  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];
323
+		$this->titles[$link_id] = & $matches[4];
324 324
 		return ''; // String that will replace the block
325 325
 	}
326 326
 
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 		 * *  List "b" is made of tags which are always block-level;
353 353
 		 */
354 354
 		$block_tags_a_re = 'ins|del';
355
-		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
356
-						   'script|noscript|style|form|fieldset|iframe|math|svg|'.
357
-						   'article|section|nav|aside|hgroup|header|footer|'.
355
+		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' .
356
+						   'script|noscript|style|form|fieldset|iframe|math|svg|' .
357
+						   'article|section|nav|aside|hgroup|header|footer|' .
358 358
 						   'figure';
359 359
 
360 360
 		// Regular expression for the content of a block tag.
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
 				  [^<]+			# content without tag
380 380
 				|
381 381
 				  <\2			# nested opening tag
382
-					'.$attr.'	# attributes
382
+					'.$attr . '	# attributes
383 383
 					(?>
384 384
 					  />
385 385
 					|
386
-					  >', $nested_tags_level).	// end of opening tag
387
-					  '.*?'.					// last level nested tag content
386
+					  >', $nested_tags_level) . // end of opening tag
387
+					  '.*?' . // last level nested tag content
388 388
 			str_repeat('
389 389
 					  </\2\s*>	# closing nested tag
390 390
 					)
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 			  # Match from `\n<tag>` to `</tag>\n`, handling nested tags
421 421
 			  # in between.
422 422
 
423
-						[ ]{0,'.$less_than_tab.'}
424
-						<('.$block_tags_b_re.')# start tag = $2
425
-						'.$attr.'>			# attributes followed by > and \n
426
-						'.$content.'		# content, support nesting
423
+						[ ]{0,'.$less_than_tab . '}
424
+						<('.$block_tags_b_re . ')# start tag = $2
425
+						'.$attr . '>			# attributes followed by > and \n
426
+						'.$content . '		# content, support nesting
427 427
 						</\2>				# the matching end tag
428 428
 						[ ]*				# trailing spaces/tabs
429 429
 						(?=\n+|\Z)	# followed by a newline or end of document
430 430
 
431 431
 			| # Special version for tags of group a.
432 432
 
433
-						[ ]{0,'.$less_than_tab.'}
434
-						<('.$block_tags_a_re.')# start tag = $3
435
-						'.$attr.'>[ ]*\n	# attributes followed by >
436
-						'.$content2.'		# content, support nesting
433
+						[ ]{0,'.$less_than_tab . '}
434
+						<('.$block_tags_a_re . ')# start tag = $3
435
+						'.$attr . '>[ ]*\n	# attributes followed by >
436
+						'.$content2 . '		# content, support nesting
437 437
 						</\3>				# the matching end tag
438 438
 						[ ]*				# trailing spaces/tabs
439 439
 						(?=\n+|\Z)	# followed by a newline or end of document
@@ -441,16 +441,16 @@  discard block
 block discarded – undo
441 441
 			| # Special case just for <hr />. It was easier to make a special
442 442
 			  # case than to make the other regex more complicated.
443 443
 
444
-						[ ]{0,'.$less_than_tab.'}
444
+						[ ]{0,'.$less_than_tab . '}
445 445
 						<(hr)				# start tag = $2
446
-						'.$attr.'			# attributes
446
+						'.$attr . '			# attributes
447 447
 						/?>					# the matching end tag
448 448
 						[ ]*
449 449
 						(?=\n{2,}|\Z)		# followed by a blank line or end of document
450 450
 
451 451
 			| # Special case for standalone HTML comments:
452 452
 
453
-					[ ]{0,'.$less_than_tab.'}
453
+					[ ]{0,'.$less_than_tab . '}
454 454
 					(?s:
455 455
 						<!-- .*? -->
456 456
 					)
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
 			| # PHP and ASP-style processor instructions (<? and <%)
461 461
 
462
-					[ ]{0,'.$less_than_tab.'}
462
+					[ ]{0,'.$less_than_tab . '}
463 463
 					(?s:
464 464
 						<([?%])			# $2
465 465
 						.*?
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 				[ ]*		# Tailing spaces
591 591
 				$			# End of line.
592 592
 			}mx',
593
-			"\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n",
593
+			"\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n",
594 594
 			$text
595 595
 		);
596 596
 	}
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 		$text = preg_replace_callback('{
670 670
 			(					# wrap whole match in $1
671 671
 			  \[
672
-				('.$this->nested_brackets_re.')	# link text = $2
672
+				('.$this->nested_brackets_re . ')	# link text = $2
673 673
 			  \]
674 674
 
675 675
 			  [ ]?				# one optional space
@@ -686,14 +686,14 @@  discard block
 block discarded – undo
686 686
 		$text = preg_replace_callback('{
687 687
 			(				# wrap whole match in $1
688 688
 			  \[
689
-				('.$this->nested_brackets_re.')	# link text = $2
689
+				('.$this->nested_brackets_re . ')	# link text = $2
690 690
 			  \]
691 691
 			  \(			# literal paren
692 692
 				[ \n]*
693 693
 				(?:
694 694
 					<(.+?)>	# href = $3
695 695
 				|
696
-					('.$this->nested_url_parenthesis_re.')	# href = $4
696
+					('.$this->nested_url_parenthesis_re . ')	# href = $4
697 697
 				)
698 698
 				[ \n]*
699 699
 				(			# $5
@@ -729,9 +729,9 @@  discard block
 block discarded – undo
729 729
 	 * @return string
730 730
 	 */
731 731
 	protected function _doAnchors_reference_callback($matches) {
732
-		$whole_match =  $matches[1];
733
-		$link_text   =  $matches[2];
734
-		$link_id     =& $matches[3];
732
+		$whole_match = $matches[1];
733
+		$link_text   = $matches[2];
734
+		$link_id     = & $matches[3];
735 735
 
736 736
 		if ($link_id == "") {
737 737
 			// for shortcut links like [this][] or [this].
@@ -747,10 +747,10 @@  discard block
 block discarded – undo
747 747
 			$url = $this->encodeURLAttribute($url);
748 748
 
749 749
 			$result = "<a href=\"$url\"";
750
-			if ( isset( $this->titles[$link_id] ) ) {
750
+			if (isset($this->titles[$link_id])) {
751 751
 				$title = $this->titles[$link_id];
752 752
 				$title = $this->encodeAttribute($title);
753
-				$result .=  " title=\"$title\"";
753
+				$result .= " title=\"$title\"";
754 754
 			}
755 755
 
756 756
 			$link_text = $this->runSpanGamut($link_text);
@@ -768,10 +768,10 @@  discard block
 block discarded – undo
768 768
 	 * @return string
769 769
 	 */
770 770
 	protected function _doAnchors_inline_callback($matches) {
771
-		$whole_match	=  $matches[1];
772
-		$link_text		=  $this->runSpanGamut($matches[2]);
773
-		$url			=  $matches[3] == '' ? $matches[4] : $matches[3];
774
-		$title			=& $matches[7];
771
+		$whole_match = $matches[1];
772
+		$link_text = $this->runSpanGamut($matches[2]);
773
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
774
+		$title = & $matches[7];
775 775
 
776 776
 		// If the URL was of the form <s p a c e s> it got caught by the HTML
777 777
 		// tag parser and hashed. Need to reverse the process before using
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 		$result = "<a href=\"$url\"";
786 786
 		if (isset($title)) {
787 787
 			$title = $this->encodeAttribute($title);
788
-			$result .=  " title=\"$title\"";
788
+			$result .= " title=\"$title\"";
789 789
 		}
790 790
 
791 791
 		$link_text = $this->runSpanGamut($link_text);
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		$text = preg_replace_callback('{
805 805
 			(				# wrap whole match in $1
806 806
 			  !\[
807
-				('.$this->nested_brackets_re.')		# alt text = $2
807
+				('.$this->nested_brackets_re . ')		# alt text = $2
808 808
 			  \]
809 809
 
810 810
 			  [ ]?				# one optional space
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 		$text = preg_replace_callback('{
824 824
 			(				# wrap whole match in $1
825 825
 			  !\[
826
-				('.$this->nested_brackets_re.')		# alt text = $2
826
+				('.$this->nested_brackets_re . ')		# alt text = $2
827 827
 			  \]
828 828
 			  \s?			# One optional whitespace character
829 829
 			  \(			# literal paren
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 				(?:
832 832
 					<(\S*)>	# src url = $3
833 833
 				|
834
-					('.$this->nested_url_parenthesis_re.')	# src url = $4
834
+					('.$this->nested_url_parenthesis_re . ')	# src url = $4
835 835
 				)
836 836
 				[ \n]*
837 837
 				(			# $5
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 			if (isset($this->titles[$link_id])) {
870 870
 				$title = $this->titles[$link_id];
871 871
 				$title = $this->encodeAttribute($title);
872
-				$result .=  " title=\"$title\"";
872
+				$result .= " title=\"$title\"";
873 873
 			}
874 874
 			$result .= $this->empty_element_suffix;
875 875
 			$result = $this->hashPart($result);
@@ -887,17 +887,17 @@  discard block
 block discarded – undo
887 887
 	 * @return string
888 888
 	 */
889 889
 	protected function _doImages_inline_callback($matches) {
890
-		$whole_match	= $matches[1];
891
-		$alt_text		= $matches[2];
892
-		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
893
-		$title			=& $matches[7];
890
+		$whole_match = $matches[1];
891
+		$alt_text = $matches[2];
892
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
893
+		$title = & $matches[7];
894 894
 
895 895
 		$alt_text = $this->encodeAttribute($alt_text);
896 896
 		$url = $this->encodeURLAttribute($url);
897 897
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
898 898
 		if (isset($title)) {
899 899
 			$title = $this->encodeAttribute($title);
900
-			$result .=  " title=\"$title\""; // $title already quoted
900
+			$result .= " title=\"$title\""; // $title already quoted
901 901
 		}
902 902
 		$result .= $this->empty_element_suffix;
903 903
 
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 		// ID attribute generation
959 959
 		$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
960 960
 
961
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[1])."</h$level>";
961
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[1]) . "</h$level>";
962 962
 		return "\n" . $this->hashBlock($block) . "\n\n";
963 963
 	}
964 964
 
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 		$idAtt = $this->_generateIdFromHeaderValue($matches[2]);
973 973
 
974 974
 		$level = strlen($matches[1]);
975
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[2])."</h$level>";
975
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[2]) . "</h$level>";
976 976
 		return "\n" . $this->hashBlock($block) . "\n\n";
977 977
 	}
978 978
 
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
 			$whole_list_re = '
1021 1021
 				(								# $1 = whole list
1022 1022
 				  (								# $2
1023
-					([ ]{0,'.$less_than_tab.'})	# $3 = number of spaces
1024
-					('.$marker_re.')			# $4 = first list item marker
1023
+					([ ]{0,'.$less_than_tab . '})	# $3 = number of spaces
1024
+					('.$marker_re . ')			# $4 = first list item marker
1025 1025
 					[ ]+
1026 1026
 				  )
1027 1027
 				  (?s:.+?)
@@ -1032,13 +1032,13 @@  discard block
 block discarded – undo
1032 1032
 					  (?=\S)
1033 1033
 					  (?!						# Negative lookahead for another list item marker
1034 1034
 						[ ]*
1035
-						'.$marker_re.'[ ]+
1035
+						'.$marker_re . '[ ]+
1036 1036
 					  )
1037 1037
 					|
1038 1038
 					  (?=						# Lookahead for another kind of list
1039 1039
 					    \n
1040 1040
 						\3						# Must have the same indentation
1041
-						'.$other_marker_re.'[ ]+
1041
+						'.$other_marker_re . '[ ]+
1042 1042
 					  )
1043 1043
 				  )
1044 1044
 				)
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 			if ($this->list_level) {
1051 1051
 				$text = preg_replace_callback('{
1052 1052
 						^
1053
-						'.$whole_list_re.'
1053
+						'.$whole_list_re . '
1054 1054
 					}mx',
1055 1055
 					array($this, '_doLists_callback'), $text);
1056 1056
 			} else {
1057 1057
 				$text = preg_replace_callback('{
1058 1058
 						(?:(?<=\n)\n|\A\n?) # Must eat the newline
1059
-						'.$whole_list_re.'
1059
+						'.$whole_list_re . '
1060 1060
 					}mx',
1061 1061
 					array($this, '_doLists_callback'), $text);
1062 1062
 			}
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		$list = $matches[1];
1081 1081
 		$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
1082 1082
 
1083
-		$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
1083
+		$marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re);
1084 1084
 
1085 1085
 		$list .= "\n";
1086 1086
 		$result = $this->processListItems($list, $marker_any_re);
@@ -1091,18 +1091,18 @@  discard block
 block discarded – undo
1091 1091
 			if ($list_type == 'ol') {
1092 1092
 				$ol_start_array = array();
1093 1093
 				$ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array);
1094
-				if ($ol_start_check){
1094
+				if ($ol_start_check) {
1095 1095
 					$ol_start = $ol_start_array[0];
1096 1096
 				}
1097 1097
 			}
1098 1098
 		}
1099 1099
 
1100
-		if ($ol_start > 1 && $list_type == 'ol'){
1100
+		if ($ol_start > 1 && $list_type == 'ol') {
1101 1101
 			$result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>");
1102 1102
 		} else {
1103 1103
 			$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
1104 1104
 		}
1105
-		return "\n". $result ."\n\n";
1105
+		return "\n" . $result . "\n\n";
1106 1106
 	}
1107 1107
 
1108 1108
 	/**
@@ -1149,12 +1149,12 @@  discard block
 block discarded – undo
1149 1149
 		$list_str = preg_replace_callback('{
1150 1150
 			(\n)?							# leading line = $1
1151 1151
 			(^[ ]*)							# leading whitespace = $2
1152
-			('.$marker_any_re.'				# list marker and space = $3
1152
+			('.$marker_any_re . '				# list marker and space = $3
1153 1153
 				(?:[ ]+|(?=\n))	# space only required if item is not empty
1154 1154
 			)
1155 1155
 			((?s:.*?))						# list item text   = $4
1156 1156
 			(?:(\n+(?=\n))|\n)				# tailing blank line = $5
1157
-			(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
1157
+			(?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n))))
1158 1158
 			}xm',
1159 1159
 			array($this, '_processListItems_callback'), $list_str);
1160 1160
 
@@ -1169,17 +1169,17 @@  discard block
 block discarded – undo
1169 1169
 	 */
1170 1170
 	protected function _processListItems_callback($matches) {
1171 1171
 		$item = $matches[4];
1172
-		$leading_line =& $matches[1];
1173
-		$leading_space =& $matches[2];
1172
+		$leading_line = & $matches[1];
1173
+		$leading_space = & $matches[2];
1174 1174
 		$marker_space = $matches[3];
1175
-		$tailing_blank_line =& $matches[5];
1175
+		$tailing_blank_line = & $matches[5];
1176 1176
 
1177 1177
 		if ($leading_line || $tailing_blank_line ||
1178 1178
 			preg_match('/\n{2,}/', $item))
1179 1179
 		{
1180 1180
 			// Replace marker with the appropriate whitespace indentation
1181 1181
 			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1182
-			$item = $this->runBlockGamut($this->outdent($item)."\n");
1182
+			$item = $this->runBlockGamut($this->outdent($item) . "\n");
1183 1183
 		} else {
1184 1184
 			// Recursion for sub-lists:
1185 1185
 			$item = $this->doLists($this->outdent($item));
@@ -1199,11 +1199,11 @@  discard block
 block discarded – undo
1199 1199
 				(?:\n\n|\A\n?)
1200 1200
 				(	            # $1 = the code block -- one or more lines, starting with a space/tab
1201 1201
 				  (?>
1202
-					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces
1202
+					[ ]{'.$this->tab_width . '}  # Lines must start with a tab or a tab-width of spaces
1203 1203
 					.*\n+
1204 1204
 				  )+
1205 1205
 				)
1206
-				((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1206
+				((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1207 1207
 			}xm',
1208 1208
 			array($this, '_doCodeBlocks_callback'), $text);
1209 1209
 
@@ -1331,8 +1331,8 @@  discard block
 block discarded – undo
1331 1331
 			// Each token is then passed to handleSpanToken.
1332 1332
 			$parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
1333 1333
 			$text_stack[0] .= $parts[0];
1334
-			$token =& $parts[1];
1335
-			$text =& $parts[2];
1334
+			$token = & $parts[1];
1335
+			$text = & $parts[2];
1336 1336
 
1337 1337
 			if (empty($token)) {
1338 1338
 				// Reached end of text span: empty stack without emitting.
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
 				} else {
1360 1360
 					// Other closing marker: close one em or strong and
1361 1361
 					// change current token state to match the other
1362
-					$token_stack[0] = str_repeat($token{0}, 3-$token_len);
1362
+					$token_stack[0] = str_repeat($token{0}, 3 - $token_len);
1363 1363
 					$tag = $token_len == 2 ? "strong" : "em";
1364 1364
 					$span = $text_stack[0];
1365 1365
 					$span = $this->runSpanGamut($span);
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		}
1706 1706
 
1707 1707
 		$chars = preg_split('/(?<!^)(?!$)/', $text);
1708
-		$seed = (int)abs(crc32($text) / strlen($text)); // Deterministic seed.
1708
+		$seed = (int) abs(crc32($text) / strlen($text)); // Deterministic seed.
1709 1709
 
1710 1710
 		foreach ($chars as $key => $char) {
1711 1711
 			$ord = ord($char);
@@ -1718,9 +1718,9 @@  discard block
 block discarded – undo
1718 1718
 				if ($r > 90 && strpos('@"&>', $char) === false) {
1719 1719
 					/* do nothing */
1720 1720
 				} else if ($r < 45) {
1721
-					$chars[$key] = '&#x'.dechex($ord).';';
1721
+					$chars[$key] = '&#x' . dechex($ord) . ';';
1722 1722
 				} else {
1723
-					$chars[$key] = '&#'.$ord.';';
1723
+					$chars[$key] = '&#' . $ord . ';';
1724 1724
 				}
1725 1725
 			}
1726 1726
 		}
@@ -1742,11 +1742,11 @@  discard block
 block discarded – undo
1742 1742
 
1743 1743
 		$span_re = '{
1744 1744
 				(
1745
-					\\\\'.$this->escape_chars_re.'
1745
+					\\\\'.$this->escape_chars_re . '
1746 1746
 				|
1747 1747
 					(?<![`\\\\])
1748 1748
 					`+						# code span marker
1749
-			'.( $this->no_markup ? '' : '
1749
+			'.($this->no_markup ? '' : '
1750 1750
 				|
1751 1751
 					<!--    .*?     -->		# comment
1752 1752
 				|
@@ -1762,7 +1762,7 @@  discard block
 block discarded – undo
1762 1762
 					<[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag
1763 1763
 				|
1764 1764
 					</[-a-zA-Z0-9:_]+\s*> # closing tag
1765
-			').'
1765
+			') . '
1766 1766
 				)
1767 1767
 				}xs';
1768 1768
 
@@ -1799,10 +1799,10 @@  discard block
 block discarded – undo
1799 1799
 	protected function handleSpanToken($token, &$str) {
1800 1800
 		switch ($token{0}) {
1801 1801
 			case "\\":
1802
-				return $this->hashPart("&#". ord($token{1}). ";");
1802
+				return $this->hashPart("&#" . ord($token{1}) . ";");
1803 1803
 			case "`":
1804 1804
 				// Search for end marker in remaining text.
1805
-				if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
1805
+				if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm',
1806 1806
 					$str, $matches))
1807 1807
 				{
1808 1808
 					$str = $matches[2];
Please login to merge, or discard this patch.