@@ -775,8 +775,9 @@ |
||
| 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 | |
@@ -176,8 +176,9 @@ discard block |
||
| 176 | 176 | $this->footnotes_assembled = ""; |
| 177 | 177 | |
| 178 | 178 | foreach ($this->predef_abbr as $abbr_word => $abbr_desc) { |
| 179 | - if ($this->abbr_word_re) |
|
| 180 | - $this->abbr_word_re .= '|'; |
|
| 179 | + if ($this->abbr_word_re) { |
|
| 180 | + $this->abbr_word_re .= '|'; |
|
| 181 | + } |
|
| 181 | 182 | $this->abbr_word_re .= preg_quote($abbr_word); |
| 182 | 183 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
| 183 | 184 | } |
@@ -194,8 +195,9 @@ discard block |
||
| 194 | 195 | $this->abbr_desciptions = array(); |
| 195 | 196 | $this->abbr_word_re = ''; |
| 196 | 197 | |
| 197 | - if ( ! $this->omit_footnotes ) |
|
| 198 | - $this->footnotes_assembled = ""; |
|
| 198 | + if ( ! $this->omit_footnotes ) { |
|
| 199 | + $this->footnotes_assembled = ""; |
|
| 200 | + } |
|
| 199 | 201 | |
| 200 | 202 | parent::teardown(); |
| 201 | 203 | } |
@@ -248,7 +250,9 @@ discard block |
||
| 248 | 250 | if ($element{0} === '.') { |
| 249 | 251 | $classes[] = substr($element, 1); |
| 250 | 252 | } else if ($element{0} === '#') { |
| 251 | - if ($id === false) $id = substr($element, 1); |
|
| 253 | + if ($id === false) { |
|
| 254 | + $id = substr($element, 1); |
|
| 255 | + } |
|
| 252 | 256 | } else if (strpos($element, '=') > 0) { |
| 253 | 257 | $parts = explode('=', $element, 2); |
| 254 | 258 | $attributes[] = $parts[0] . '="' . $parts[1] . '"'; |
@@ -424,7 +428,9 @@ discard block |
||
| 424 | 428 | $enclosing_tag_re = '', $span = false) |
| 425 | 429 | { |
| 426 | 430 | |
| 427 | - if ($text === '') return array('', ''); |
|
| 431 | + if ($text === '') { |
|
| 432 | + return array('', ''); |
|
| 433 | + } |
|
| 428 | 434 | |
| 429 | 435 | // Regex to check for the presense of newlines around a block tag. |
| 430 | 436 | $newline_before_re = '/(?:^\n?|\n\n)*$/'; |
@@ -535,8 +541,7 @@ discard block |
||
| 535 | 541 | // End marker found: pass text unchanged until marker. |
| 536 | 542 | $parsed .= $tag . $matches[0]; |
| 537 | 543 | $text = substr($text, strlen($matches[0])); |
| 538 | - } |
|
| 539 | - else { |
|
| 544 | + } else { |
|
| 540 | 545 | // No end marker: just skip it. |
| 541 | 546 | $parsed .= $tag; |
| 542 | 547 | } |
@@ -558,8 +563,7 @@ discard block |
||
| 558 | 563 | // End marker found: pass text unchanged until marker. |
| 559 | 564 | $parsed .= $tag . $matches[0]; |
| 560 | 565 | $text = substr($text, strlen($matches[0])); |
| 561 | - } |
|
| 562 | - else { |
|
| 566 | + } else { |
|
| 563 | 567 | // Unmatched marker: just skip it. |
| 564 | 568 | $parsed .= $tag; |
| 565 | 569 | } |
@@ -612,8 +616,7 @@ discard block |
||
| 612 | 616 | } |
| 613 | 617 | |
| 614 | 618 | $parsed .= $tag; |
| 615 | - } |
|
| 616 | - else { |
|
| 619 | + } else { |
|
| 617 | 620 | $parsed .= $tag; |
| 618 | 621 | } |
| 619 | 622 | } while ($depth >= 0); |
@@ -636,7 +639,9 @@ discard block |
||
| 636 | 639 | * @return array |
| 637 | 640 | */ |
| 638 | 641 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
| 639 | - if ($text === '') return array('', ''); |
|
| 642 | + if ($text === '') { |
|
| 643 | + return array('', ''); |
|
| 644 | + } |
|
| 640 | 645 | |
| 641 | 646 | // Regex to match `markdown` attribute inside of a tag. |
| 642 | 647 | $markdown_attr_re = ' |
@@ -686,8 +691,9 @@ discard block |
||
| 686 | 691 | |
| 687 | 692 | // Get the name of the starting tag. |
| 688 | 693 | // (This pattern makes $base_tag_name_re safe without quoting.) |
| 689 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
| 690 | - $base_tag_name_re = $matches[1]; |
|
| 694 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
| 695 | + $base_tag_name_re = $matches[1]; |
|
| 696 | + } |
|
| 691 | 697 | |
| 692 | 698 | // Loop through every tag until we find the corresponding closing tag. |
| 693 | 699 | do { |
@@ -716,8 +722,7 @@ discard block |
||
| 716 | 722 | { |
| 717 | 723 | // Just add the tag to the block as if it was text. |
| 718 | 724 | $block_text .= $tag; |
| 719 | - } |
|
| 720 | - else { |
|
| 725 | + } else { |
|
| 721 | 726 | // Increase/decrease nested tag count. Only do so if |
| 722 | 727 | // the tag's name match base tag's. |
| 723 | 728 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
@@ -778,8 +783,9 @@ discard block |
||
| 778 | 783 | |
| 779 | 784 | // Start over with a new block. |
| 780 | 785 | $block_text = ""; |
| 786 | + } else { |
|
| 787 | + $block_text .= $tag; |
|
| 781 | 788 | } |
| 782 | - else $block_text .= $tag; |
|
| 783 | 789 | } |
| 784 | 790 | |
| 785 | 791 | } while ($depth > 0); |
@@ -900,14 +906,14 @@ discard block |
||
| 900 | 906 | $title = $this->encodeAttribute($title); |
| 901 | 907 | $result .= " title=\"$title\""; |
| 902 | 908 | } |
| 903 | - if (isset($this->ref_attr[$link_id])) |
|
| 904 | - $result .= $this->ref_attr[$link_id]; |
|
| 909 | + if (isset($this->ref_attr[$link_id])) { |
|
| 910 | + $result .= $this->ref_attr[$link_id]; |
|
| 911 | + } |
|
| 905 | 912 | |
| 906 | 913 | $link_text = $this->runSpanGamut($link_text); |
| 907 | 914 | $result .= ">$link_text</a>"; |
| 908 | 915 | $result = $this->hashPart($result); |
| 909 | - } |
|
| 910 | - else { |
|
| 916 | + } else { |
|
| 911 | 917 | $result = $whole_match; |
| 912 | 918 | } |
| 913 | 919 | return $result; |
@@ -927,8 +933,9 @@ discard block |
||
| 927 | 933 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
| 928 | 934 | // tag parser and hashed. Need to reverse the process before using the URL. |
| 929 | 935 | $unhashed = $this->unhash($url); |
| 930 | - if ($unhashed !== $url) |
|
| 931 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 936 | + if ($unhashed !== $url) { |
|
| 937 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 938 | + } |
|
| 932 | 939 | |
| 933 | 940 | $url = $this->encodeURLAttribute($url); |
| 934 | 941 | |
@@ -1028,8 +1035,7 @@ discard block |
||
| 1028 | 1035 | } |
| 1029 | 1036 | $result .= $this->empty_element_suffix; |
| 1030 | 1037 | $result = $this->hashPart($result); |
| 1031 | - } |
|
| 1032 | - else { |
|
| 1038 | + } else { |
|
| 1033 | 1039 | // If there's no such link ID, leave intact: |
| 1034 | 1040 | $result = $whole_match; |
| 1035 | 1041 | } |
@@ -1245,14 +1251,15 @@ discard block |
||
| 1245 | 1251 | // Reading alignement from header underline. |
| 1246 | 1252 | $separators = preg_split('/ *[|] */', $underline); |
| 1247 | 1253 | foreach ($separators as $n => $s) { |
| 1248 | - if (preg_match('/^ *-+: *$/', $s)) |
|
| 1249 | - $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 1250 | - else if (preg_match('/^ *:-+: *$/', $s)) |
|
| 1251 | - $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 1252 | - else if (preg_match('/^ *:-+ *$/', $s)) |
|
| 1253 | - $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 1254 | - else |
|
| 1255 | - $attr[$n] = ''; |
|
| 1254 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
| 1255 | + $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 1256 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
| 1257 | + $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 1258 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
| 1259 | + $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 1260 | + } else { |
|
| 1261 | + $attr[$n] = ''; |
|
| 1262 | + } |
|
| 1256 | 1263 | } |
| 1257 | 1264 | |
| 1258 | 1265 | // Parsing span elements, including code spans, character escapes, |
@@ -1435,8 +1442,7 @@ discard block |
||
| 1435 | 1442 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 1436 | 1443 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 1437 | 1444 | $def = "\n". $def ."\n"; |
| 1438 | - } |
|
| 1439 | - else { |
|
| 1445 | + } else { |
|
| 1440 | 1446 | $def = rtrim($def); |
| 1441 | 1447 | $def = $this->runSpanGamut($this->outdent($def)); |
| 1442 | 1448 | } |