@@ -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 |
@@ -35,7 +35,7 @@ discard block |
||
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) { |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $this->prepareItalicsAndBold(); |
148 | 148 | |
149 | 149 | $this->nested_brackets_re = |
150 | - str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth). |
|
150 | + str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) . |
|
151 | 151 | str_repeat('\])*', $this->nested_brackets_depth); |
152 | 152 | |
153 | 153 | $this->nested_url_parenthesis_re = |
154 | - str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth). |
|
154 | + str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) . |
|
155 | 155 | str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth); |
156 | 156 | |
157 | - $this->escape_chars_re = '['.preg_quote($this->escape_chars).']'; |
|
157 | + $this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']'; |
|
158 | 158 | |
159 | 159 | // Sort document, block, and span gamut in ascendent priority order. |
160 | 160 | asort($this->document_gamut); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * Internal hashes used during transformation. |
168 | 168 | */ |
169 | 169 | protected array $urls = array(); |
170 | - protected $titles = array(); |
|
170 | + protected $titles = array(); |
|
171 | 171 | protected array $html_hashes = array(); |
172 | 172 | |
173 | 173 | /** |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | // Link defs are in the form: ^[id]: url "optional title" |
271 | 271 | $text = preg_replace_callback('{ |
272 | - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
272 | + ^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
273 | 273 | [ ]* |
274 | 274 | \n? # maybe *one* newline |
275 | 275 | [ ]* |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $link_id = strtolower($matches[1]); |
306 | 306 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
307 | 307 | $this->urls[$link_id] = $url; |
308 | - $this->titles[$link_id] =& $matches[4]; |
|
308 | + $this->titles[$link_id] = & $matches[4]; |
|
309 | 309 | return ''; // String that will replace the block |
310 | 310 | } |
311 | 311 | |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | * * List "b" is made of tags which are always block-level; |
338 | 338 | */ |
339 | 339 | $block_tags_a_re = 'ins|del'; |
340 | - $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'. |
|
341 | - 'script|noscript|style|form|fieldset|iframe|math|svg|'. |
|
342 | - 'article|section|nav|aside|hgroup|header|footer|'. |
|
340 | + $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' . |
|
341 | + 'script|noscript|style|form|fieldset|iframe|math|svg|' . |
|
342 | + 'article|section|nav|aside|hgroup|header|footer|' . |
|
343 | 343 | 'figure|details|summary'; |
344 | 344 | |
345 | 345 | // Regular expression for the content of a block tag. |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | [^<]+ # content without tag |
365 | 365 | | |
366 | 366 | <\2 # nested opening tag |
367 | - '.$attr.' # attributes |
|
367 | + '.$attr . ' # attributes |
|
368 | 368 | (?> |
369 | 369 | /> |
370 | 370 | | |
371 | - >', $nested_tags_level). // end of opening tag |
|
372 | - '.*?'. // last level nested tag content |
|
371 | + >', $nested_tags_level) . // end of opening tag |
|
372 | + '.*?' . // last level nested tag content |
|
373 | 373 | str_repeat(' |
374 | 374 | </\2\s*> # closing nested tag |
375 | 375 | ) |
@@ -405,20 +405,20 @@ discard block |
||
405 | 405 | # Match from `\n<tag>` to `</tag>\n`, handling nested tags |
406 | 406 | # in between. |
407 | 407 | |
408 | - [ ]{0,'.$less_than_tab.'} |
|
409 | - <('.$block_tags_b_re.')# start tag = $2 |
|
410 | - '.$attr.'> # attributes followed by > and \n |
|
411 | - '.$content.' # content, support nesting |
|
408 | + [ ]{0,'.$less_than_tab . '} |
|
409 | + <('.$block_tags_b_re . ')# start tag = $2 |
|
410 | + '.$attr . '> # attributes followed by > and \n |
|
411 | + '.$content . ' # content, support nesting |
|
412 | 412 | </\2> # the matching end tag |
413 | 413 | [ ]* # trailing spaces/tabs |
414 | 414 | (?=\n+|\Z) # followed by a newline or end of document |
415 | 415 | |
416 | 416 | | # Special version for tags of group a. |
417 | 417 | |
418 | - [ ]{0,'.$less_than_tab.'} |
|
419 | - <('.$block_tags_a_re.')# start tag = $3 |
|
420 | - '.$attr.'>[ ]*\n # attributes followed by > |
|
421 | - '.$content2.' # content, support nesting |
|
418 | + [ ]{0,'.$less_than_tab . '} |
|
419 | + <('.$block_tags_a_re . ')# start tag = $3 |
|
420 | + '.$attr . '>[ ]*\n # attributes followed by > |
|
421 | + '.$content2 . ' # content, support nesting |
|
422 | 422 | </\3> # the matching end tag |
423 | 423 | [ ]* # trailing spaces/tabs |
424 | 424 | (?=\n+|\Z) # followed by a newline or end of document |
@@ -426,16 +426,16 @@ discard block |
||
426 | 426 | | # Special case just for <hr />. It was easier to make a special |
427 | 427 | # case than to make the other regex more complicated. |
428 | 428 | |
429 | - [ ]{0,'.$less_than_tab.'} |
|
429 | + [ ]{0,'.$less_than_tab . '} |
|
430 | 430 | <(hr) # start tag = $2 |
431 | - '.$attr.' # attributes |
|
431 | + '.$attr . ' # attributes |
|
432 | 432 | /?> # the matching end tag |
433 | 433 | [ ]* |
434 | 434 | (?=\n{2,}|\Z) # followed by a blank line or end of document |
435 | 435 | |
436 | 436 | | # Special case for standalone HTML comments: |
437 | 437 | |
438 | - [ ]{0,'.$less_than_tab.'} |
|
438 | + [ ]{0,'.$less_than_tab . '} |
|
439 | 439 | (?s: |
440 | 440 | <!-- .*? --> |
441 | 441 | ) |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | |
445 | 445 | | # PHP and ASP-style processor instructions (<? and <%) |
446 | 446 | |
447 | - [ ]{0,'.$less_than_tab.'} |
|
447 | + [ ]{0,'.$less_than_tab . '} |
|
448 | 448 | (?s: |
449 | 449 | <([?%]) # $2 |
450 | 450 | .*? |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | [ ]* # Tailing spaces |
575 | 575 | $ # End of line. |
576 | 576 | }mx', |
577 | - "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n", |
|
577 | + "\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n", |
|
578 | 578 | $text |
579 | 579 | ); |
580 | 580 | } |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | $text = preg_replace_callback('{ |
653 | 653 | ( # wrap whole match in $1 |
654 | 654 | \[ |
655 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
655 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
656 | 656 | \] |
657 | 657 | |
658 | 658 | [ ]? # one optional space |
@@ -669,14 +669,14 @@ discard block |
||
669 | 669 | $text = preg_replace_callback('{ |
670 | 670 | ( # wrap whole match in $1 |
671 | 671 | \[ |
672 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
672 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
673 | 673 | \] |
674 | 674 | \( # literal paren |
675 | 675 | [ \n]* |
676 | 676 | (?: |
677 | 677 | <(.+?)> # href = $3 |
678 | 678 | | |
679 | - ('.$this->nested_url_parenthesis_re.') # href = $4 |
|
679 | + ('.$this->nested_url_parenthesis_re . ') # href = $4 |
|
680 | 680 | ) |
681 | 681 | [ \n]* |
682 | 682 | ( # $5 |
@@ -712,9 +712,9 @@ discard block |
||
712 | 712 | * @return string |
713 | 713 | */ |
714 | 714 | protected function _doAnchors_reference_callback($matches) { |
715 | - $whole_match = $matches[1]; |
|
716 | - $link_text = $matches[2]; |
|
717 | - $link_id =& $matches[3]; |
|
715 | + $whole_match = $matches[1]; |
|
716 | + $link_text = $matches[2]; |
|
717 | + $link_id = & $matches[3]; |
|
718 | 718 | |
719 | 719 | if ($link_id == "") { |
720 | 720 | // for shortcut links like [this][] or [this]. |
@@ -730,10 +730,10 @@ discard block |
||
730 | 730 | $url = $this->encodeURLAttribute($url); |
731 | 731 | |
732 | 732 | $result = "<a href=\"$url\""; |
733 | - if ( isset( $this->titles[$link_id] ) ) { |
|
733 | + if (isset($this->titles[$link_id])) { |
|
734 | 734 | $title = $this->titles[$link_id]; |
735 | 735 | $title = $this->encodeAttribute($title); |
736 | - $result .= " title=\"$title\""; |
|
736 | + $result .= " title=\"$title\""; |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | $link_text = $this->runSpanGamut($link_text); |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | * @return string |
752 | 752 | */ |
753 | 753 | protected function _doAnchors_inline_callback($matches) { |
754 | - $link_text = $this->runSpanGamut($matches[2]); |
|
755 | - $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
|
756 | - $title =& $matches[7]; |
|
754 | + $link_text = $this->runSpanGamut($matches[2]); |
|
755 | + $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
|
756 | + $title = & $matches[7]; |
|
757 | 757 | |
758 | 758 | // If the URL was of the form <s p a c e s> it got caught by the HTML |
759 | 759 | // tag parser and hashed. Need to reverse the process before using |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | $result = "<a href=\"$url\""; |
768 | 768 | if ($title) { |
769 | 769 | $title = $this->encodeAttribute($title); |
770 | - $result .= " title=\"$title\""; |
|
770 | + $result .= " title=\"$title\""; |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | $link_text = $this->runSpanGamut($link_text); |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | $text = preg_replace_callback('{ |
787 | 787 | ( # wrap whole match in $1 |
788 | 788 | !\[ |
789 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
789 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
790 | 790 | \] |
791 | 791 | |
792 | 792 | [ ]? # one optional space |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | $text = preg_replace_callback('{ |
806 | 806 | ( # wrap whole match in $1 |
807 | 807 | !\[ |
808 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
808 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
809 | 809 | \] |
810 | 810 | \s? # One optional whitespace character |
811 | 811 | \( # literal paren |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | (?: |
814 | 814 | <(\S*)> # src url = $3 |
815 | 815 | | |
816 | - ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
816 | + ('.$this->nested_url_parenthesis_re . ') # src url = $4 |
|
817 | 817 | ) |
818 | 818 | [ \n]* |
819 | 819 | ( # $5 |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | if (isset($this->titles[$link_id])) { |
852 | 852 | $title = $this->titles[$link_id]; |
853 | 853 | $title = $this->encodeAttribute($title); |
854 | - $result .= " title=\"$title\""; |
|
854 | + $result .= " title=\"$title\""; |
|
855 | 855 | } |
856 | 856 | $result .= $this->empty_element_suffix; |
857 | 857 | $result = $this->hashPart($result); |
@@ -869,17 +869,17 @@ discard block |
||
869 | 869 | * @return string |
870 | 870 | */ |
871 | 871 | protected function _doImages_inline_callback($matches) { |
872 | - $whole_match = $matches[1]; |
|
873 | - $alt_text = $matches[2]; |
|
874 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
875 | - $title =& $matches[7]; |
|
872 | + $whole_match = $matches[1]; |
|
873 | + $alt_text = $matches[2]; |
|
874 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
875 | + $title = & $matches[7]; |
|
876 | 876 | |
877 | 877 | $alt_text = $this->encodeAttribute($alt_text); |
878 | 878 | $url = $this->encodeURLAttribute($url); |
879 | 879 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
880 | 880 | if (isset($title)) { |
881 | 881 | $title = $this->encodeAttribute($title); |
882 | - $result .= " title=\"$title\""; // $title already quoted |
|
882 | + $result .= " title=\"$title\""; // $title already quoted |
|
883 | 883 | } |
884 | 884 | $result .= $this->empty_element_suffix; |
885 | 885 | |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | // ID attribute generation |
941 | 941 | $idAtt = $this->_generateIdFromHeaderValue($matches[1]); |
942 | 942 | |
943 | - $block = "<h$level$idAtt>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
943 | + $block = "<h$level$idAtt>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
944 | 944 | return "\n" . $this->hashBlock($block) . "\n\n"; |
945 | 945 | } |
946 | 946 | |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | $idAtt = $this->_generateIdFromHeaderValue($matches[2]); |
955 | 955 | |
956 | 956 | $level = strlen($matches[1]); |
957 | - $block = "<h$level$idAtt>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
957 | + $block = "<h$level$idAtt>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
958 | 958 | return "\n" . $this->hashBlock($block) . "\n\n"; |
959 | 959 | } |
960 | 960 | |
@@ -1002,8 +1002,8 @@ discard block |
||
1002 | 1002 | $whole_list_re = ' |
1003 | 1003 | ( # $1 = whole list |
1004 | 1004 | ( # $2 |
1005 | - ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces |
|
1006 | - ('.$marker_re.') # $4 = first list item marker |
|
1005 | + ([ ]{0,'.$less_than_tab . '}) # $3 = number of spaces |
|
1006 | + ('.$marker_re . ') # $4 = first list item marker |
|
1007 | 1007 | [ ]+ |
1008 | 1008 | ) |
1009 | 1009 | (?s:.+?) |
@@ -1014,13 +1014,13 @@ discard block |
||
1014 | 1014 | (?=\S) |
1015 | 1015 | (?! # Negative lookahead for another list item marker |
1016 | 1016 | [ ]* |
1017 | - '.$marker_re.'[ ]+ |
|
1017 | + '.$marker_re . '[ ]+ |
|
1018 | 1018 | ) |
1019 | 1019 | | |
1020 | 1020 | (?= # Lookahead for another kind of list |
1021 | 1021 | \n |
1022 | 1022 | \3 # Must have the same indentation |
1023 | - '.$other_marker_re.'[ ]+ |
|
1023 | + '.$other_marker_re . '[ ]+ |
|
1024 | 1024 | ) |
1025 | 1025 | ) |
1026 | 1026 | ) |
@@ -1032,13 +1032,13 @@ discard block |
||
1032 | 1032 | if ($this->list_level) { |
1033 | 1033 | $text = preg_replace_callback('{ |
1034 | 1034 | ^ |
1035 | - '.$whole_list_re.' |
|
1035 | + '.$whole_list_re . ' |
|
1036 | 1036 | }mx', |
1037 | 1037 | array($this, '_doLists_callback'), $text); |
1038 | 1038 | } else { |
1039 | 1039 | $text = preg_replace_callback('{ |
1040 | 1040 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
1041 | - '.$whole_list_re.' |
|
1041 | + '.$whole_list_re . ' |
|
1042 | 1042 | }mx', |
1043 | 1043 | array($this, '_doLists_callback'), $text); |
1044 | 1044 | } |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | $list = $matches[1]; |
1063 | 1063 | $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol"; |
1064 | 1064 | |
1065 | - $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re ); |
|
1065 | + $marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re); |
|
1066 | 1066 | |
1067 | 1067 | $list .= "\n"; |
1068 | 1068 | $result = $this->processListItems($list, $marker_any_re); |
@@ -1073,18 +1073,18 @@ discard block |
||
1073 | 1073 | if ($list_type == 'ol') { |
1074 | 1074 | $ol_start_array = array(); |
1075 | 1075 | $ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array); |
1076 | - if ($ol_start_check){ |
|
1076 | + if ($ol_start_check) { |
|
1077 | 1077 | $ol_start = $ol_start_array[0]; |
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | } |
1081 | 1081 | |
1082 | - if ($ol_start > 1 && $list_type == 'ol'){ |
|
1082 | + if ($ol_start > 1 && $list_type == 'ol') { |
|
1083 | 1083 | $result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>"); |
1084 | 1084 | } else { |
1085 | 1085 | $result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>"); |
1086 | 1086 | } |
1087 | - return "\n". $result ."\n\n"; |
|
1087 | + return "\n" . $result . "\n\n"; |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | /** |
@@ -1130,12 +1130,12 @@ discard block |
||
1130 | 1130 | $list_str = preg_replace_callback('{ |
1131 | 1131 | (\n)? # leading line = $1 |
1132 | 1132 | (^[ ]*) # leading whitespace = $2 |
1133 | - ('.$marker_any_re.' # list marker and space = $3 |
|
1133 | + ('.$marker_any_re . ' # list marker and space = $3 |
|
1134 | 1134 | (?:[ ]+|(?=\n)) # space only required if item is not empty |
1135 | 1135 | ) |
1136 | 1136 | ((?s:.*?)) # list item text = $4 |
1137 | 1137 | (?:(\n+(?=\n))|\n) # tailing blank line = $5 |
1138 | - (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n)))) |
|
1138 | + (?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n)))) |
|
1139 | 1139 | }xm', |
1140 | 1140 | array($this, '_processListItems_callback'), $list_str); |
1141 | 1141 | |
@@ -1150,17 +1150,17 @@ discard block |
||
1150 | 1150 | */ |
1151 | 1151 | protected function _processListItems_callback($matches) { |
1152 | 1152 | $item = $matches[4]; |
1153 | - $leading_line =& $matches[1]; |
|
1154 | - $leading_space =& $matches[2]; |
|
1153 | + $leading_line = & $matches[1]; |
|
1154 | + $leading_space = & $matches[2]; |
|
1155 | 1155 | $marker_space = $matches[3]; |
1156 | - $tailing_blank_line =& $matches[5]; |
|
1156 | + $tailing_blank_line = & $matches[5]; |
|
1157 | 1157 | |
1158 | 1158 | if ($leading_line || $tailing_blank_line || |
1159 | 1159 | preg_match('/\n{2,}/', $item)) |
1160 | 1160 | { |
1161 | 1161 | // Replace marker with the appropriate whitespace indentation |
1162 | 1162 | $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
1163 | - $item = $this->runBlockGamut($this->outdent($item)."\n"); |
|
1163 | + $item = $this->runBlockGamut($this->outdent($item) . "\n"); |
|
1164 | 1164 | } else { |
1165 | 1165 | // Recursion for sub-lists: |
1166 | 1166 | $item = $this->doLists($this->outdent($item)); |
@@ -1180,11 +1180,11 @@ discard block |
||
1180 | 1180 | (?:\n\n|\A\n?) |
1181 | 1181 | ( # $1 = the code block -- one or more lines, starting with a space/tab |
1182 | 1182 | (?> |
1183 | - [ ]{'.$this->tab_width.'} # Lines must start with a tab or a tab-width of spaces |
|
1183 | + [ ]{'.$this->tab_width . '} # Lines must start with a tab or a tab-width of spaces |
|
1184 | 1184 | .*\n+ |
1185 | 1185 | )+ |
1186 | 1186 | ) |
1187 | - ((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
1187 | + ((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
1188 | 1188 | }xm', |
1189 | 1189 | array($this, '_doCodeBlocks_callback'), $text); |
1190 | 1190 | |
@@ -1311,8 +1311,8 @@ discard block |
||
1311 | 1311 | // Each token is then passed to handleSpanToken. |
1312 | 1312 | $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); |
1313 | 1313 | $text_stack[0] .= $parts[0]; |
1314 | - $token =& $parts[1]; |
|
1315 | - $text =& $parts[2]; |
|
1314 | + $token = & $parts[1]; |
|
1315 | + $text = & $parts[2]; |
|
1316 | 1316 | |
1317 | 1317 | if (empty($token)) { |
1318 | 1318 | // Reached end of text span: empty stack without emitting. |
@@ -1339,7 +1339,7 @@ discard block |
||
1339 | 1339 | } else { |
1340 | 1340 | // Other closing marker: close one em or strong and |
1341 | 1341 | // change current token state to match the other |
1342 | - $token_stack[0] = str_repeat($token[0], 3-$token_len); |
|
1342 | + $token_stack[0] = str_repeat($token[0], 3 - $token_len); |
|
1343 | 1343 | $tag = $token_len == 2 ? "strong" : "em"; |
1344 | 1344 | $span = $text_stack[0]; |
1345 | 1345 | $span = $this->runSpanGamut($span); |
@@ -1685,7 +1685,7 @@ discard block |
||
1685 | 1685 | } |
1686 | 1686 | |
1687 | 1687 | $chars = preg_split('/(?<!^)(?!$)/', $text); |
1688 | - $seed = (int)abs(crc32($text) / strlen($text)); // Deterministic seed. |
|
1688 | + $seed = (int) abs(crc32($text) / strlen($text)); // Deterministic seed. |
|
1689 | 1689 | |
1690 | 1690 | foreach ($chars as $key => $char) { |
1691 | 1691 | $ord = ord($char); |
@@ -1698,9 +1698,9 @@ discard block |
||
1698 | 1698 | if ($r > 90 && strpos('@"&>', $char) === false) { |
1699 | 1699 | /* do nothing */ |
1700 | 1700 | } else if ($r < 45) { |
1701 | - $chars[$key] = '&#x'.dechex($ord).';'; |
|
1701 | + $chars[$key] = '&#x' . dechex($ord) . ';'; |
|
1702 | 1702 | } else { |
1703 | - $chars[$key] = '&#'.$ord.';'; |
|
1703 | + $chars[$key] = '&#' . $ord . ';'; |
|
1704 | 1704 | } |
1705 | 1705 | } |
1706 | 1706 | } |
@@ -1722,11 +1722,11 @@ discard block |
||
1722 | 1722 | |
1723 | 1723 | $span_re = '{ |
1724 | 1724 | ( |
1725 | - \\\\'.$this->escape_chars_re.' |
|
1725 | + \\\\'.$this->escape_chars_re . ' |
|
1726 | 1726 | | |
1727 | 1727 | (?<![`\\\\]) |
1728 | 1728 | `+ # code span marker |
1729 | - '.( $this->no_markup ? '' : ' |
|
1729 | + '.($this->no_markup ? '' : ' |
|
1730 | 1730 | | |
1731 | 1731 | <!-- .*? --> # comment |
1732 | 1732 | | |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | <[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag |
1743 | 1743 | | |
1744 | 1744 | </[-a-zA-Z0-9:_]+\s*> # closing tag |
1745 | - ').' |
|
1745 | + ') . ' |
|
1746 | 1746 | ) |
1747 | 1747 | }xs'; |
1748 | 1748 | |
@@ -1779,10 +1779,10 @@ discard block |
||
1779 | 1779 | protected function handleSpanToken($token, &$str) { |
1780 | 1780 | switch ($token[0]) { |
1781 | 1781 | case "\\": |
1782 | - return $this->hashPart("&#". ord($token[1]). ";"); |
|
1782 | + return $this->hashPart("&#" . ord($token[1]) . ";"); |
|
1783 | 1783 | case "`": |
1784 | 1784 | // Search for end marker in remaining text. |
1785 | - if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', |
|
1785 | + if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm', |
|
1786 | 1786 | $str, $matches)) |
1787 | 1787 | { |
1788 | 1788 | $str = $matches[2]; |
@@ -5,8 +5,8 @@ |
||
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/autoload.php'; |
@@ -149,7 +149,7 @@ |
||
149 | 149 | */ |
150 | 150 | protected int $footnote_counter = 1; |
151 | 151 | |
152 | - /** |
|
152 | + /** |
|
153 | 153 | * Ref attribute for links |
154 | 154 | */ |
155 | 155 | protected array $ref_attr = array(); |
@@ -188,7 +188,7 @@ discard block |
||
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(); |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | // Compose attributes as string |
254 | 254 | $attr_str = ""; |
255 | 255 | if (!empty($id)) { |
256 | - $attr_str .= ' id="'.$this->encodeAttribute($id) .'"'; |
|
256 | + $attr_str .= ' id="' . $this->encodeAttribute($id) . '"'; |
|
257 | 257 | } |
258 | 258 | if (!empty($classes)) { |
259 | - $attr_str .= ' class="'. implode(" ", $classes) . '"'; |
|
259 | + $attr_str .= ' class="' . implode(" ", $classes) . '"'; |
|
260 | 260 | } |
261 | 261 | if (!$this->no_markup && !empty($attributes)) { |
262 | - $attr_str .= ' '.implode(" ", $attributes); |
|
262 | + $attr_str .= ' ' . implode(" ", $attributes); |
|
263 | 263 | } |
264 | 264 | return $attr_str; |
265 | 265 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | // Link defs are in the form: ^[id]: url "optional title" |
277 | 277 | $text = preg_replace_callback('{ |
278 | - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
278 | + ^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
279 | 279 | [ ]* |
280 | 280 | \n? # maybe *one* newline |
281 | 281 | [ ]* |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | [")] |
295 | 295 | [ ]* |
296 | 296 | )? # title is optional |
297 | - (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
297 | + (?:[ ]* '.$this->id_class_attr_catch_re . ' )? # $5 = extra id & class attr |
|
298 | 298 | (?:\n+|\Z) |
299 | 299 | }xm', |
300 | 300 | array($this, '_stripLinkDefinitions_callback'), |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | $link_id = strtolower($matches[1]); |
312 | 312 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
313 | 313 | $this->urls[$link_id] = $url; |
314 | - $this->titles[$link_id] =& $matches[4]; |
|
315 | - $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]); |
|
314 | + $this->titles[$link_id] = & $matches[4]; |
|
315 | + $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]); |
|
316 | 316 | return ''; // String that will replace the block |
317 | 317 | } |
318 | 318 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | // Call the HTML-in-Markdown hasher. |
372 | - list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
372 | + list($text,) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
373 | 373 | |
374 | 374 | return $text; |
375 | 375 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | <\?.*?\?> | <%.*?%> # Processing instruction |
447 | 447 | | |
448 | 448 | <!\[CDATA\[.*?\]\]> # CData Block |
449 | - ' . ( !$span ? ' # If not in span. |
|
449 | + ' . (!$span ? ' # If not in span. |
|
450 | 450 | | |
451 | 451 | # Indented code block |
452 | 452 | (?: ^[ ]*\n | ^ | \n[ ]*\n ) |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | (?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes |
465 | 465 | [ ]* |
466 | 466 | (?= \n ) |
467 | - ' : '' ) . ' # End (if not is span). |
|
467 | + ' : '') . ' # End (if not is span). |
|
468 | 468 | | |
469 | 469 | # Code span marker |
470 | 470 | # Note, this regex needs to go after backtick fenced |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | }xs'; |
476 | 476 | |
477 | 477 | |
478 | - $depth = 0; // Current depth inside the tag tree. |
|
479 | - $parsed = ""; // Parsed text that will be returned. |
|
478 | + $depth = 0; // Current depth inside the tag tree. |
|
479 | + $parsed = ""; // Parsed text that will be returned. |
|
480 | 480 | |
481 | 481 | // Loop through every tag until we find the closing tag of the parent |
482 | 482 | // or loop until reaching the end of text if no parent tag specified. |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | // Opening Context Block tag (like ins and del) |
554 | 554 | // used as a block tag (tag is alone on it's line). |
555 | 555 | else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) || |
556 | - ( preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
556 | + (preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
557 | 557 | preg_match($newline_before_re, $parsed) && |
558 | - preg_match($newline_after_re, $text) ) |
|
558 | + preg_match($newline_after_re, $text)) |
|
559 | 559 | ) |
560 | 560 | { |
561 | 561 | // Need to parse tag and following text using the HTML parser. |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | // Increase/decrease nested tag count. |
586 | 586 | if ($tag[1] === '/') { |
587 | 587 | $depth--; |
588 | - } else if ($tag[strlen($tag)-2] !== '/') { |
|
588 | + } else if ($tag[strlen($tag) - 2] !== '/') { |
|
589 | 589 | $depth++; |
590 | 590 | } |
591 | 591 | |
@@ -662,11 +662,11 @@ discard block |
||
662 | 662 | ) |
663 | 663 | }xs'; |
664 | 664 | |
665 | - $original_text = $text; // Save original text in case of faliure. |
|
665 | + $original_text = $text; // Save original text in case of faliure. |
|
666 | 666 | |
667 | - $depth = 0; // Current depth inside the tag tree. |
|
668 | - $block_text = ""; // Temporary text holder for current text. |
|
669 | - $parsed = ""; // Parsed text that will be returned. |
|
667 | + $depth = 0; // Current depth inside the tag tree. |
|
668 | + $block_text = ""; // Temporary text holder for current text. |
|
669 | + $parsed = ""; // Parsed text that will be returned. |
|
670 | 670 | $base_tag_name_re = ''; |
671 | 671 | |
672 | 672 | // Get the name of the starting tag. |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
709 | 709 | if ($tag[1] === '/') { |
710 | 710 | $depth--; |
711 | - } else if ($tag[strlen($tag)-2] !== '/') { |
|
711 | + } else if ($tag[strlen($tag) - 2] !== '/') { |
|
712 | 712 | $depth++; |
713 | 713 | } |
714 | 714 | } |
@@ -862,9 +862,9 @@ discard block |
||
862 | 862 | * @return string |
863 | 863 | */ |
864 | 864 | protected function _doAnchors_reference_callback($matches) { |
865 | - $whole_match = $matches[1]; |
|
866 | - $link_text = $matches[2]; |
|
867 | - $link_id =& $matches[3]; |
|
865 | + $whole_match = $matches[1]; |
|
866 | + $link_text = $matches[2]; |
|
867 | + $link_id = & $matches[3]; |
|
868 | 868 | |
869 | 869 | if ($link_id == "") { |
870 | 870 | // for shortcut links like [this][] or [this]. |
@@ -880,10 +880,10 @@ discard block |
||
880 | 880 | $url = $this->encodeURLAttribute($url); |
881 | 881 | |
882 | 882 | $result = "<a href=\"$url\""; |
883 | - if ( isset( $this->titles[$link_id] ) ) { |
|
883 | + if (isset($this->titles[$link_id])) { |
|
884 | 884 | $title = $this->titles[$link_id]; |
885 | 885 | $title = $this->encodeAttribute($title); |
886 | - $result .= " title=\"$title\""; |
|
886 | + $result .= " title=\"$title\""; |
|
887 | 887 | } |
888 | 888 | if (isset($this->ref_attr[$link_id])) |
889 | 889 | $result .= $this->ref_attr[$link_id]; |
@@ -904,11 +904,11 @@ discard block |
||
904 | 904 | * @return string |
905 | 905 | */ |
906 | 906 | protected function _doAnchors_inline_callback($matches) { |
907 | - $link_text = $this->runSpanGamut($matches[2]); |
|
908 | - $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
|
909 | - $title_quote =& $matches[6]; |
|
910 | - $title =& $matches[7]; |
|
911 | - $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]); |
|
907 | + $link_text = $this->runSpanGamut($matches[2]); |
|
908 | + $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
|
909 | + $title_quote = & $matches[6]; |
|
910 | + $title = & $matches[7]; |
|
911 | + $attr = $this->doExtraAttributes("a", $dummy = & $matches[8]); |
|
912 | 912 | |
913 | 913 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
914 | 914 | // tag parser and hashed. Need to reverse the process before using the URL. |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | $result = "<a href=\"$url\""; |
922 | 922 | if (isset($title) && $title_quote) { |
923 | 923 | $title = $this->encodeAttribute($title); |
924 | - $result .= " title=\"$title\""; |
|
924 | + $result .= " title=\"$title\""; |
|
925 | 925 | } |
926 | 926 | $result .= $attr; |
927 | 927 | |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | if (isset($this->titles[$link_id])) { |
1008 | 1008 | $title = $this->titles[$link_id]; |
1009 | 1009 | $title = $this->encodeAttribute($title); |
1010 | - $result .= " title=\"$title\""; |
|
1010 | + $result .= " title=\"$title\""; |
|
1011 | 1011 | } |
1012 | 1012 | if (isset($this->ref_attr[$link_id])) { |
1013 | 1013 | $result .= $this->ref_attr[$link_id]; |
@@ -1029,18 +1029,18 @@ discard block |
||
1029 | 1029 | * @return string |
1030 | 1030 | */ |
1031 | 1031 | protected function _doImages_inline_callback($matches) { |
1032 | - $alt_text = $matches[2]; |
|
1032 | + $alt_text = $matches[2]; |
|
1033 | 1033 | $url = $matches[3] === '' ? $matches[4] : $matches[3]; |
1034 | - $title_quote =& $matches[6]; |
|
1035 | - $title =& $matches[7]; |
|
1036 | - $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); |
|
1034 | + $title_quote = & $matches[6]; |
|
1035 | + $title = & $matches[7]; |
|
1036 | + $attr = $this->doExtraAttributes("img", $dummy = & $matches[8]); |
|
1037 | 1037 | |
1038 | 1038 | $alt_text = $this->encodeAttribute($alt_text); |
1039 | 1039 | $url = $this->encodeURLAttribute($url); |
1040 | 1040 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
1041 | 1041 | if (isset($title) && $title_quote) { |
1042 | 1042 | $title = $this->encodeAttribute($title); |
1043 | - $result .= " title=\"$title\""; // $title already quoted |
|
1043 | + $result .= " title=\"$title\""; // $title already quoted |
|
1044 | 1044 | } |
1045 | 1045 | $result .= $attr; |
1046 | 1046 | $result .= $this->empty_element_suffix; |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | // |
1079 | 1079 | $text = preg_replace_callback('{ |
1080 | 1080 | ^(\#{1,6}) # $1 = string of #\'s |
1081 | - [ ]'.($this->hashtag_protection ? '+' : '*').' |
|
1081 | + [ ]'.($this->hashtag_protection ? '+' : '*') . ' |
|
1082 | 1082 | (.+?) # $2 = Header text |
1083 | 1083 | [ ]* |
1084 | 1084 | \#* # optional closing #\'s (not counted) |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null; |
1107 | 1107 | |
1108 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId); |
|
1108 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[2], $defaultId); |
|
1109 | 1109 | $block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
1110 | 1110 | return "\n" . $this->hashBlock($block) . "\n\n"; |
1111 | 1111 | } |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | $level = strlen($matches[1]); |
1120 | 1120 | |
1121 | 1121 | $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null; |
1122 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId); |
|
1122 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[3], $defaultId); |
|
1123 | 1123 | $block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
1124 | 1124 | return "\n" . $this->hashBlock($block) . "\n\n"; |
1125 | 1125 | } |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | * @return string |
1191 | 1191 | */ |
1192 | 1192 | protected function _doTable_leadingPipe_callback($matches) { |
1193 | - $head = $matches[1]; |
|
1194 | - $underline = $matches[2]; |
|
1193 | + $head = $matches[1]; |
|
1194 | + $underline = $matches[2]; |
|
1195 | 1195 | $content = $matches[3]; |
1196 | 1196 | |
1197 | 1197 | $content = preg_replace('/^ *[|]/m', '', $content); |
@@ -1219,15 +1219,15 @@ discard block |
||
1219 | 1219 | * @return string |
1220 | 1220 | */ |
1221 | 1221 | protected function _doTable_callback($matches) { |
1222 | - $head = $matches[1]; |
|
1223 | - $underline = $matches[2]; |
|
1224 | - $content = $matches[3]; |
|
1225 | - $attr = []; |
|
1222 | + $head = $matches[1]; |
|
1223 | + $underline = $matches[2]; |
|
1224 | + $content = $matches[3]; |
|
1225 | + $attr = []; |
|
1226 | 1226 | |
1227 | 1227 | // Remove any tailing pipes for each line. |
1228 | - $head = preg_replace('/[|] *$/m', '', $head); |
|
1229 | - $underline = preg_replace('/[|] *$/m', '', $underline); |
|
1230 | - $content = preg_replace('/[|] *$/m', '', $content); |
|
1228 | + $head = preg_replace('/[|] *$/m', '', $head); |
|
1229 | + $underline = preg_replace('/[|] *$/m', '', $underline); |
|
1230 | + $content = preg_replace('/[|] *$/m', '', $content); |
|
1231 | 1231 | |
1232 | 1232 | // Reading alignement from header underline. |
1233 | 1233 | $separators = preg_split('/ *[|] */', $underline); |
@@ -1244,10 +1244,10 @@ discard block |
||
1244 | 1244 | |
1245 | 1245 | // Parsing span elements, including code spans, character escapes, |
1246 | 1246 | // and inline HTML tags, so that pipes inside those gets ignored. |
1247 | - $head = $this->parseSpan($head); |
|
1248 | - $headers = preg_split('/ *[|] */', $head); |
|
1249 | - $col_count = count($headers); |
|
1250 | - $attr = array_pad($attr, $col_count, ''); |
|
1247 | + $head = $this->parseSpan($head); |
|
1248 | + $headers = preg_split('/ *[|] */', $head); |
|
1249 | + $col_count = count($headers); |
|
1250 | + $attr = array_pad($attr, $col_count, ''); |
|
1251 | 1251 | |
1252 | 1252 | // Write column headers. |
1253 | 1253 | $text = "<table>\n"; |
@@ -1415,13 +1415,13 @@ discard block |
||
1415 | 1415 | protected function _processDefListItems_callback_dd($matches) { |
1416 | 1416 | $leading_line = $matches[1]; |
1417 | 1417 | $marker_space = $matches[2]; |
1418 | - $def = $matches[3]; |
|
1418 | + $def = $matches[3]; |
|
1419 | 1419 | |
1420 | 1420 | if ($leading_line || preg_match('/\n{2,}/', $def)) { |
1421 | 1421 | // Replace marker with the appropriate whitespace indentation |
1422 | 1422 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
1423 | 1423 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
1424 | - $def = "\n". $def ."\n"; |
|
1424 | + $def = "\n" . $def . "\n"; |
|
1425 | 1425 | } |
1426 | 1426 | else { |
1427 | 1427 | $def = rtrim($def); |
@@ -1481,8 +1481,8 @@ discard block |
||
1481 | 1481 | * @return string |
1482 | 1482 | */ |
1483 | 1483 | protected function _doFencedCodeBlocks_callback($matches) { |
1484 | - $classname =& $matches[2]; |
|
1485 | - $attrs =& $matches[3]; |
|
1484 | + $classname = & $matches[2]; |
|
1485 | + $attrs = & $matches[3]; |
|
1486 | 1486 | $codeblock = $matches[4]; |
1487 | 1487 | |
1488 | 1488 | if ($this->code_block_content_func) { |
@@ -1504,9 +1504,9 @@ discard block |
||
1504 | 1504 | $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes); |
1505 | 1505 | $pre_attr_str = $this->code_attr_on_pre ? $attr_str : ''; |
1506 | 1506 | $code_attr_str = $this->code_attr_on_pre ? '' : $attr_str; |
1507 | - $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
1507 | + $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
1508 | 1508 | |
1509 | - return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
1509 | + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
1510 | 1510 | } |
1511 | 1511 | |
1512 | 1512 | /** |
@@ -1639,9 +1639,9 @@ discard block |
||
1639 | 1639 | $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', |
1640 | 1640 | array($this, '_appendFootnotes_callback'), $text); |
1641 | 1641 | |
1642 | - if ( ! empty( $this->footnotes_ordered ) ) { |
|
1642 | + if (!empty($this->footnotes_ordered)) { |
|
1643 | 1643 | $this->_doFootnotes(); |
1644 | - if ( ! $this->omit_footnotes ) { |
|
1644 | + if (!$this->omit_footnotes) { |
|
1645 | 1645 | $text .= "\n\n"; |
1646 | 1646 | $text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n"; |
1647 | 1647 | $text .= "<hr" . $this->empty_element_suffix . "\n"; |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | // Create footnote marker only if it has a corresponding footnote *and* |
1742 | 1742 | // the footnote hasn't been used by another marker. |
1743 | 1743 | if (isset($this->footnotes[$node_id])) { |
1744 | - $num =& $this->footnotes_numbers[$node_id]; |
|
1744 | + $num = & $this->footnotes_numbers[$node_id]; |
|
1745 | 1745 | if (!isset($num)) { |
1746 | 1746 | // Transfer footnote content to the ordered list and give it its |
1747 | 1747 | // number |
@@ -1770,8 +1770,8 @@ discard block |
||
1770 | 1770 | $node_id = $this->encodeAttribute($node_id); |
1771 | 1771 | |
1772 | 1772 | return |
1773 | - "<sup id=\"fnref$ref_count_mark:$node_id\">". |
|
1774 | - "<a href=\"#fn:$node_id\"$attr>$num</a>". |
|
1773 | + "<sup id=\"fnref$ref_count_mark:$node_id\">" . |
|
1774 | + "<a href=\"#fn:$node_id\"$attr>$num</a>" . |
|
1775 | 1775 | "</sup>"; |
1776 | 1776 | } |
1777 | 1777 |
@@ -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 | // @phpstan-ignore-next-line |
@@ -622,7 +625,9 @@ discard block |
||
622 | 625 | * @return array |
623 | 626 | */ |
624 | 627 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
625 | - if ($text === '') return array('', ''); |
|
628 | + if ($text === '') { |
|
629 | + return array('', ''); |
|
630 | + } |
|
626 | 631 | |
627 | 632 | // Regex to match `markdown` attribute inside of a tag. |
628 | 633 | $markdown_attr_re = ' |
@@ -672,8 +677,9 @@ discard block |
||
672 | 677 | |
673 | 678 | // Get the name of the starting tag. |
674 | 679 | // (This pattern makes $base_tag_name_re safe without quoting.) |
675 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
676 | - $base_tag_name_re = $matches[1]; |
|
680 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
681 | + $base_tag_name_re = $matches[1]; |
|
682 | + } |
|
677 | 683 | |
678 | 684 | // Loop through every tag until we find the corresponding closing tag. |
679 | 685 | do { |
@@ -702,8 +708,7 @@ discard block |
||
702 | 708 | { |
703 | 709 | // Just add the tag to the block as if it was text. |
704 | 710 | $block_text .= $tag; |
705 | - } |
|
706 | - else { |
|
711 | + } else { |
|
707 | 712 | // Increase/decrease nested tag count. Only do so if |
708 | 713 | // the tag's name match base tag's. |
709 | 714 | if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
@@ -764,8 +769,9 @@ discard block |
||
764 | 769 | |
765 | 770 | // Start over with a new block. |
766 | 771 | $block_text = ""; |
772 | + } else { |
|
773 | + $block_text .= $tag; |
|
767 | 774 | } |
768 | - else $block_text .= $tag; |
|
769 | 775 | } |
770 | 776 | |
771 | 777 | } while ($depth > 0); |
@@ -886,14 +892,14 @@ discard block |
||
886 | 892 | $title = $this->encodeAttribute($title); |
887 | 893 | $result .= " title=\"$title\""; |
888 | 894 | } |
889 | - if (isset($this->ref_attr[$link_id])) |
|
890 | - $result .= $this->ref_attr[$link_id]; |
|
895 | + if (isset($this->ref_attr[$link_id])) { |
|
896 | + $result .= $this->ref_attr[$link_id]; |
|
897 | + } |
|
891 | 898 | |
892 | 899 | $link_text = $this->runSpanGamut($link_text); |
893 | 900 | $result .= ">$link_text</a>"; |
894 | 901 | $result = $this->hashPart($result); |
895 | - } |
|
896 | - else { |
|
902 | + } else { |
|
897 | 903 | $result = $whole_match; |
898 | 904 | } |
899 | 905 | return $result; |
@@ -914,8 +920,9 @@ discard block |
||
914 | 920 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
915 | 921 | // tag parser and hashed. Need to reverse the process before using the URL. |
916 | 922 | $unhashed = $this->unhash($url); |
917 | - if ($unhashed !== $url) |
|
918 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
923 | + if ($unhashed !== $url) { |
|
924 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
925 | + } |
|
919 | 926 | |
920 | 927 | $url = $this->encodeURLAttribute($url); |
921 | 928 | |
@@ -1015,8 +1022,7 @@ discard block |
||
1015 | 1022 | } |
1016 | 1023 | $result .= $this->empty_element_suffix; |
1017 | 1024 | $result = $this->hashPart($result); |
1018 | - } |
|
1019 | - else { |
|
1025 | + } else { |
|
1020 | 1026 | // If there's no such link ID, leave intact: |
1021 | 1027 | $result = $whole_match; |
1022 | 1028 | } |
@@ -1233,14 +1239,15 @@ discard block |
||
1233 | 1239 | // Reading alignement from header underline. |
1234 | 1240 | $separators = preg_split('/ *[|] */', $underline); |
1235 | 1241 | foreach ($separators as $n => $s) { |
1236 | - if (preg_match('/^ *-+: *$/', $s)) |
|
1237 | - $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
1238 | - else if (preg_match('/^ *:-+: *$/', $s)) |
|
1239 | - $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
1240 | - else if (preg_match('/^ *:-+ *$/', $s)) |
|
1241 | - $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
1242 | - else |
|
1243 | - $attr[$n] = ''; |
|
1242 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
1243 | + $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
1244 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
1245 | + $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
1246 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
1247 | + $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
1248 | + } else { |
|
1249 | + $attr[$n] = ''; |
|
1250 | + } |
|
1244 | 1251 | } |
1245 | 1252 | |
1246 | 1253 | // Parsing span elements, including code spans, character escapes, |
@@ -1423,8 +1430,7 @@ discard block |
||
1423 | 1430 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
1424 | 1431 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
1425 | 1432 | $def = "\n". $def ."\n"; |
1426 | - } |
|
1427 | - else { |
|
1433 | + } else { |
|
1428 | 1434 | $def = rtrim($def); |
1429 | 1435 | $def = $this->runSpanGamut($this->outdent($def)); |
1430 | 1436 | } |