@@ -170,8 +170,9 @@ discard block |
||
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 |
||
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 | } |
@@ -239,7 +241,9 @@ discard block |
||
239 | 241 | if ($element[0] === '.') { |
240 | 242 | $classes[] = substr($element, 1); |
241 | 243 | } else if ($element[0] === '#') { |
242 | - if ($id === false) $id = substr($element, 1); |
|
244 | + if ($id === false) { |
|
245 | + $id = substr($element, 1); |
|
246 | + } |
|
243 | 247 | } else if (strpos($element, '=') > 0) { |
244 | 248 | $parts = explode('=', $element, 2); |
245 | 249 | $attributes[] = $parts[0] . '="' . $parts[1] . '"'; |
@@ -409,7 +413,9 @@ discard block |
||
409 | 413 | $enclosing_tag_re = '', $span = false) |
410 | 414 | { |
411 | 415 | |
412 | - if ($text === '') return array('', ''); |
|
416 | + if ($text === '') { |
|
417 | + return array('', ''); |
|
418 | + } |
|
413 | 419 | |
414 | 420 | // Regex to check for the presense of newlines around a block tag. |
415 | 421 | $newline_before_re = '/(?:^\n?|\n\n)*$/'; |
@@ -520,8 +526,7 @@ discard block |
||
520 | 526 | // End marker found: pass text unchanged until marker. |
521 | 527 | $parsed .= $tag . $matches[0]; |
522 | 528 | $text = substr($text, strlen($matches[0])); |
523 | - } |
|
524 | - else { |
|
529 | + } else { |
|
525 | 530 | // No end marker: just skip it. |
526 | 531 | $parsed .= $tag; |
527 | 532 | } |
@@ -543,8 +548,7 @@ discard block |
||
543 | 548 | // End marker found: pass text unchanged until marker. |
544 | 549 | $parsed .= $tag . $matches[0]; |
545 | 550 | $text = substr($text, strlen($matches[0])); |
546 | - } |
|
547 | - else { |
|
551 | + } else { |
|
548 | 552 | // Unmatched marker: just skip it. |
549 | 553 | $parsed .= $tag; |
550 | 554 | } |
@@ -597,8 +601,7 @@ discard block |
||
597 | 601 | } |
598 | 602 | |
599 | 603 | $parsed .= $tag; |
600 | - } |
|
601 | - else { |
|
604 | + } else { |
|
602 | 605 | $parsed .= $tag; |
603 | 606 | } |
604 | 607 | } while ($depth >= 0); // @phpstan-ignore-line |
@@ -621,7 +624,9 @@ discard block |
||
621 | 624 | * @return array |
622 | 625 | */ |
623 | 626 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
624 | - if ($text === '') return array('', ''); |
|
627 | + if ($text === '') { |
|
628 | + return array('', ''); |
|
629 | + } |
|
625 | 630 | |
626 | 631 | // Regex to match `markdown` attribute inside of a tag. |
627 | 632 | $markdown_attr_re = ' |
@@ -671,8 +676,9 @@ discard block |
||
671 | 676 | |
672 | 677 | // Get the name of the starting tag. |
673 | 678 | // (This pattern makes $base_tag_name_re safe without quoting.) |
674 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
675 | - $base_tag_name_re = $matches[1]; |
|
679 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
680 | + $base_tag_name_re = $matches[1]; |
|
681 | + } |
|
676 | 682 | |
677 | 683 | // Loop through every tag until we find the corresponding closing tag. |
678 | 684 | do { |
@@ -701,8 +707,7 @@ discard block |
||
701 | 707 | { |
702 | 708 | // Just add the tag to the block as if it was text. |
703 | 709 | $block_text .= $tag; |
704 | - } |
|
705 | - else { |
|
710 | + } else { |
|
706 | 711 | // Increase/decrease nested tag count. Only do so if |
707 | 712 | // the tag's name match base tag's. |
708 | 713 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
@@ -763,8 +768,9 @@ discard block |
||
763 | 768 | |
764 | 769 | // Start over with a new block. |
765 | 770 | $block_text = ""; |
771 | + } else { |
|
772 | + $block_text .= $tag; |
|
766 | 773 | } |
767 | - else $block_text .= $tag; |
|
768 | 774 | } |
769 | 775 | |
770 | 776 | } while ($depth > 0); |
@@ -885,14 +891,14 @@ discard block |
||
885 | 891 | $title = $this->encodeAttribute($title); |
886 | 892 | $result .= " title=\"$title\""; |
887 | 893 | } |
888 | - if (isset($this->ref_attr[$link_id])) |
|
889 | - $result .= $this->ref_attr[$link_id]; |
|
894 | + if (isset($this->ref_attr[$link_id])) { |
|
895 | + $result .= $this->ref_attr[$link_id]; |
|
896 | + } |
|
890 | 897 | |
891 | 898 | $link_text = $this->runSpanGamut($link_text); |
892 | 899 | $result .= ">$link_text</a>"; |
893 | 900 | $result = $this->hashPart($result); |
894 | - } |
|
895 | - else { |
|
901 | + } else { |
|
896 | 902 | $result = $whole_match; |
897 | 903 | } |
898 | 904 | return $result; |
@@ -913,8 +919,9 @@ discard block |
||
913 | 919 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
914 | 920 | // tag parser and hashed. Need to reverse the process before using the URL. |
915 | 921 | $unhashed = $this->unhash($url); |
916 | - if ($unhashed !== $url) |
|
917 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
922 | + if ($unhashed !== $url) { |
|
923 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
924 | + } |
|
918 | 925 | |
919 | 926 | $url = $this->encodeURLAttribute($url); |
920 | 927 | |
@@ -1014,8 +1021,7 @@ discard block |
||
1014 | 1021 | } |
1015 | 1022 | $result .= $this->empty_element_suffix; |
1016 | 1023 | $result = $this->hashPart($result); |
1017 | - } |
|
1018 | - else { |
|
1024 | + } else { |
|
1019 | 1025 | // If there's no such link ID, leave intact: |
1020 | 1026 | $result = $whole_match; |
1021 | 1027 | } |
@@ -1232,14 +1238,15 @@ discard block |
||
1232 | 1238 | // Reading alignement from header underline. |
1233 | 1239 | $separators = preg_split('/ *[|] */', $underline); |
1234 | 1240 | foreach ($separators as $n => $s) { |
1235 | - if (preg_match('/^ *-+: *$/', $s)) |
|
1236 | - $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
1237 | - else if (preg_match('/^ *:-+: *$/', $s)) |
|
1238 | - $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
1239 | - else if (preg_match('/^ *:-+ *$/', $s)) |
|
1240 | - $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
1241 | - else |
|
1242 | - $attr[$n] = ''; |
|
1241 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
1242 | + $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
1243 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
1244 | + $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
1245 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
1246 | + $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
1247 | + } else { |
|
1248 | + $attr[$n] = ''; |
|
1249 | + } |
|
1243 | 1250 | } |
1244 | 1251 | |
1245 | 1252 | // Parsing span elements, including code spans, character escapes, |
@@ -1422,8 +1429,7 @@ discard block |
||
1422 | 1429 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
1423 | 1430 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
1424 | 1431 | $def = "\n". $def ."\n"; |
1425 | - } |
|
1426 | - else { |
|
1432 | + } else { |
|
1427 | 1433 | $def = rtrim($def); |
1428 | 1434 | $def = $this->runSpanGamut($this->outdent($def)); |
1429 | 1435 | } |