@@ -187,8 +187,9 @@ discard block |
||
187 | 187 | $this->footnotes_assembled = null; |
188 | 188 | |
189 | 189 | foreach ($this->predef_abbr as $abbr_word => $abbr_desc) { |
190 | - if ($this->abbr_word_re) |
|
191 | - $this->abbr_word_re .= '|'; |
|
190 | + if ($this->abbr_word_re) { |
|
191 | + $this->abbr_word_re .= '|'; |
|
192 | + } |
|
192 | 193 | $this->abbr_word_re .= preg_quote($abbr_word); |
193 | 194 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
194 | 195 | } |
@@ -205,8 +206,9 @@ discard block |
||
205 | 206 | $this->abbr_desciptions = array(); |
206 | 207 | $this->abbr_word_re = ''; |
207 | 208 | |
208 | - if ( ! $this->omit_footnotes ) |
|
209 | - $this->footnotes_assembled = null; |
|
209 | + if ( ! $this->omit_footnotes ) { |
|
210 | + $this->footnotes_assembled = null; |
|
211 | + } |
|
210 | 212 | |
211 | 213 | parent::teardown(); |
212 | 214 | } |
@@ -259,7 +261,9 @@ discard block |
||
259 | 261 | if ($element[0] === '.') { |
260 | 262 | $classes[] = substr($element, 1); |
261 | 263 | } else if ($element[0] === '#') { |
262 | - if ($id === false) $id = substr($element, 1); |
|
264 | + if ($id === false) { |
|
265 | + $id = substr($element, 1); |
|
266 | + } |
|
263 | 267 | } else if (strpos($element, '=') > 0) { |
264 | 268 | $parts = explode('=', $element, 2); |
265 | 269 | $attributes[] = $parts[0] . '="' . $parts[1] . '"'; |
@@ -435,7 +439,9 @@ discard block |
||
435 | 439 | $enclosing_tag_re = '', $span = false) |
436 | 440 | { |
437 | 441 | |
438 | - if ($text === '') return array('', ''); |
|
442 | + if ($text === '') { |
|
443 | + return array('', ''); |
|
444 | + } |
|
439 | 445 | |
440 | 446 | // Regex to check for the presense of newlines around a block tag. |
441 | 447 | $newline_before_re = '/(?:^\n?|\n\n)*$/'; |
@@ -546,8 +552,7 @@ discard block |
||
546 | 552 | // End marker found: pass text unchanged until marker. |
547 | 553 | $parsed .= $tag . $matches[0]; |
548 | 554 | $text = substr($text, strlen($matches[0])); |
549 | - } |
|
550 | - else { |
|
555 | + } else { |
|
551 | 556 | // No end marker: just skip it. |
552 | 557 | $parsed .= $tag; |
553 | 558 | } |
@@ -569,8 +574,7 @@ discard block |
||
569 | 574 | // End marker found: pass text unchanged until marker. |
570 | 575 | $parsed .= $tag . $matches[0]; |
571 | 576 | $text = substr($text, strlen($matches[0])); |
572 | - } |
|
573 | - else { |
|
577 | + } else { |
|
574 | 578 | // Unmatched marker: just skip it. |
575 | 579 | $parsed .= $tag; |
576 | 580 | } |
@@ -623,8 +627,7 @@ discard block |
||
623 | 627 | } |
624 | 628 | |
625 | 629 | $parsed .= $tag; |
626 | - } |
|
627 | - else { |
|
630 | + } else { |
|
628 | 631 | $parsed .= $tag; |
629 | 632 | } |
630 | 633 | } while ($depth >= 0); |
@@ -647,7 +650,9 @@ discard block |
||
647 | 650 | * @return array |
648 | 651 | */ |
649 | 652 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
650 | - if ($text === '') return array('', ''); |
|
653 | + if ($text === '') { |
|
654 | + return array('', ''); |
|
655 | + } |
|
651 | 656 | |
652 | 657 | // Regex to match `markdown` attribute inside of a tag. |
653 | 658 | $markdown_attr_re = ' |
@@ -697,8 +702,9 @@ discard block |
||
697 | 702 | |
698 | 703 | // Get the name of the starting tag. |
699 | 704 | // (This pattern makes $base_tag_name_re safe without quoting.) |
700 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
701 | - $base_tag_name_re = $matches[1]; |
|
705 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
706 | + $base_tag_name_re = $matches[1]; |
|
707 | + } |
|
702 | 708 | |
703 | 709 | // Loop through every tag until we find the corresponding closing tag. |
704 | 710 | do { |
@@ -727,8 +733,7 @@ discard block |
||
727 | 733 | { |
728 | 734 | // Just add the tag to the block as if it was text. |
729 | 735 | $block_text .= $tag; |
730 | - } |
|
731 | - else { |
|
736 | + } else { |
|
732 | 737 | // Increase/decrease nested tag count. Only do so if |
733 | 738 | // the tag's name match base tag's. |
734 | 739 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
@@ -789,8 +794,9 @@ discard block |
||
789 | 794 | |
790 | 795 | // Start over with a new block. |
791 | 796 | $block_text = ""; |
797 | + } else { |
|
798 | + $block_text .= $tag; |
|
792 | 799 | } |
793 | - else $block_text .= $tag; |
|
794 | 800 | } |
795 | 801 | |
796 | 802 | } while ($depth > 0); |
@@ -911,14 +917,14 @@ discard block |
||
911 | 917 | $title = $this->encodeAttribute($title); |
912 | 918 | $result .= " title=\"$title\""; |
913 | 919 | } |
914 | - if (isset($this->ref_attr[$link_id])) |
|
915 | - $result .= $this->ref_attr[$link_id]; |
|
920 | + if (isset($this->ref_attr[$link_id])) { |
|
921 | + $result .= $this->ref_attr[$link_id]; |
|
922 | + } |
|
916 | 923 | |
917 | 924 | $link_text = $this->runSpanGamut($link_text); |
918 | 925 | $result .= ">$link_text</a>"; |
919 | 926 | $result = $this->hashPart($result); |
920 | - } |
|
921 | - else { |
|
927 | + } else { |
|
922 | 928 | $result = $whole_match; |
923 | 929 | } |
924 | 930 | return $result; |
@@ -939,8 +945,9 @@ discard block |
||
939 | 945 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
940 | 946 | // tag parser and hashed. Need to reverse the process before using the URL. |
941 | 947 | $unhashed = $this->unhash($url); |
942 | - if ($unhashed !== $url) |
|
943 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
948 | + if ($unhashed !== $url) { |
|
949 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
950 | + } |
|
944 | 951 | |
945 | 952 | $url = $this->encodeURLAttribute($url); |
946 | 953 | |
@@ -1031,9 +1038,15 @@ discard block |
||
1031 | 1038 | $url = $this->encodeURLAttribute($this->urls[$link_id]); |
1032 | 1039 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
1033 | 1040 | list($width, $height, $type, $attr) = getimagesize($url); |
1034 | - if(isset($width)) $result .= " width=\"$width\""; |
|
1035 | - if(isset($height)) $result .= " height=\"$height\""; |
|
1036 | - if(isset($width) && isset($height)) $result .= " loading=\"lazy\""; |
|
1041 | + if(isset($width)) { |
|
1042 | + $result .= " width=\"$width\""; |
|
1043 | + } |
|
1044 | + if(isset($height)) { |
|
1045 | + $result .= " height=\"$height\""; |
|
1046 | + } |
|
1047 | + if(isset($width) && isset($height)) { |
|
1048 | + $result .= " loading=\"lazy\""; |
|
1049 | + } |
|
1037 | 1050 | if (isset($this->titles[$link_id])) { |
1038 | 1051 | $title = $this->titles[$link_id]; |
1039 | 1052 | $title = $this->encodeAttribute($title); |
@@ -1044,8 +1057,7 @@ discard block |
||
1044 | 1057 | } |
1045 | 1058 | $result .= $this->empty_element_suffix; |
1046 | 1059 | $result = $this->hashPart($result); |
1047 | - } |
|
1048 | - else { |
|
1060 | + } else { |
|
1049 | 1061 | // If there's no such link ID, leave intact: |
1050 | 1062 | $result = $whole_match; |
1051 | 1063 | } |
@@ -1069,9 +1081,15 @@ discard block |
||
1069 | 1081 | $url = $this->encodeURLAttribute($url); |
1070 | 1082 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
1071 | 1083 | list($width, $height, $type, $attr) = getimagesize($url); |
1072 | - if(isset($width)) $result .= " width=\"$width\""; |
|
1073 | - if(isset($height)) $result .= " height=\"$height\""; |
|
1074 | - if(isset($width) && isset($height)) $result .= " loading=\"lazy\""; |
|
1084 | + if(isset($width)) { |
|
1085 | + $result .= " width=\"$width\""; |
|
1086 | + } |
|
1087 | + if(isset($height)) { |
|
1088 | + $result .= " height=\"$height\""; |
|
1089 | + } |
|
1090 | + if(isset($width) && isset($height)) { |
|
1091 | + $result .= " loading=\"lazy\""; |
|
1092 | + } |
|
1075 | 1093 | if (isset($title) && $title_quote) { |
1076 | 1094 | $title = $this->encodeAttribute($title); |
1077 | 1095 | $result .= " title=\"$title\""; // $title already quoted |
@@ -1265,14 +1283,15 @@ discard block |
||
1265 | 1283 | // Reading alignement from header underline. |
1266 | 1284 | $separators = preg_split('/ *[|] */', $underline); |
1267 | 1285 | foreach ($separators as $n => $s) { |
1268 | - if (preg_match('/^ *-+: *$/', $s)) |
|
1269 | - $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
1270 | - else if (preg_match('/^ *:-+: *$/', $s)) |
|
1271 | - $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
1272 | - else if (preg_match('/^ *:-+ *$/', $s)) |
|
1273 | - $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
1274 | - else |
|
1275 | - $attr[$n] = ''; |
|
1286 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
1287 | + $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
1288 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
1289 | + $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
1290 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
1291 | + $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
1292 | + } else { |
|
1293 | + $attr[$n] = ''; |
|
1294 | + } |
|
1276 | 1295 | } |
1277 | 1296 | |
1278 | 1297 | // Parsing span elements, including code spans, character escapes, |
@@ -1455,8 +1474,7 @@ discard block |
||
1455 | 1474 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
1456 | 1475 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
1457 | 1476 | $def = "\n". $def ."\n"; |
1458 | - } |
|
1459 | - else { |
|
1477 | + } else { |
|
1460 | 1478 | $def = rtrim($def); |
1461 | 1479 | $def = $this->runSpanGamut($this->outdent($def)); |
1462 | 1480 | } |
@@ -775,8 +775,9 @@ discard block |
||
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 | |
@@ -865,9 +866,15 @@ discard block |
||
865 | 866 | $url = $this->encodeURLAttribute($this->urls[$link_id]); |
866 | 867 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
867 | 868 | list($width, $height, $type, $attr) = getimagesize($url); |
868 | - if(isset($width)) $result .= " width=\"$width\""; |
|
869 | - if(isset($height)) $result .= " height=\"$height\""; |
|
870 | - if(isset($width) && isset($height)) $result .= " loading=\"lazy\""; |
|
869 | + if(isset($width)) { |
|
870 | + $result .= " width=\"$width\""; |
|
871 | + } |
|
872 | + if(isset($height)) { |
|
873 | + $result .= " height=\"$height\""; |
|
874 | + } |
|
875 | + if(isset($width) && isset($height)) { |
|
876 | + $result .= " loading=\"lazy\""; |
|
877 | + } |
|
871 | 878 | if (isset($this->titles[$link_id])) { |
872 | 879 | $title = $this->titles[$link_id]; |
873 | 880 | $title = $this->encodeAttribute($title); |
@@ -898,9 +905,15 @@ discard block |
||
898 | 905 | $url = $this->encodeURLAttribute($url); |
899 | 906 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
900 | 907 | list($width, $height, $type, $attr) = getimagesize($url); |
901 | - if(isset($width)) $result .= " width=\"$width\""; |
|
902 | - if(isset($height)) $result .= " height=\"$height\""; |
|
903 | - if(isset($width) && isset($height)) $result .= " loading=\"lazy\""; |
|
908 | + if(isset($width)) { |
|
909 | + $result .= " width=\"$width\""; |
|
910 | + } |
|
911 | + if(isset($height)) { |
|
912 | + $result .= " height=\"$height\""; |
|
913 | + } |
|
914 | + if(isset($width) && isset($height)) { |
|
915 | + $result .= " loading=\"lazy\""; |
|
916 | + } |
|
904 | 917 | if (isset($title)) { |
905 | 918 | $title = $this->encodeAttribute($title); |
906 | 919 | $result .= " title=\"$title\""; // $title already quoted |