Completed
Pull Request — lib (#313)
by
unknown
02:44
created
Michelf/MarkdownExtra.php 1 patch
Braces   +42 added lines, -36 removed lines patch added patch discarded remove patch
@@ -172,8 +172,9 @@  discard block
 block discarded – undo
172 172
 		$this->footnotes_assembled = null;
173 173
 
174 174
 		foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
175
-			if ($this->abbr_word_re)
176
-				$this->abbr_word_re .= '|';
175
+			if ($this->abbr_word_re) {
176
+							$this->abbr_word_re .= '|';
177
+			}
177 178
 			$this->abbr_word_re .= preg_quote($abbr_word);
178 179
 			$this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
179 180
 		}
@@ -190,8 +191,9 @@  discard block
 block discarded – undo
190 191
 		$this->abbr_desciptions = array();
191 192
 		$this->abbr_word_re = '';
192 193
 
193
-		if ( ! $this->omit_footnotes )
194
-			$this->footnotes_assembled = null;
194
+		if ( ! $this->omit_footnotes ) {
195
+					$this->footnotes_assembled = null;
196
+		}
195 197
 
196 198
 		parent::teardown();
197 199
 	}
@@ -244,7 +246,9 @@  discard block
 block discarded – undo
244 246
 			if ($element{0} === '.') {
245 247
 				$classes[] = substr($element, 1);
246 248
 			} else if ($element{0} === '#') {
247
-				if ($id === false) $id = substr($element, 1);
249
+				if ($id === false) {
250
+					$id = substr($element, 1);
251
+				}
248 252
 			} else if (strpos($element, '=') > 0) {
249 253
 				$parts = explode('=', $element, 2);
250 254
 				$attributes[] = $parts[0] . '="' . $parts[1] . '"';
@@ -420,7 +424,9 @@  discard block
 block discarded – undo
420 424
 										$enclosing_tag_re = '', $span = false)
421 425
 	{
422 426
 
423
-		if ($text === '') return array('', '');
427
+		if ($text === '') {
428
+			return array('', '');
429
+		}
424 430
 
425 431
 		// Regex to check for the presense of newlines around a block tag.
426 432
 		$newline_before_re = '/(?:^\n?|\n\n)*$/';
@@ -531,8 +537,7 @@  discard block
 block discarded – undo
531 537
 					// End marker found: pass text unchanged until marker.
532 538
 					$parsed .= $tag . $matches[0];
533 539
 					$text = substr($text, strlen($matches[0]));
534
-				}
535
-				else {
540
+				} else {
536 541
 					// No end marker: just skip it.
537 542
 					$parsed .= $tag;
538 543
 				}
@@ -554,8 +559,7 @@  discard block
 block discarded – undo
554 559
 					// End marker found: pass text unchanged until marker.
555 560
 					$parsed .= $tag . $matches[0];
556 561
 					$text = substr($text, strlen($matches[0]));
557
-				}
558
-				else {
562
+				} else {
559 563
 					// Unmatched marker: just skip it.
560 564
 					$parsed .= $tag;
561 565
 				}
@@ -608,8 +612,7 @@  discard block
 block discarded – undo
608 612
 				}
609 613
 
610 614
 				$parsed .= $tag;
611
-			}
612
-			else {
615
+			} else {
613 616
 				$parsed .= $tag;
614 617
 			}
615 618
 		} while ($depth >= 0);
@@ -632,7 +635,9 @@  discard block
 block discarded – undo
632 635
 	 * @return array
633 636
 	 */
634 637
 	protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
635
-		if ($text === '') return array('', '');
638
+		if ($text === '') {
639
+			return array('', '');
640
+		}
636 641
 
637 642
 		// Regex to match `markdown` attribute inside of a tag.
638 643
 		$markdown_attr_re = '
@@ -682,8 +687,9 @@  discard block
 block discarded – undo
682 687
 
683 688
 		// Get the name of the starting tag.
684 689
 		// (This pattern makes $base_tag_name_re safe without quoting.)
685
-		if (preg_match('/^<([\w:$]*)\b/', $text, $matches))
686
-			$base_tag_name_re = $matches[1];
690
+		if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) {
691
+					$base_tag_name_re = $matches[1];
692
+		}
687 693
 
688 694
 		// Loop through every tag until we find the corresponding closing tag.
689 695
 		do {
@@ -712,8 +718,7 @@  discard block
 block discarded – undo
712 718
 			{
713 719
 				// Just add the tag to the block as if it was text.
714 720
 				$block_text .= $tag;
715
-			}
716
-			else {
721
+			} else {
717 722
 				// Increase/decrease nested tag count. Only do so if
718 723
 				// the tag's name match base tag's.
719 724
 				if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) {
@@ -774,8 +779,9 @@  discard block
 block discarded – undo
774 779
 
775 780
 					// Start over with a new block.
776 781
 					$block_text = "";
782
+				} else {
783
+					$block_text .= $tag;
777 784
 				}
778
-				else $block_text .= $tag;
779 785
 			}
780 786
 
781 787
 		} while ($depth > 0);
@@ -896,14 +902,14 @@  discard block
 block discarded – undo
896 902
 				$title = $this->encodeAttribute($title);
897 903
 				$result .=  " title=\"$title\"";
898 904
 			}
899
-			if (isset($this->ref_attr[$link_id]))
900
-				$result .= $this->ref_attr[$link_id];
905
+			if (isset($this->ref_attr[$link_id])) {
906
+							$result .= $this->ref_attr[$link_id];
907
+			}
901 908
 
902 909
 			$link_text = $this->runSpanGamut($link_text);
903 910
 			$result .= ">$link_text</a>";
904 911
 			$result = $this->hashPart($result);
905
-		}
906
-		else {
912
+		} else {
907 913
 			$result = $whole_match;
908 914
 		}
909 915
 		return $result;
@@ -923,8 +929,9 @@  discard block
 block discarded – undo
923 929
 		// if the URL was of the form <s p a c e s> it got caught by the HTML
924 930
 		// tag parser and hashed. Need to reverse the process before using the URL.
925 931
 		$unhashed = $this->unhash($url);
926
-		if ($unhashed !== $url)
927
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
932
+		if ($unhashed !== $url) {
933
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
934
+		}
928 935
 
929 936
 		$url = $this->encodeURLAttribute($url);
930 937
 
@@ -1024,8 +1031,7 @@  discard block
 block discarded – undo
1024 1031
 			}
1025 1032
 			$result .= $this->empty_element_suffix;
1026 1033
 			$result = $this->hashPart($result);
1027
-		}
1028
-		else {
1034
+		} else {
1029 1035
 			// If there's no such link ID, leave intact:
1030 1036
 			$result = $whole_match;
1031 1037
 		}
@@ -1241,14 +1247,15 @@  discard block
 block discarded – undo
1241 1247
 		// Reading alignement from header underline.
1242 1248
 		$separators	= preg_split('/ *[|] */', $underline);
1243 1249
 		foreach ($separators as $n => $s) {
1244
-			if (preg_match('/^ *-+: *$/', $s))
1245
-				$attr[$n] = $this->_doTable_makeAlignAttr('right');
1246
-			else if (preg_match('/^ *:-+: *$/', $s))
1247
-				$attr[$n] = $this->_doTable_makeAlignAttr('center');
1248
-			else if (preg_match('/^ *:-+ *$/', $s))
1249
-				$attr[$n] = $this->_doTable_makeAlignAttr('left');
1250
-			else
1251
-				$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
+			}
1252 1259
 		}
1253 1260
 
1254 1261
 		// Parsing span elements, including code spans, character escapes,
@@ -1431,8 +1438,7 @@  discard block
 block discarded – undo
1431 1438
 			$def = str_repeat(' ', strlen($marker_space)) . $def;
1432 1439
 			$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
1433 1440
 			$def = "\n". $def ."\n";
1434
-		}
1435
-		else {
1441
+		} else {
1436 1442
 			$def = rtrim($def);
1437 1443
 			$def = $this->runSpanGamut($this->outdent($def));
1438 1444
 		}
Please login to merge, or discard this patch.
Michelf/Markdown.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -775,8 +775,9 @@
 block discarded – undo
775 775
 		// tag parser and hashed. Need to reverse the process before using
776 776
 		// the URL.
777 777
 		$unhashed = $this->unhash($url);
778
-		if ($unhashed !== $url)
779
-			$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
778
+		if ($unhashed !== $url) {
779
+					$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
780
+		}
780 781
 
781 782
 		$url = $this->encodeURLAttribute($url);
782 783
 
Please login to merge, or discard this patch.