Completed
Branch lib (9da5a6)
by Michel
02:57
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 2 patches
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.
Braces   +75 added lines, -52 removed lines patch added patch discarded remove patch
@@ -170,8 +170,9 @@  discard block
 block discarded – undo
170 170
 		$this->footnotes_assembled = null;
171 171
 
172 172
 		foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
173
-			if ($this->abbr_word_re)
174
-				$this->abbr_word_re .= '|';
173
+			if ($this->abbr_word_re) {
174
+							$this->abbr_word_re .= '|';
175
+			}
175 176
 			$this->abbr_word_re .= preg_quote($abbr_word);
176 177
 			$this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
177 178
 		}
@@ -188,8 +189,9 @@  discard block
 block discarded – undo
188 189
 		$this->abbr_desciptions = array();
189 190
 		$this->abbr_word_re = '';
190 191
 
191
-		if ( ! $this->omit_footnotes )
192
-			$this->footnotes_assembled = null;
192
+		if ( ! $this->omit_footnotes ) {
193
+					$this->footnotes_assembled = null;
194
+		}
193 195
 
194 196
 		parent::teardown();
195 197
 	}
@@ -227,7 +229,9 @@  discard block
 block discarded – undo
227 229
 	 * @return string
228 230
 	 */
229 231
 	protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $classes = array()) {
230
-		if (empty($attr) && !$defaultIdValue && empty($classes)) return "";
232
+		if (empty($attr) && !$defaultIdValue && empty($classes)) {
233
+			return "";
234
+		}
231 235
 
232 236
 		// Split on components
233 237
 		preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches);
@@ -240,14 +244,18 @@  discard block
 block discarded – undo
240 244
 			if ($element{0} == '.') {
241 245
 				$classes[] = substr($element, 1);
242 246
 			} else if ($element{0} == '#') {
243
-				if ($id === false) $id = substr($element, 1);
247
+				if ($id === false) {
248
+					$id = substr($element, 1);
249
+				}
244 250
 			} else if (strpos($element, '=') > 0) {
245 251
 				$parts = explode('=', $element, 2);
246 252
 				$attributes[] = $parts[0] . '="' . $parts[1] . '"';
247 253
 			}
248 254
 		}
249 255
 
250
-		if (!$id) $id = $defaultIdValue;
256
+		if (!$id) {
257
+			$id = $defaultIdValue;
258
+		}
251 259
 
252 260
 		// Compose attributes as string
253 261
 		$attr_str = "";
@@ -414,7 +422,9 @@  discard block
 block discarded – undo
414 422
 										$enclosing_tag_re = '', $span = false)
415 423
 	{
416 424
 
417
-		if ($text === '') return array('', '');
425
+		if ($text === '') {
426
+			return array('', '');
427
+		}
418 428
 
419 429
 		// Regex to check for the presense of newlines around a block tag.
420 430
 		$newline_before_re = '/(?:^\n?|\n\n)*$/';
@@ -526,8 +536,7 @@  discard block
 block discarded – undo
526 536
 					// End marker found: pass text unchanged until marker.
527 537
 					$parsed .= $tag . $matches[0];
528 538
 					$text = substr($text, strlen($matches[0]));
529
-				}
530
-				else {
539
+				} else {
531 540
 					// No end marker: just skip it.
532 541
 					$parsed .= $tag;
533 542
 				}
@@ -549,8 +558,7 @@  discard block
 block discarded – undo
549 558
 					// End marker found: pass text unchanged until marker.
550 559
 					$parsed .= $tag . $matches[0];
551 560
 					$text = substr($text, strlen($matches[0]));
552
-				}
553
-				else {
561
+				} else {
554 562
 					// Unmatched marker: just skip it.
555 563
 					$parsed .= $tag;
556 564
 				}
@@ -589,8 +597,11 @@  discard block
 block discarded – undo
589 597
 				preg_match('{^</?(?:' . $enclosing_tag_re . ')\b}', $tag))
590 598
 			{
591 599
 				// Increase/decrease nested tag count.
592
-				if ($tag{1} == '/')						$depth--;
593
-				else if ($tag{strlen($tag)-2} != '/')	$depth++;
600
+				if ($tag{1} == '/') {
601
+					$depth--;
602
+				} else if ($tag{strlen($tag)-2} != '/') {
603
+					$depth++;
604
+				}
594 605
 
595 606
 				if ($depth < 0) {
596 607
 					// Going out of parent element. Clean up and break so we
@@ -600,8 +611,7 @@  discard block
 block discarded – undo
600 611
 				}
601 612
 
602 613
 				$parsed .= $tag;
603
-			}
604
-			else {
614
+			} else {
605 615
 				$parsed .= $tag;
606 616
 			}
607 617
 		} while ($depth >= 0);
@@ -624,7 +634,9 @@  discard block
 block discarded – undo
624 634
 	 * @return array
625 635
 	 */
626 636
 	protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
627
-		if ($text === '') return array('', '');
637
+		if ($text === '') {
638
+			return array('', '');
639
+		}
628 640
 
629 641
 		// Regex to match `markdown` attribute inside of a tag.
630 642
 		$markdown_attr_re = '
@@ -673,8 +685,9 @@  discard block
 block discarded – undo
673 685
 
674 686
 		// Get the name of the starting tag.
675 687
 		// (This pattern makes $base_tag_name_re safe without quoting.)
676
-		if (preg_match('/^<([\w:$]*)\b/', $text, $matches))
677
-			$base_tag_name_re = $matches[1];
688
+		if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) {
689
+					$base_tag_name_re = $matches[1];
690
+		}
678 691
 
679 692
 		// Loop through every tag until we find the corresponding closing tag.
680 693
 		do {
@@ -703,13 +716,15 @@  discard block
 block discarded – undo
703 716
 			{
704 717
 				// Just add the tag to the block as if it was text.
705 718
 				$block_text .= $tag;
706
-			}
707
-			else {
719
+			} else {
708 720
 				// Increase/decrease nested tag count. Only do so if
709 721
 				// the tag's name match base tag's.
710 722
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
711
-					if ($tag{1} == '/')						$depth--;
712
-					else if ($tag{strlen($tag)-2} != '/')	$depth++;
723
+					if ($tag{1} == '/') {
724
+						$depth--;
725
+					} else if ($tag{strlen($tag)-2} != '/') {
726
+						$depth++;
727
+					}
713 728
 				}
714 729
 
715 730
 				// Check for `markdown="1"` attribute and handle it.
@@ -754,13 +769,17 @@  discard block
 block discarded – undo
754 769
 					}
755 770
 
756 771
 					// Append tag content to parsed text.
757
-					if (!$span_mode)	$parsed .= "\n\n$block_text\n\n";
758
-					else				$parsed .= "$block_text";
772
+					if (!$span_mode) {
773
+						$parsed .= "\n\n$block_text\n\n";
774
+					} else {
775
+						$parsed .= "$block_text";
776
+					}
759 777
 
760 778
 					// Start over with a new block.
761 779
 					$block_text = "";
780
+				} else {
781
+					$block_text .= $tag;
762 782
 				}
763
-				else $block_text .= $tag;
764 783
 			}
765 784
 
766 785
 		} while ($depth > 0);
@@ -881,14 +900,14 @@  discard block
 block discarded – undo
881 900
 				$title = $this->encodeAttribute($title);
882 901
 				$result .=  " title=\"$title\"";
883 902
 			}
884
-			if (isset($this->ref_attr[$link_id]))
885
-				$result .= $this->ref_attr[$link_id];
903
+			if (isset($this->ref_attr[$link_id])) {
904
+							$result .= $this->ref_attr[$link_id];
905
+			}
886 906
 
887 907
 			$link_text = $this->runSpanGamut($link_text);
888 908
 			$result .= ">$link_text</a>";
889 909
 			$result = $this->hashPart($result);
890
-		}
891
-		else {
910
+		} else {
892 911
 			$result = $whole_match;
893 912
 		}
894 913
 		return $result;
@@ -909,8 +928,9 @@  discard block
 block discarded – undo
909 928
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
910 929
 		// tag parser and hashed. Need to reverse the process before using the URL.
911 930
 		$unhashed = $this->unhash($url);
912
-		if ($unhashed != $url)
913
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
931
+		if ($unhashed != $url) {
932
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
933
+		}
914 934
 
915 935
 		$url = $this->encodeURLAttribute($url);
916 936
 
@@ -1005,12 +1025,12 @@  discard block
 block discarded – undo
1005 1025
 				$title = $this->encodeAttribute($title);
1006 1026
 				$result .=  " title=\"$title\"";
1007 1027
 			}
1008
-			if (isset($this->ref_attr[$link_id]))
1009
-				$result .= $this->ref_attr[$link_id];
1028
+			if (isset($this->ref_attr[$link_id])) {
1029
+							$result .= $this->ref_attr[$link_id];
1030
+			}
1010 1031
 			$result .= $this->empty_element_suffix;
1011 1032
 			$result = $this->hashPart($result);
1012
-		}
1013
-		else {
1033
+		} else {
1014 1034
 			// If there's no such link ID, leave intact:
1015 1035
 			$result = $whole_match;
1016 1036
 		}
@@ -1227,14 +1247,15 @@  discard block
 block discarded – undo
1227 1247
 		// Reading alignement from header underline.
1228 1248
 		$separators	= preg_split('/ *[|] */', $underline);
1229 1249
 		foreach ($separators as $n => $s) {
1230
-			if (preg_match('/^ *-+: *$/', $s))
1231
-				$attr[$n] = $this->_doTable_makeAlignAttr('right');
1232
-			else if (preg_match('/^ *:-+: *$/', $s))
1233
-				$attr[$n] = $this->_doTable_makeAlignAttr('center');
1234
-			else if (preg_match('/^ *:-+ *$/', $s))
1235
-				$attr[$n] = $this->_doTable_makeAlignAttr('left');
1236
-			else
1237
-				$attr[$n] = '';
1250
+			if (preg_match('/^ *-+: *$/', $s)) {
1251
+							$attr[$n] = $this->_doTable_makeAlignAttr('right');
1252
+			} else if (preg_match('/^ *:-+: *$/', $s)) {
1253
+							$attr[$n] = $this->_doTable_makeAlignAttr('center');
1254
+			} else if (preg_match('/^ *:-+ *$/', $s)) {
1255
+							$attr[$n] = $this->_doTable_makeAlignAttr('left');
1256
+			} else {
1257
+							$attr[$n] = '';
1258
+			}
1238 1259
 		}
1239 1260
 
1240 1261
 		// Parsing span elements, including code spans, character escapes,
@@ -1248,8 +1269,9 @@  discard block
 block discarded – undo
1248 1269
 		$text = "<table>\n";
1249 1270
 		$text .= "<thead>\n";
1250 1271
 		$text .= "<tr>\n";
1251
-		foreach ($headers as $n => $header)
1252
-			$text .= "  <th$attr[$n]>" . $this->runSpanGamut(trim($header)) . "</th>\n";
1272
+		foreach ($headers as $n => $header) {
1273
+					$text .= "  <th$attr[$n]>" . $this->runSpanGamut(trim($header)) . "</th>\n";
1274
+		}
1253 1275
 		$text .= "</tr>\n";
1254 1276
 		$text .= "</thead>\n";
1255 1277
 
@@ -1267,8 +1289,9 @@  discard block
 block discarded – undo
1267 1289
 			$row_cells = array_pad($row_cells, $col_count, '');
1268 1290
 
1269 1291
 			$text .= "<tr>\n";
1270
-			foreach ($row_cells as $n => $cell)
1271
-				$text .= "  <td$attr[$n]>" . $this->runSpanGamut(trim($cell)) . "</td>\n";
1292
+			foreach ($row_cells as $n => $cell) {
1293
+							$text .= "  <td$attr[$n]>" . $this->runSpanGamut(trim($cell)) . "</td>\n";
1294
+			}
1272 1295
 			$text .= "</tr>\n";
1273 1296
 		}
1274 1297
 		$text .= "</tbody>\n";
@@ -1415,8 +1438,7 @@  discard block
 block discarded – undo
1415 1438
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1416 1439
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1417 1440
 			$def = "\n". $def ."\n";
1418
-		}
1419
-		else {
1441
+		} else {
1420 1442
 			$def = rtrim($def);
1421 1443
 			$def = $this->runSpanGamut($this->outdent($def));
1422 1444
 		}
@@ -1491,8 +1513,9 @@  discard block
 block discarded – undo
1491 1513
 
1492 1514
 		$classes = array();
1493 1515
 		if ($classname != "") {
1494
-			if ($classname{0} == '.')
1495
-				$classname = substr($classname, 1);
1516
+			if ($classname{0} == '.') {
1517
+							$classname = substr($classname, 1);
1518
+			}
1496 1519
 			$classes[] = $this->code_class_prefix . $classname;
1497 1520
 		}
1498 1521
 		$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
Please login to merge, or discard this patch.
Michelf/Markdown.php 2 patches
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,14 +157,14 @@  discard block
 block discarded – undo
157 157
 		$this->prepareItalicsAndBold();
158 158
 
159 159
 		$this->nested_brackets_re =
160
-			str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth).
160
+			str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) .
161 161
 			str_repeat('\])*', $this->nested_brackets_depth);
162 162
 
163 163
 		$this->nested_url_parenthesis_re =
164
-			str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth).
164
+			str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) .
165 165
 			str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth);
166 166
 
167
-		$this->escape_chars_re = '['.preg_quote($this->escape_chars).']';
167
+		$this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']';
168 168
 
169 169
 		// Sort document, block, and span gamut in ascendent priority order.
170 170
 		asort($this->document_gamut);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
 		// Link defs are in the form: ^[id]: url "optional title"
285 285
 		$text = preg_replace_callback('{
286
-							^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?:	# id = $1
286
+							^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?:	# id = $1
287 287
 							  [ ]*
288 288
 							  \n?				# maybe *one* newline
289 289
 							  [ ]*
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		$link_id = strtolower($matches[1]);
320 320
 		$url = $matches[2] == '' ? $matches[3] : $matches[2];
321 321
 		$this->urls[$link_id] = $url;
322
-		$this->titles[$link_id] =& $matches[4];
322
+		$this->titles[$link_id] = & $matches[4];
323 323
 		return ''; // String that will replace the block
324 324
 	}
325 325
 
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 		 * *  List "b" is made of tags which are always block-level;
352 352
 		 */
353 353
 		$block_tags_a_re = 'ins|del';
354
-		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
355
-						   'script|noscript|style|form|fieldset|iframe|math|svg|'.
356
-						   'article|section|nav|aside|hgroup|header|footer|'.
354
+		$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' .
355
+						   'script|noscript|style|form|fieldset|iframe|math|svg|' .
356
+						   'article|section|nav|aside|hgroup|header|footer|' .
357 357
 						   'figure';
358 358
 
359 359
 		// Regular expression for the content of a block tag.
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
 				  [^<]+			# content without tag
379 379
 				|
380 380
 				  <\2			# nested opening tag
381
-					'.$attr.'	# attributes
381
+					'.$attr . '	# attributes
382 382
 					(?>
383 383
 					  />
384 384
 					|
385
-					  >', $nested_tags_level).	// end of opening tag
386
-					  '.*?'.					// last level nested tag content
385
+					  >', $nested_tags_level) . // end of opening tag
386
+					  '.*?' . // last level nested tag content
387 387
 			str_repeat('
388 388
 					  </\2\s*>	# closing nested tag
389 389
 					)
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
 			  # Match from `\n<tag>` to `</tag>\n`, handling nested tags
420 420
 			  # in between.
421 421
 
422
-						[ ]{0,'.$less_than_tab.'}
423
-						<('.$block_tags_b_re.')# start tag = $2
424
-						'.$attr.'>			# attributes followed by > and \n
425
-						'.$content.'		# content, support nesting
422
+						[ ]{0,'.$less_than_tab . '}
423
+						<('.$block_tags_b_re . ')# start tag = $2
424
+						'.$attr . '>			# attributes followed by > and \n
425
+						'.$content . '		# content, support nesting
426 426
 						</\2>				# the matching end tag
427 427
 						[ ]*				# trailing spaces/tabs
428 428
 						(?=\n+|\Z)	# followed by a newline or end of document
429 429
 
430 430
 			| # Special version for tags of group a.
431 431
 
432
-						[ ]{0,'.$less_than_tab.'}
433
-						<('.$block_tags_a_re.')# start tag = $3
434
-						'.$attr.'>[ ]*\n	# attributes followed by >
435
-						'.$content2.'		# content, support nesting
432
+						[ ]{0,'.$less_than_tab . '}
433
+						<('.$block_tags_a_re . ')# start tag = $3
434
+						'.$attr . '>[ ]*\n	# attributes followed by >
435
+						'.$content2 . '		# content, support nesting
436 436
 						</\3>				# the matching end tag
437 437
 						[ ]*				# trailing spaces/tabs
438 438
 						(?=\n+|\Z)	# followed by a newline or end of document
@@ -440,16 +440,16 @@  discard block
 block discarded – undo
440 440
 			| # Special case just for <hr />. It was easier to make a special
441 441
 			  # case than to make the other regex more complicated.
442 442
 
443
-						[ ]{0,'.$less_than_tab.'}
443
+						[ ]{0,'.$less_than_tab . '}
444 444
 						<(hr)				# start tag = $2
445
-						'.$attr.'			# attributes
445
+						'.$attr . '			# attributes
446 446
 						/?>					# the matching end tag
447 447
 						[ ]*
448 448
 						(?=\n{2,}|\Z)		# followed by a blank line or end of document
449 449
 
450 450
 			| # Special case for standalone HTML comments:
451 451
 
452
-					[ ]{0,'.$less_than_tab.'}
452
+					[ ]{0,'.$less_than_tab . '}
453 453
 					(?s:
454 454
 						<!-- .*? -->
455 455
 					)
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
 			| # PHP and ASP-style processor instructions (<? and <%)
460 460
 
461
-					[ ]{0,'.$less_than_tab.'}
461
+					[ ]{0,'.$less_than_tab . '}
462 462
 					(?s:
463 463
 						<([?%])			# $2
464 464
 						.*?
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 				[ ]*		# Tailing spaces
590 590
 				$			# End of line.
591 591
 			}mx',
592
-			"\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n",
592
+			"\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n",
593 593
 			$text
594 594
 		);
595 595
 	}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		$text = preg_replace_callback('{
669 669
 			(					# wrap whole match in $1
670 670
 			  \[
671
-				('.$this->nested_brackets_re.')	# link text = $2
671
+				('.$this->nested_brackets_re . ')	# link text = $2
672 672
 			  \]
673 673
 
674 674
 			  [ ]?				# one optional space
@@ -685,14 +685,14 @@  discard block
 block discarded – undo
685 685
 		$text = preg_replace_callback('{
686 686
 			(				# wrap whole match in $1
687 687
 			  \[
688
-				('.$this->nested_brackets_re.')	# link text = $2
688
+				('.$this->nested_brackets_re . ')	# link text = $2
689 689
 			  \]
690 690
 			  \(			# literal paren
691 691
 				[ \n]*
692 692
 				(?:
693 693
 					<(.+?)>	# href = $3
694 694
 				|
695
-					('.$this->nested_url_parenthesis_re.')	# href = $4
695
+					('.$this->nested_url_parenthesis_re . ')	# href = $4
696 696
 				)
697 697
 				[ \n]*
698 698
 				(			# $5
@@ -728,9 +728,9 @@  discard block
 block discarded – undo
728 728
 	 * @return string
729 729
 	 */
730 730
 	protected function _doAnchors_reference_callback($matches) {
731
-		$whole_match =  $matches[1];
732
-		$link_text   =  $matches[2];
733
-		$link_id     =& $matches[3];
731
+		$whole_match = $matches[1];
732
+		$link_text   = $matches[2];
733
+		$link_id     = & $matches[3];
734 734
 
735 735
 		if ($link_id == "") {
736 736
 			// for shortcut links like [this][] or [this].
@@ -746,10 +746,10 @@  discard block
 block discarded – undo
746 746
 			$url = $this->encodeURLAttribute($url);
747 747
 
748 748
 			$result = "<a href=\"$url\"";
749
-			if ( isset( $this->titles[$link_id] ) ) {
749
+			if (isset($this->titles[$link_id])) {
750 750
 				$title = $this->titles[$link_id];
751 751
 				$title = $this->encodeAttribute($title);
752
-				$result .=  " title=\"$title\"";
752
+				$result .= " title=\"$title\"";
753 753
 			}
754 754
 
755 755
 			$link_text = $this->runSpanGamut($link_text);
@@ -767,10 +767,10 @@  discard block
 block discarded – undo
767 767
 	 * @return string
768 768
 	 */
769 769
 	protected function _doAnchors_inline_callback($matches) {
770
-		$whole_match	=  $matches[1];
771
-		$link_text		=  $this->runSpanGamut($matches[2]);
772
-		$url			=  $matches[3] == '' ? $matches[4] : $matches[3];
773
-		$title			=& $matches[7];
770
+		$whole_match = $matches[1];
771
+		$link_text = $this->runSpanGamut($matches[2]);
772
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
773
+		$title = & $matches[7];
774 774
 
775 775
 		// If the URL was of the form <s p a c e s> it got caught by the HTML
776 776
 		// tag parser and hashed. Need to reverse the process before using
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 		$result = "<a href=\"$url\"";
785 785
 		if (isset($title)) {
786 786
 			$title = $this->encodeAttribute($title);
787
-			$result .=  " title=\"$title\"";
787
+			$result .= " title=\"$title\"";
788 788
 		}
789 789
 
790 790
 		$link_text = $this->runSpanGamut($link_text);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 		$text = preg_replace_callback('{
804 804
 			(				# wrap whole match in $1
805 805
 			  !\[
806
-				('.$this->nested_brackets_re.')		# alt text = $2
806
+				('.$this->nested_brackets_re . ')		# alt text = $2
807 807
 			  \]
808 808
 
809 809
 			  [ ]?				# one optional space
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 		$text = preg_replace_callback('{
823 823
 			(				# wrap whole match in $1
824 824
 			  !\[
825
-				('.$this->nested_brackets_re.')		# alt text = $2
825
+				('.$this->nested_brackets_re . ')		# alt text = $2
826 826
 			  \]
827 827
 			  \s?			# One optional whitespace character
828 828
 			  \(			# literal paren
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 				(?:
831 831
 					<(\S*)>	# src url = $3
832 832
 				|
833
-					('.$this->nested_url_parenthesis_re.')	# src url = $4
833
+					('.$this->nested_url_parenthesis_re . ')	# src url = $4
834 834
 				)
835 835
 				[ \n]*
836 836
 				(			# $5
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 			if (isset($this->titles[$link_id])) {
869 869
 				$title = $this->titles[$link_id];
870 870
 				$title = $this->encodeAttribute($title);
871
-				$result .=  " title=\"$title\"";
871
+				$result .= " title=\"$title\"";
872 872
 			}
873 873
 			$result .= $this->empty_element_suffix;
874 874
 			$result = $this->hashPart($result);
@@ -886,17 +886,17 @@  discard block
 block discarded – undo
886 886
 	 * @return string
887 887
 	 */
888 888
 	protected function _doImages_inline_callback($matches) {
889
-		$whole_match	= $matches[1];
890
-		$alt_text		= $matches[2];
891
-		$url			= $matches[3] == '' ? $matches[4] : $matches[3];
892
-		$title			=& $matches[7];
889
+		$whole_match = $matches[1];
890
+		$alt_text = $matches[2];
891
+		$url = $matches[3] == '' ? $matches[4] : $matches[3];
892
+		$title = & $matches[7];
893 893
 
894 894
 		$alt_text = $this->encodeAttribute($alt_text);
895 895
 		$url = $this->encodeURLAttribute($url);
896 896
 		$result = "<img src=\"$url\" alt=\"$alt_text\"";
897 897
 		if (isset($title)) {
898 898
 			$title = $this->encodeAttribute($title);
899
-			$result .=  " title=\"$title\""; // $title already quoted
899
+			$result .= " title=\"$title\""; // $title already quoted
900 900
 		}
901 901
 		$result .= $this->empty_element_suffix;
902 902
 
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 		// ID attribute generation
958 958
 		$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
959 959
 
960
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[1])."</h$level>";
960
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[1]) . "</h$level>";
961 961
 		return "\n" . $this->hashBlock($block) . "\n\n";
962 962
 	}
963 963
 
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 		$idAtt = $this->_generateIdFromHeaderValue($matches[2]);
972 972
 
973 973
 		$level = strlen($matches[1]);
974
-		$block = "<h$level$idAtt>".$this->runSpanGamut($matches[2])."</h$level>";
974
+		$block = "<h$level$idAtt>" . $this->runSpanGamut($matches[2]) . "</h$level>";
975 975
 		return "\n" . $this->hashBlock($block) . "\n\n";
976 976
 	}
977 977
 
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 			$whole_list_re = '
1020 1020
 				(								# $1 = whole list
1021 1021
 				  (								# $2
1022
-					([ ]{0,'.$less_than_tab.'})	# $3 = number of spaces
1023
-					('.$marker_re.')			# $4 = first list item marker
1022
+					([ ]{0,'.$less_than_tab . '})	# $3 = number of spaces
1023
+					('.$marker_re . ')			# $4 = first list item marker
1024 1024
 					[ ]+
1025 1025
 				  )
1026 1026
 				  (?s:.+?)
@@ -1031,13 +1031,13 @@  discard block
 block discarded – undo
1031 1031
 					  (?=\S)
1032 1032
 					  (?!						# Negative lookahead for another list item marker
1033 1033
 						[ ]*
1034
-						'.$marker_re.'[ ]+
1034
+						'.$marker_re . '[ ]+
1035 1035
 					  )
1036 1036
 					|
1037 1037
 					  (?=						# Lookahead for another kind of list
1038 1038
 					    \n
1039 1039
 						\3						# Must have the same indentation
1040
-						'.$other_marker_re.'[ ]+
1040
+						'.$other_marker_re . '[ ]+
1041 1041
 					  )
1042 1042
 				  )
1043 1043
 				)
@@ -1049,13 +1049,13 @@  discard block
 block discarded – undo
1049 1049
 			if ($this->list_level) {
1050 1050
 				$text = preg_replace_callback('{
1051 1051
 						^
1052
-						'.$whole_list_re.'
1052
+						'.$whole_list_re . '
1053 1053
 					}mx',
1054 1054
 					array($this, '_doLists_callback'), $text);
1055 1055
 			} else {
1056 1056
 				$text = preg_replace_callback('{
1057 1057
 						(?:(?<=\n)\n|\A\n?) # Must eat the newline
1058
-						'.$whole_list_re.'
1058
+						'.$whole_list_re . '
1059 1059
 					}mx',
1060 1060
 					array($this, '_doLists_callback'), $text);
1061 1061
 			}
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 		$list = $matches[1];
1080 1080
 		$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
1081 1081
 
1082
-		$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
1082
+		$marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re);
1083 1083
 
1084 1084
 		$list .= "\n";
1085 1085
 		$result = $this->processListItems($list, $marker_any_re);
@@ -1090,18 +1090,18 @@  discard block
 block discarded – undo
1090 1090
 			if ($list_type == 'ol') {
1091 1091
 				$ol_start_array = array();
1092 1092
 				$ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array);
1093
-				if ($ol_start_check){
1093
+				if ($ol_start_check) {
1094 1094
 					$ol_start = $ol_start_array[0];
1095 1095
 				}
1096 1096
 			}
1097 1097
 		}
1098 1098
 
1099
-		if ($ol_start > 1 && $list_type == 'ol'){
1099
+		if ($ol_start > 1 && $list_type == 'ol') {
1100 1100
 			$result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>");
1101 1101
 		} else {
1102 1102
 			$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
1103 1103
 		}
1104
-		return "\n". $result ."\n\n";
1104
+		return "\n" . $result . "\n\n";
1105 1105
 	}
1106 1106
 
1107 1107
 	/**
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
 		$list_str = preg_replace_callback('{
1149 1149
 			(\n)?							# leading line = $1
1150 1150
 			(^[ ]*)							# leading whitespace = $2
1151
-			('.$marker_any_re.'				# list marker and space = $3
1151
+			('.$marker_any_re . '				# list marker and space = $3
1152 1152
 				(?:[ ]+|(?=\n))	# space only required if item is not empty
1153 1153
 			)
1154 1154
 			((?s:.*?))						# list item text   = $4
1155 1155
 			(?:(\n+(?=\n))|\n)				# tailing blank line = $5
1156
-			(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
1156
+			(?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n))))
1157 1157
 			}xm',
1158 1158
 			array($this, '_processListItems_callback'), $list_str);
1159 1159
 
@@ -1168,17 +1168,17 @@  discard block
 block discarded – undo
1168 1168
 	 */
1169 1169
 	protected function _processListItems_callback($matches) {
1170 1170
 		$item = $matches[4];
1171
-		$leading_line =& $matches[1];
1172
-		$leading_space =& $matches[2];
1171
+		$leading_line = & $matches[1];
1172
+		$leading_space = & $matches[2];
1173 1173
 		$marker_space = $matches[3];
1174
-		$tailing_blank_line =& $matches[5];
1174
+		$tailing_blank_line = & $matches[5];
1175 1175
 
1176 1176
 		if ($leading_line || $tailing_blank_line ||
1177 1177
 			preg_match('/\n{2,}/', $item))
1178 1178
 		{
1179 1179
 			// Replace marker with the appropriate whitespace indentation
1180 1180
 			$item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
1181
-			$item = $this->runBlockGamut($this->outdent($item)."\n");
1181
+			$item = $this->runBlockGamut($this->outdent($item) . "\n");
1182 1182
 		} else {
1183 1183
 			// Recursion for sub-lists:
1184 1184
 			$item = $this->doLists($this->outdent($item));
@@ -1198,11 +1198,11 @@  discard block
 block discarded – undo
1198 1198
 				(?:\n\n|\A\n?)
1199 1199
 				(	            # $1 = the code block -- one or more lines, starting with a space/tab
1200 1200
 				  (?>
1201
-					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces
1201
+					[ ]{'.$this->tab_width . '}  # Lines must start with a tab or a tab-width of spaces
1202 1202
 					.*\n+
1203 1203
 				  )+
1204 1204
 				)
1205
-				((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1205
+				((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
1206 1206
 			}xm',
1207 1207
 			array($this, '_doCodeBlocks_callback'), $text);
1208 1208
 
@@ -1330,8 +1330,8 @@  discard block
 block discarded – undo
1330 1330
 			// Each token is then passed to handleSpanToken.
1331 1331
 			$parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
1332 1332
 			$text_stack[0] .= $parts[0];
1333
-			$token =& $parts[1];
1334
-			$text =& $parts[2];
1333
+			$token = & $parts[1];
1334
+			$text = & $parts[2];
1335 1335
 
1336 1336
 			if (empty($token)) {
1337 1337
 				// Reached end of text span: empty stack without emitting.
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 				} else {
1359 1359
 					// Other closing marker: close one em or strong and
1360 1360
 					// change current token state to match the other
1361
-					$token_stack[0] = str_repeat($token{0}, 3-$token_len);
1361
+					$token_stack[0] = str_repeat($token{0}, 3 - $token_len);
1362 1362
 					$tag = $token_len == 2 ? "strong" : "em";
1363 1363
 					$span = $text_stack[0];
1364 1364
 					$span = $this->runSpanGamut($span);
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 		}
1705 1705
 
1706 1706
 		$chars = preg_split('/(?<!^)(?!$)/', $text);
1707
-		$seed = (int)abs(crc32($text) / strlen($text)); // Deterministic seed.
1707
+		$seed = (int) abs(crc32($text) / strlen($text)); // Deterministic seed.
1708 1708
 
1709 1709
 		foreach ($chars as $key => $char) {
1710 1710
 			$ord = ord($char);
@@ -1717,9 +1717,9 @@  discard block
 block discarded – undo
1717 1717
 				if ($r > 90 && strpos('@"&>', $char) === false) {
1718 1718
 					/* do nothing */
1719 1719
 				} else if ($r < 45) {
1720
-					$chars[$key] = '&#x'.dechex($ord).';';
1720
+					$chars[$key] = '&#x' . dechex($ord) . ';';
1721 1721
 				} else {
1722
-					$chars[$key] = '&#'.$ord.';';
1722
+					$chars[$key] = '&#' . $ord . ';';
1723 1723
 				}
1724 1724
 			}
1725 1725
 		}
@@ -1741,11 +1741,11 @@  discard block
 block discarded – undo
1741 1741
 
1742 1742
 		$span_re = '{
1743 1743
 				(
1744
-					\\\\'.$this->escape_chars_re.'
1744
+					\\\\'.$this->escape_chars_re . '
1745 1745
 				|
1746 1746
 					(?<![`\\\\])
1747 1747
 					`+						# code span marker
1748
-			'.( $this->no_markup ? '' : '
1748
+			'.($this->no_markup ? '' : '
1749 1749
 				|
1750 1750
 					<!--    .*?     -->		# comment
1751 1751
 				|
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
 					<[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag
1762 1762
 				|
1763 1763
 					</[-a-zA-Z0-9:_]+\s*> # closing tag
1764
-			').'
1764
+			') . '
1765 1765
 				)
1766 1766
 				}xs';
1767 1767
 
@@ -1798,10 +1798,10 @@  discard block
 block discarded – undo
1798 1798
 	protected function handleSpanToken($token, &$str) {
1799 1799
 		switch ($token{0}) {
1800 1800
 			case "\\":
1801
-				return $this->hashPart("&#". ord($token{1}). ";");
1801
+				return $this->hashPart("&#" . ord($token{1}) . ";");
1802 1802
 			case "`":
1803 1803
 				// Search for end marker in remaining text.
1804
-				if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
1804
+				if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm',
1805 1805
 					$str, $matches))
1806 1806
 				{
1807 1807
 					$str = $matches[2];
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -776,8 +776,9 @@
 block discarded – undo
776 776
 		// tag parser and hashed. Need to reverse the process before using
777 777
 		// the URL.
778 778
 		$unhashed = $this->unhash($url);
779
-		if ($unhashed != $url)
780
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
779
+		if ($unhashed != $url) {
780
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
781
+		}
781 782
 
782 783
 		$url = $this->encodeURLAttribute($url);
783 784
 
Please login to merge, or discard this patch.