@@ -25,6 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | ### Simple Function Interface ### |
| 27 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string $text |
|
| 30 | + */ |
|
| 28 | 31 | public static function defaultTransform($text) { |
| 29 | 32 | # |
| 30 | 33 | # Initialize the parser and return the result of its transform method. |
@@ -866,6 +869,10 @@ discard block |
||
| 866 | 869 | |
| 867 | 870 | protected $list_level = 0; |
| 868 | 871 | |
| 872 | + /** |
|
| 873 | + * @param string $list_str |
|
| 874 | + * @param string $marker_any_re |
|
| 875 | + */ |
|
| 869 | 876 | protected function processListItems($list_str, $marker_any_re) { |
| 870 | 877 | # |
| 871 | 878 | # Process the contents of a single ordered or unordered list, splitting it |
@@ -969,6 +976,9 @@ discard block |
||
| 969 | 976 | } |
| 970 | 977 | |
| 971 | 978 | |
| 979 | + /** |
|
| 980 | + * @param string $code |
|
| 981 | + */ |
|
| 972 | 982 | protected function makeCodeSpan($code) { |
| 973 | 983 | # |
| 974 | 984 | # Create a code span markup for $code. Called from handleSpanToken. |
@@ -1461,6 +1471,9 @@ discard block |
||
| 1461 | 1471 | # hanlde UTF-8 if the default function does not exist. |
| 1462 | 1472 | protected $utf8_strlen = 'mb_strlen'; |
| 1463 | 1473 | |
| 1474 | + /** |
|
| 1475 | + * @param string $text |
|
| 1476 | + */ |
|
| 1464 | 1477 | protected function detab($text) { |
| 1465 | 1478 | # |
| 1466 | 1479 | # Replace tabs with the appropriate amount of space. |
@@ -2018,6 +2031,12 @@ discard block |
||
| 2018 | 2031 | |
| 2019 | 2032 | return array($parsed, $text); |
| 2020 | 2033 | } |
| 2034 | + |
|
| 2035 | + /** |
|
| 2036 | + * @param string $text |
|
| 2037 | + * @param string $hash_method |
|
| 2038 | + * @param boolean $md_attr |
|
| 2039 | + */ |
|
| 2021 | 2040 | protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { |
| 2022 | 2041 | # |
| 2023 | 2042 | # Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags. |
@@ -2568,6 +2587,10 @@ discard block |
||
| 2568 | 2587 | |
| 2569 | 2588 | return $this->_doTable_callback(array($matches[0], $head, $underline, $content)); |
| 2570 | 2589 | } |
| 2590 | + |
|
| 2591 | + /** |
|
| 2592 | + * @param string $alignname |
|
| 2593 | + */ |
|
| 2571 | 2594 | protected function _doTable_makeAlignAttr($alignname) |
| 2572 | 2595 | { |
| 2573 | 2596 | if (empty($this->table_align_class_tmpl)) |
@@ -2694,6 +2717,9 @@ discard block |
||
| 2694 | 2717 | } |
| 2695 | 2718 | |
| 2696 | 2719 | |
| 2720 | + /** |
|
| 2721 | + * @return string |
|
| 2722 | + */ |
|
| 2697 | 2723 | protected function processDefListItems($list_str) { |
| 2698 | 2724 | # |
| 2699 | 2725 | # Process the contents of a single definition list, splitting it |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | ### Version ### |
| 23 | 23 | |
| 24 | - const MARKDOWNLIB_VERSION = "1.4.0"; |
|
| 24 | + const MARKDOWNLIB_VERSION = "1.4.0"; |
|
| 25 | 25 | |
| 26 | 26 | ### Simple Function Interface ### |
| 27 | 27 | |
@@ -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) |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | $this->prepareItalicsAndBold(); |
| 84 | 84 | |
| 85 | 85 | $this->nested_brackets_re = |
| 86 | - str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth). |
|
| 86 | + str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) . |
|
| 87 | 87 | str_repeat('\])*', $this->nested_brackets_depth); |
| 88 | 88 | |
| 89 | 89 | $this->nested_url_parenthesis_re = |
| 90 | - str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth). |
|
| 90 | + str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) . |
|
| 91 | 91 | str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth); |
| 92 | 92 | |
| 93 | - $this->escape_chars_re = '['.preg_quote($this->escape_chars).']'; |
|
| 93 | + $this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']'; |
|
| 94 | 94 | |
| 95 | 95 | # Sort document, block, and span gamut in ascendent priority order. |
| 96 | 96 | asort($this->document_gamut); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | # Link defs are in the form: ^[id]: url "optional title" |
| 190 | 190 | $text = preg_replace_callback('{ |
| 191 | - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 191 | + ^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
| 192 | 192 | [ ]* |
| 193 | 193 | \n? # maybe *one* newline |
| 194 | 194 | [ ]* |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $link_id = strtolower($matches[1]); |
| 218 | 218 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
| 219 | 219 | $this->urls[$link_id] = $url; |
| 220 | - $this->titles[$link_id] =& $matches[4]; |
|
| 220 | + $this->titles[$link_id] = & $matches[4]; |
|
| 221 | 221 | return ''; # String that will replace the block |
| 222 | 222 | } |
| 223 | 223 | |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | # * List "b" is made of tags which are always block-level; |
| 242 | 242 | # |
| 243 | 243 | $block_tags_a_re = 'ins|del'; |
| 244 | - $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'. |
|
| 245 | - 'script|noscript|form|fieldset|iframe|math|svg|'. |
|
| 246 | - 'article|section|nav|aside|hgroup|header|footer|'. |
|
| 244 | + $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' . |
|
| 245 | + 'script|noscript|form|fieldset|iframe|math|svg|' . |
|
| 246 | + 'article|section|nav|aside|hgroup|header|footer|' . |
|
| 247 | 247 | 'figure'; |
| 248 | 248 | |
| 249 | 249 | # Regular expression for the content of a block tag. |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | [^<]+ # content without tag |
| 269 | 269 | | |
| 270 | 270 | <\2 # nested opening tag |
| 271 | - '.$attr.' # attributes |
|
| 271 | + '.$attr . ' # attributes |
|
| 272 | 272 | (?> |
| 273 | 273 | /> |
| 274 | 274 | | |
| 275 | - >', $nested_tags_level). # end of opening tag |
|
| 276 | - '.*?'. # last level nested tag content |
|
| 275 | + >', $nested_tags_level) . # end of opening tag |
|
| 276 | + '.*?' . # last level nested tag content |
|
| 277 | 277 | str_repeat(' |
| 278 | 278 | </\2\s*> # closing nested tag |
| 279 | 279 | ) |
@@ -306,20 +306,20 @@ discard block |
||
| 306 | 306 | # Match from `\n<tag>` to `</tag>\n`, handling nested tags |
| 307 | 307 | # in between. |
| 308 | 308 | |
| 309 | - [ ]{0,'.$less_than_tab.'} |
|
| 310 | - <('.$block_tags_b_re.')# start tag = $2 |
|
| 311 | - '.$attr.'> # attributes followed by > and \n |
|
| 312 | - '.$content.' # content, support nesting |
|
| 309 | + [ ]{0,'.$less_than_tab . '} |
|
| 310 | + <('.$block_tags_b_re . ')# start tag = $2 |
|
| 311 | + '.$attr . '> # attributes followed by > and \n |
|
| 312 | + '.$content . ' # content, support nesting |
|
| 313 | 313 | </\2> # the matching end tag |
| 314 | 314 | [ ]* # trailing spaces/tabs |
| 315 | 315 | (?=\n+|\Z) # followed by a newline or end of document |
| 316 | 316 | |
| 317 | 317 | | # Special version for tags of group a. |
| 318 | 318 | |
| 319 | - [ ]{0,'.$less_than_tab.'} |
|
| 320 | - <('.$block_tags_a_re.')# start tag = $3 |
|
| 321 | - '.$attr.'>[ ]*\n # attributes followed by > |
|
| 322 | - '.$content2.' # content, support nesting |
|
| 319 | + [ ]{0,'.$less_than_tab . '} |
|
| 320 | + <('.$block_tags_a_re . ')# start tag = $3 |
|
| 321 | + '.$attr . '>[ ]*\n # attributes followed by > |
|
| 322 | + '.$content2 . ' # content, support nesting |
|
| 323 | 323 | </\3> # the matching end tag |
| 324 | 324 | [ ]* # trailing spaces/tabs |
| 325 | 325 | (?=\n+|\Z) # followed by a newline or end of document |
@@ -327,16 +327,16 @@ discard block |
||
| 327 | 327 | | # Special case just for <hr />. It was easier to make a special |
| 328 | 328 | # case than to make the other regex more complicated. |
| 329 | 329 | |
| 330 | - [ ]{0,'.$less_than_tab.'} |
|
| 330 | + [ ]{0,'.$less_than_tab . '} |
|
| 331 | 331 | <(hr) # start tag = $2 |
| 332 | - '.$attr.' # attributes |
|
| 332 | + '.$attr . ' # attributes |
|
| 333 | 333 | /?> # the matching end tag |
| 334 | 334 | [ ]* |
| 335 | 335 | (?=\n{2,}|\Z) # followed by a blank line or end of document |
| 336 | 336 | |
| 337 | 337 | | # Special case for standalone HTML comments: |
| 338 | 338 | |
| 339 | - [ ]{0,'.$less_than_tab.'} |
|
| 339 | + [ ]{0,'.$less_than_tab . '} |
|
| 340 | 340 | (?s: |
| 341 | 341 | <!-- .*? --> |
| 342 | 342 | ) |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | | # PHP and ASP-style processor instructions (<? and <%) |
| 347 | 347 | |
| 348 | - [ ]{0,'.$less_than_tab.'} |
|
| 348 | + [ ]{0,'.$less_than_tab . '} |
|
| 349 | 349 | (?s: |
| 350 | 350 | <([?%]) # $2 |
| 351 | 351 | .*? |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | [ ]* # Tailing spaces |
| 457 | 457 | $ # End of line. |
| 458 | 458 | }mx', |
| 459 | - "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n", |
|
| 459 | + "\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n", |
|
| 460 | 460 | $text); |
| 461 | 461 | } |
| 462 | 462 | |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | $text = preg_replace_callback('{ |
| 521 | 521 | ( # wrap whole match in $1 |
| 522 | 522 | \[ |
| 523 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 523 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 524 | 524 | \] |
| 525 | 525 | |
| 526 | 526 | [ ]? # one optional space |
@@ -539,14 +539,14 @@ discard block |
||
| 539 | 539 | $text = preg_replace_callback('{ |
| 540 | 540 | ( # wrap whole match in $1 |
| 541 | 541 | \[ |
| 542 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 542 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 543 | 543 | \] |
| 544 | 544 | \( # literal paren |
| 545 | 545 | [ \n]* |
| 546 | 546 | (?: |
| 547 | 547 | <(.+?)> # href = $3 |
| 548 | 548 | | |
| 549 | - ('.$this->nested_url_parenthesis_re.') # href = $4 |
|
| 549 | + ('.$this->nested_url_parenthesis_re . ') # href = $4 |
|
| 550 | 550 | ) |
| 551 | 551 | [ \n]* |
| 552 | 552 | ( # $5 |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | return $text; |
| 579 | 579 | } |
| 580 | 580 | protected function _doAnchors_reference_callback($matches) { |
| 581 | - $whole_match = $matches[1]; |
|
| 582 | - $link_text = $matches[2]; |
|
| 583 | - $link_id =& $matches[3]; |
|
| 581 | + $whole_match = $matches[1]; |
|
| 582 | + $link_text = $matches[2]; |
|
| 583 | + $link_id = & $matches[3]; |
|
| 584 | 584 | |
| 585 | 585 | if ($link_id == "") { |
| 586 | 586 | # for shortcut links like [this][] or [this]. |
@@ -596,10 +596,10 @@ discard block |
||
| 596 | 596 | $url = $this->encodeAttribute($url); |
| 597 | 597 | |
| 598 | 598 | $result = "<a href=\"$url\""; |
| 599 | - if ( isset( $this->titles[$link_id] ) ) { |
|
| 599 | + if (isset($this->titles[$link_id])) { |
|
| 600 | 600 | $title = $this->titles[$link_id]; |
| 601 | 601 | $title = $this->encodeAttribute($title); |
| 602 | - $result .= " title=\"$title\""; |
|
| 602 | + $result .= " title=\"$title\""; |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | $link_text = $this->runSpanGamut($link_text); |
@@ -612,17 +612,17 @@ discard block |
||
| 612 | 612 | return $result; |
| 613 | 613 | } |
| 614 | 614 | protected function _doAnchors_inline_callback($matches) { |
| 615 | - $whole_match = $matches[1]; |
|
| 616 | - $link_text = $this->runSpanGamut($matches[2]); |
|
| 617 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 618 | - $title =& $matches[7]; |
|
| 615 | + $whole_match = $matches[1]; |
|
| 616 | + $link_text = $this->runSpanGamut($matches[2]); |
|
| 617 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 618 | + $title = & $matches[7]; |
|
| 619 | 619 | |
| 620 | 620 | $url = $this->encodeAttribute($url); |
| 621 | 621 | |
| 622 | 622 | $result = "<a href=\"$url\""; |
| 623 | 623 | if (isset($title)) { |
| 624 | 624 | $title = $this->encodeAttribute($title); |
| 625 | - $result .= " title=\"$title\""; |
|
| 625 | + $result .= " title=\"$title\""; |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | $link_text = $this->runSpanGamut($link_text); |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $text = preg_replace_callback('{ |
| 643 | 643 | ( # wrap whole match in $1 |
| 644 | 644 | !\[ |
| 645 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 645 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 646 | 646 | \] |
| 647 | 647 | |
| 648 | 648 | [ ]? # one optional space |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | $text = preg_replace_callback('{ |
| 664 | 664 | ( # wrap whole match in $1 |
| 665 | 665 | !\[ |
| 666 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 666 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 667 | 667 | \] |
| 668 | 668 | \s? # One optional whitespace character |
| 669 | 669 | \( # literal paren |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | (?: |
| 672 | 672 | <(\S*)> # src url = $3 |
| 673 | 673 | | |
| 674 | - ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 674 | + ('.$this->nested_url_parenthesis_re . ') # src url = $4 |
|
| 675 | 675 | ) |
| 676 | 676 | [ \n]* |
| 677 | 677 | ( # $5 |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | if (isset($this->titles[$link_id])) { |
| 704 | 704 | $title = $this->titles[$link_id]; |
| 705 | 705 | $title = $this->encodeAttribute($title); |
| 706 | - $result .= " title=\"$title\""; |
|
| 706 | + $result .= " title=\"$title\""; |
|
| 707 | 707 | } |
| 708 | 708 | $result .= $this->empty_element_suffix; |
| 709 | 709 | $result = $this->hashPart($result); |
@@ -716,17 +716,17 @@ discard block |
||
| 716 | 716 | return $result; |
| 717 | 717 | } |
| 718 | 718 | protected function _doImages_inline_callback($matches) { |
| 719 | - $whole_match = $matches[1]; |
|
| 720 | - $alt_text = $matches[2]; |
|
| 721 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 722 | - $title =& $matches[7]; |
|
| 719 | + $whole_match = $matches[1]; |
|
| 720 | + $alt_text = $matches[2]; |
|
| 721 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 722 | + $title = & $matches[7]; |
|
| 723 | 723 | |
| 724 | 724 | $alt_text = $this->encodeAttribute($alt_text); |
| 725 | 725 | $url = $this->encodeAttribute($url); |
| 726 | 726 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
| 727 | 727 | if (isset($title)) { |
| 728 | 728 | $title = $this->encodeAttribute($title); |
| 729 | - $result .= " title=\"$title\""; # $title already quoted |
|
| 729 | + $result .= " title=\"$title\""; # $title already quoted |
|
| 730 | 730 | } |
| 731 | 731 | $result .= $this->empty_element_suffix; |
| 732 | 732 | |
@@ -770,12 +770,12 @@ discard block |
||
| 770 | 770 | return $matches[0]; |
| 771 | 771 | |
| 772 | 772 | $level = $matches[2]{0} == '=' ? 1 : 2; |
| 773 | - $block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
| 773 | + $block = "<h$level>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
| 774 | 774 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 775 | 775 | } |
| 776 | 776 | protected function _doHeaders_callback_atx($matches) { |
| 777 | 777 | $level = strlen($matches[1]); |
| 778 | - $block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
| 778 | + $block = "<h$level>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
| 779 | 779 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -801,8 +801,8 @@ discard block |
||
| 801 | 801 | $whole_list_re = ' |
| 802 | 802 | ( # $1 = whole list |
| 803 | 803 | ( # $2 |
| 804 | - ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces |
|
| 805 | - ('.$marker_re.') # $4 = first list item marker |
|
| 804 | + ([ ]{0,'.$less_than_tab . '}) # $3 = number of spaces |
|
| 805 | + ('.$marker_re . ') # $4 = first list item marker |
|
| 806 | 806 | [ ]+ |
| 807 | 807 | ) |
| 808 | 808 | (?s:.+?) |
@@ -813,13 +813,13 @@ discard block |
||
| 813 | 813 | (?=\S) |
| 814 | 814 | (?! # Negative lookahead for another list item marker |
| 815 | 815 | [ ]* |
| 816 | - '.$marker_re.'[ ]+ |
|
| 816 | + '.$marker_re . '[ ]+ |
|
| 817 | 817 | ) |
| 818 | 818 | | |
| 819 | 819 | (?= # Lookahead for another kind of list |
| 820 | 820 | \n |
| 821 | 821 | \3 # Must have the same indentation |
| 822 | - '.$other_marker_re.'[ ]+ |
|
| 822 | + '.$other_marker_re . '[ ]+ |
|
| 823 | 823 | ) |
| 824 | 824 | ) |
| 825 | 825 | ) |
@@ -831,14 +831,14 @@ discard block |
||
| 831 | 831 | if ($this->list_level) { |
| 832 | 832 | $text = preg_replace_callback('{ |
| 833 | 833 | ^ |
| 834 | - '.$whole_list_re.' |
|
| 834 | + '.$whole_list_re . ' |
|
| 835 | 835 | }mx', |
| 836 | 836 | array(&$this, '_doLists_callback'), $text); |
| 837 | 837 | } |
| 838 | 838 | else { |
| 839 | 839 | $text = preg_replace_callback('{ |
| 840 | 840 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
| 841 | - '.$whole_list_re.' |
|
| 841 | + '.$whole_list_re . ' |
|
| 842 | 842 | }mx', |
| 843 | 843 | array(&$this, '_doLists_callback'), $text); |
| 844 | 844 | } |
@@ -855,13 +855,13 @@ discard block |
||
| 855 | 855 | $list = $matches[1]; |
| 856 | 856 | $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol"; |
| 857 | 857 | |
| 858 | - $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re ); |
|
| 858 | + $marker_any_re = ($list_type == "ul" ? $marker_ul_re : $marker_ol_re); |
|
| 859 | 859 | |
| 860 | 860 | $list .= "\n"; |
| 861 | 861 | $result = $this->processListItems($list, $marker_any_re); |
| 862 | 862 | |
| 863 | 863 | $result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>"); |
| 864 | - return "\n". $result ."\n\n"; |
|
| 864 | + return "\n" . $result . "\n\n"; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | protected $list_level = 0; |
@@ -900,12 +900,12 @@ discard block |
||
| 900 | 900 | $list_str = preg_replace_callback('{ |
| 901 | 901 | (\n)? # leading line = $1 |
| 902 | 902 | (^[ ]*) # leading whitespace = $2 |
| 903 | - ('.$marker_any_re.' # list marker and space = $3 |
|
| 903 | + ('.$marker_any_re . ' # list marker and space = $3 |
|
| 904 | 904 | (?:[ ]+|(?=\n)) # space only required if item is not empty |
| 905 | 905 | ) |
| 906 | 906 | ((?s:.*?)) # list item text = $4 |
| 907 | 907 | (?:(\n+(?=\n))|\n) # tailing blank line = $5 |
| 908 | - (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n)))) |
|
| 908 | + (?= \n* (\z | \2 ('.$marker_any_re . ') (?:[ ]+|(?=\n)))) |
|
| 909 | 909 | }xm', |
| 910 | 910 | array(&$this, '_processListItems_callback'), $list_str); |
| 911 | 911 | |
@@ -914,17 +914,17 @@ discard block |
||
| 914 | 914 | } |
| 915 | 915 | protected function _processListItems_callback($matches) { |
| 916 | 916 | $item = $matches[4]; |
| 917 | - $leading_line =& $matches[1]; |
|
| 918 | - $leading_space =& $matches[2]; |
|
| 917 | + $leading_line = & $matches[1]; |
|
| 918 | + $leading_space = & $matches[2]; |
|
| 919 | 919 | $marker_space = $matches[3]; |
| 920 | - $tailing_blank_line =& $matches[5]; |
|
| 920 | + $tailing_blank_line = & $matches[5]; |
|
| 921 | 921 | |
| 922 | 922 | if ($leading_line || $tailing_blank_line || |
| 923 | 923 | preg_match('/\n{2,}/', $item)) |
| 924 | 924 | { |
| 925 | 925 | # Replace marker with the appropriate whitespace indentation |
| 926 | 926 | $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
| 927 | - $item = $this->runBlockGamut($this->outdent($item)."\n"); |
|
| 927 | + $item = $this->runBlockGamut($this->outdent($item) . "\n"); |
|
| 928 | 928 | } |
| 929 | 929 | else { |
| 930 | 930 | # Recursion for sub-lists: |
@@ -945,11 +945,11 @@ discard block |
||
| 945 | 945 | (?:\n\n|\A\n?) |
| 946 | 946 | ( # $1 = the code block -- one or more lines, starting with a space/tab |
| 947 | 947 | (?> |
| 948 | - [ ]{'.$this->tab_width.'} # Lines must start with a tab or a tab-width of spaces |
|
| 948 | + [ ]{'.$this->tab_width . '} # Lines must start with a tab or a tab-width of spaces |
|
| 949 | 949 | .*\n+ |
| 950 | 950 | )+ |
| 951 | 951 | ) |
| 952 | - ((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
| 952 | + ((?=^[ ]{0,'.$this->tab_width . '}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
| 953 | 953 | }xm', |
| 954 | 954 | array(&$this, '_doCodeBlocks_callback'), $text); |
| 955 | 955 | |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | $codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock); |
| 966 | 966 | |
| 967 | 967 | $codeblock = "<pre><code>$codeblock\n</code></pre>"; |
| 968 | - return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
| 968 | + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | $token_relist[] = $strong_re; |
| 1012 | 1012 | |
| 1013 | 1013 | # Construct master expression from list. |
| 1014 | - $token_re = '{('. implode('|', $token_relist) .')}'; |
|
| 1014 | + $token_re = '{(' . implode('|', $token_relist) . ')}'; |
|
| 1015 | 1015 | $this->em_strong_prepared_relist["$em$strong"] = $token_re; |
| 1016 | 1016 | } |
| 1017 | 1017 | } |
@@ -1037,8 +1037,8 @@ discard block |
||
| 1037 | 1037 | # |
| 1038 | 1038 | $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); |
| 1039 | 1039 | $text_stack[0] .= $parts[0]; |
| 1040 | - $token =& $parts[1]; |
|
| 1041 | - $text =& $parts[2]; |
|
| 1040 | + $token = & $parts[1]; |
|
| 1041 | + $text = & $parts[2]; |
|
| 1042 | 1042 | |
| 1043 | 1043 | if (empty($token)) { |
| 1044 | 1044 | # Reached end of text span: empty stack without emitting. |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | } else { |
| 1066 | 1066 | # Other closing marker: close one em or strong and |
| 1067 | 1067 | # change current token state to match the other |
| 1068 | - $token_stack[0] = str_repeat($token{0}, 3-$token_len); |
|
| 1068 | + $token_stack[0] = str_repeat($token{0}, 3 - $token_len); |
|
| 1069 | 1069 | $tag = $token_len == 2 ? "strong" : "em"; |
| 1070 | 1070 | $span = $text_stack[0]; |
| 1071 | 1071 | $span = $this->runSpanGamut($span); |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | $bq = $matches[1]; |
| 1160 | 1160 | # trim one level of quoting - trim whitespace-only lines |
| 1161 | 1161 | $bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq); |
| 1162 | - $bq = $this->runBlockGamut($bq); # recurse |
|
| 1162 | + $bq = $this->runBlockGamut($bq); # recurse |
|
| 1163 | 1163 | |
| 1164 | 1164 | $bq = preg_replace('/^/m', " ", $bq); |
| 1165 | 1165 | # These leading spaces cause problem with <pre> content, |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | $bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx', |
| 1168 | 1168 | array(&$this, '_doBlockQuotes_callback2'), $bq); |
| 1169 | 1169 | |
| 1170 | - return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n"; |
|
| 1170 | + return "\n" . $this->hashBlock("<blockquote>\n$bq\n</blockquote>") . "\n\n"; |
|
| 1171 | 1171 | } |
| 1172 | 1172 | protected function _doBlockQuotes_callback2($matches) { |
| 1173 | 1173 | $pre = $matches[1]; |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | > |
| 1303 | 1303 | }xi', |
| 1304 | 1304 | array(&$this, '_doAutoLinks_email_callback'), $text); |
| 1305 | - $text = preg_replace_callback('{<(tel:([^\'">\s]+))>}i',array(&$this, '_doAutoLinks_tel_callback'), $text); |
|
| 1305 | + $text = preg_replace_callback('{<(tel:([^\'">\s]+))>}i', array(&$this, '_doAutoLinks_tel_callback'), $text); |
|
| 1306 | 1306 | |
| 1307 | 1307 | return $text; |
| 1308 | 1308 | } |
@@ -1342,7 +1342,7 @@ discard block |
||
| 1342 | 1342 | # |
| 1343 | 1343 | $addr = "mailto:" . $addr; |
| 1344 | 1344 | $chars = preg_split('/(?<!^)(?!$)/', $addr); |
| 1345 | - $seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed. |
|
| 1345 | + $seed = (int) abs(crc32($addr) / strlen($addr)); # Deterministic seed. |
|
| 1346 | 1346 | |
| 1347 | 1347 | foreach ($chars as $key => $char) { |
| 1348 | 1348 | $ord = ord($char); |
@@ -1352,8 +1352,8 @@ discard block |
||
| 1352 | 1352 | # roughly 10% raw, 45% hex, 45% dec |
| 1353 | 1353 | # '@' *must* be encoded. I insist. |
| 1354 | 1354 | if ($r > 90 && $char != '@') /* do nothing */; |
| 1355 | - else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1356 | - else $chars[$key] = '&#'.$ord.';'; |
|
| 1355 | + else if ($r < 45) $chars[$key] = '&#x' . dechex($ord) . ';'; |
|
| 1356 | + else $chars[$key] = '&#' . $ord . ';'; |
|
| 1357 | 1357 | } |
| 1358 | 1358 | } |
| 1359 | 1359 | |
@@ -1374,11 +1374,11 @@ discard block |
||
| 1374 | 1374 | |
| 1375 | 1375 | $span_re = '{ |
| 1376 | 1376 | ( |
| 1377 | - \\\\'.$this->escape_chars_re.' |
|
| 1377 | + \\\\'.$this->escape_chars_re . ' |
|
| 1378 | 1378 | | |
| 1379 | 1379 | (?<![`\\\\]) |
| 1380 | 1380 | `+ # code span marker |
| 1381 | - '.( $this->no_markup ? '' : ' |
|
| 1381 | + '.($this->no_markup ? '' : ' |
|
| 1382 | 1382 | | |
| 1383 | 1383 | <!-- .*? --> # comment |
| 1384 | 1384 | | |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | <[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag |
| 1395 | 1395 | | |
| 1396 | 1396 | </[-a-zA-Z0-9:_]+\s*> # closing tag |
| 1397 | - ').' |
|
| 1397 | + ') . ' |
|
| 1398 | 1398 | ) |
| 1399 | 1399 | }xs'; |
| 1400 | 1400 | |
@@ -1432,10 +1432,10 @@ discard block |
||
| 1432 | 1432 | # |
| 1433 | 1433 | switch ($token{0}) { |
| 1434 | 1434 | case "\\": |
| 1435 | - return $this->hashPart("&#". ord($token{1}). ";"); |
|
| 1435 | + return $this->hashPart("&#" . ord($token{1}) . ";"); |
|
| 1436 | 1436 | case "`": |
| 1437 | 1437 | # Search for end marker in remaining text. |
| 1438 | - if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', |
|
| 1438 | + if (preg_match('/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm', |
|
| 1439 | 1439 | $str, $matches)) |
| 1440 | 1440 | { |
| 1441 | 1441 | $str = $matches[2]; |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | # |
| 1454 | 1454 | # Remove one level of line-leading tabs or spaces |
| 1455 | 1455 | # |
| 1456 | - return preg_replace('/^(\t|[ ]{1,'.$this->tab_width.'})/m', '', $text); |
|
| 1456 | + return preg_replace('/^(\t|[ ]{1,' . $this->tab_width . '})/m', '', $text); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | 1459 | |
@@ -1676,10 +1676,10 @@ discard block |
||
| 1676 | 1676 | # compose attributes as string |
| 1677 | 1677 | $attr_str = ""; |
| 1678 | 1678 | if (!empty($id)) { |
| 1679 | - $attr_str .= ' id="'.$id.'"'; |
|
| 1679 | + $attr_str .= ' id="' . $id . '"'; |
|
| 1680 | 1680 | } |
| 1681 | 1681 | if (!empty($classes)) { |
| 1682 | - $attr_str .= ' class="'.implode(" ", $classes).'"'; |
|
| 1682 | + $attr_str .= ' class="' . implode(" ", $classes) . '"'; |
|
| 1683 | 1683 | } |
| 1684 | 1684 | return $attr_str; |
| 1685 | 1685 | } |
@@ -1694,7 +1694,7 @@ discard block |
||
| 1694 | 1694 | |
| 1695 | 1695 | # Link defs are in the form: ^[id]: url "optional title" |
| 1696 | 1696 | $text = preg_replace_callback('{ |
| 1697 | - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 1697 | + ^[ ]{0,'.$less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
| 1698 | 1698 | [ ]* |
| 1699 | 1699 | \n? # maybe *one* newline |
| 1700 | 1700 | [ ]* |
@@ -1713,7 +1713,7 @@ discard block |
||
| 1713 | 1713 | [")] |
| 1714 | 1714 | [ ]* |
| 1715 | 1715 | )? # title is optional |
| 1716 | - (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
| 1716 | + (?:[ ]* '.$this->id_class_attr_catch_re . ' )? # $5 = extra id & class attr |
|
| 1717 | 1717 | (?:\n+|\Z) |
| 1718 | 1718 | }xm', |
| 1719 | 1719 | array(&$this, '_stripLinkDefinitions_callback'), |
@@ -1724,8 +1724,8 @@ discard block |
||
| 1724 | 1724 | $link_id = strtolower($matches[1]); |
| 1725 | 1725 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
| 1726 | 1726 | $this->urls[$link_id] = $url; |
| 1727 | - $this->titles[$link_id] =& $matches[4]; |
|
| 1728 | - $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]); |
|
| 1727 | + $this->titles[$link_id] = & $matches[4]; |
|
| 1728 | + $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]); |
|
| 1729 | 1729 | return ''; # String that will replace the block |
| 1730 | 1730 | } |
| 1731 | 1731 | |
@@ -1770,7 +1770,7 @@ discard block |
||
| 1770 | 1770 | # |
| 1771 | 1771 | # Call the HTML-in-Markdown hasher. |
| 1772 | 1772 | # |
| 1773 | - list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 1773 | + list($text,) = $this->_hashHTMLBlocks_inMarkdown($text); |
|
| 1774 | 1774 | |
| 1775 | 1775 | return $text; |
| 1776 | 1776 | } |
@@ -1819,10 +1819,10 @@ discard block |
||
| 1819 | 1819 | ( # $2: Capture whole tag. |
| 1820 | 1820 | </? # Any opening or closing tag. |
| 1821 | 1821 | (?> # Tag name. |
| 1822 | - '.$this->block_tags_re.' | |
|
| 1823 | - '.$this->context_block_tags_re.' | |
|
| 1824 | - '.$this->clean_tags_re.' | |
|
| 1825 | - (?!\s)'.$enclosing_tag_re.' |
|
| 1822 | + '.$this->block_tags_re . ' | |
|
| 1823 | + '.$this->context_block_tags_re . ' | |
|
| 1824 | + '.$this->clean_tags_re . ' | |
|
| 1825 | + (?!\s)'.$enclosing_tag_re . ' |
|
| 1826 | 1826 | ) |
| 1827 | 1827 | (?: |
| 1828 | 1828 | (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name. |
@@ -1839,27 +1839,27 @@ discard block |
||
| 1839 | 1839 | <\?.*?\?> | <%.*?%> # Processing instruction |
| 1840 | 1840 | | |
| 1841 | 1841 | <!\[CDATA\[.*?\]\]> # CData Block |
| 1842 | - '. ( !$span ? ' # If not in span. |
|
| 1842 | + '. (!$span ? ' # If not in span. |
|
| 1843 | 1843 | | |
| 1844 | 1844 | # Indented code block |
| 1845 | 1845 | (?: ^[ ]*\n | ^ | \n[ ]*\n ) |
| 1846 | - [ ]{'.($indent+4).'}[^\n]* \n |
|
| 1846 | + [ ]{'.($indent + 4) . '}[^\n]* \n |
|
| 1847 | 1847 | (?> |
| 1848 | - (?: [ ]{'.($indent+4).'}[^\n]* | [ ]* ) \n |
|
| 1848 | + (?: [ ]{'.($indent + 4) . '}[^\n]* | [ ]* ) \n |
|
| 1849 | 1849 | )* |
| 1850 | 1850 | | |
| 1851 | 1851 | # Fenced code block marker |
| 1852 | 1852 | (?<= ^ | \n ) |
| 1853 | - [ ]{0,'.($indent+3).'}(?:~{3,}|`{3,}) |
|
| 1853 | + [ ]{0,'.($indent + 3) . '}(?:~{3,}|`{3,}) |
|
| 1854 | 1854 | [ ]* |
| 1855 | 1855 | (?: |
| 1856 | 1856 | \.?[-_:a-zA-Z0-9]+ # standalone class name |
| 1857 | 1857 | | |
| 1858 | - '.$this->id_class_attr_nocatch_re.' # extra attributes |
|
| 1858 | + '.$this->id_class_attr_nocatch_re . ' # extra attributes |
|
| 1859 | 1859 | )? |
| 1860 | 1860 | [ ]* |
| 1861 | 1861 | (?= \n ) |
| 1862 | - ' : '' ). ' # End (if not is span). |
|
| 1862 | + ' : '') . ' # End (if not is span). |
|
| 1863 | 1863 | | |
| 1864 | 1864 | # Code span marker |
| 1865 | 1865 | # Note, this regex needs to go after backtick fenced |
@@ -1870,8 +1870,8 @@ discard block |
||
| 1870 | 1870 | }xs'; |
| 1871 | 1871 | |
| 1872 | 1872 | |
| 1873 | - $depth = 0; # Current depth inside the tag tree. |
|
| 1874 | - $parsed = ""; # Parsed text that will be returned. |
|
| 1873 | + $depth = 0; # Current depth inside the tag tree. |
|
| 1874 | + $parsed = ""; # Parsed text that will be returned. |
|
| 1875 | 1875 | |
| 1876 | 1876 | # |
| 1877 | 1877 | # Loop through every tag until we find the closing tag of the parent |
@@ -1912,11 +1912,11 @@ discard block |
||
| 1912 | 1912 | # Note: need to recheck the whole tag to disambiguate backtick |
| 1913 | 1913 | # fences from code spans |
| 1914 | 1914 | # |
| 1915 | - if (preg_match('{^\n?([ ]{0,'.($indent+3).'})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+|'.$this->id_class_attr_nocatch_re.')?[ ]*\n?$}', $tag, $capture)) { |
|
| 1915 | + if (preg_match('{^\n?([ ]{0,' . ($indent + 3) . '})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+|' . $this->id_class_attr_nocatch_re . ')?[ ]*\n?$}', $tag, $capture)) { |
|
| 1916 | 1916 | # Fenced code block marker: find matching end marker. |
| 1917 | 1917 | $fence_indent = strlen($capture[1]); # use captured indent in re |
| 1918 | 1918 | $fence_re = $capture[2]; # use captured fence in re |
| 1919 | - if (preg_match('{^(?>.*\n)*?[ ]{'.($fence_indent).'}'.$fence_re.'[ ]*(?:\n|$)}', $text, |
|
| 1919 | + if (preg_match('{^(?>.*\n)*?[ ]{' . ($fence_indent) . '}' . $fence_re . '[ ]*(?:\n|$)}', $text, |
|
| 1920 | 1920 | $matches)) |
| 1921 | 1921 | { |
| 1922 | 1922 | # End marker found: pass text unchanged until marker. |
@@ -1943,7 +1943,7 @@ discard block |
||
| 1943 | 1943 | else if ($tag{0} == "`") { |
| 1944 | 1944 | # Find corresponding end marker. |
| 1945 | 1945 | $tag_re = preg_quote($tag); |
| 1946 | - if (preg_match('{^(?>.+?|\n(?!\n))*?(?<!`)'.$tag_re.'(?!`)}', |
|
| 1946 | + if (preg_match('{^(?>.+?|\n(?!\n))*?(?<!`)' . $tag_re . '(?!`)}', |
|
| 1947 | 1947 | $text, $matches)) |
| 1948 | 1948 | { |
| 1949 | 1949 | # End marker found: pass text unchanged until marker. |
@@ -1960,10 +1960,10 @@ discard block |
||
| 1960 | 1960 | # Opening Context Block tag (like ins and del) |
| 1961 | 1961 | # used as a block tag (tag is alone on it's line). |
| 1962 | 1962 | # |
| 1963 | - else if (preg_match('{^<(?:'.$this->block_tags_re.')\b}', $tag) || |
|
| 1964 | - ( preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) && |
|
| 1963 | + else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) || |
|
| 1964 | + (preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
| 1965 | 1965 | preg_match($newline_before_re, $parsed) && |
| 1966 | - preg_match($newline_after_re, $text) ) |
|
| 1966 | + preg_match($newline_after_re, $text)) |
|
| 1967 | 1967 | ) |
| 1968 | 1968 | { |
| 1969 | 1969 | # Need to parse tag and following text using the HTML parser. |
@@ -1977,7 +1977,7 @@ discard block |
||
| 1977 | 1977 | # Check for: Clean tag (like script, math) |
| 1978 | 1978 | # HTML Comments, processing instructions. |
| 1979 | 1979 | # |
| 1980 | - else if (preg_match('{^<(?:'.$this->clean_tags_re.')\b}', $tag) || |
|
| 1980 | + else if (preg_match('{^<(?:' . $this->clean_tags_re . ')\b}', $tag) || |
|
| 1981 | 1981 | $tag{1} == '!' || $tag{1} == '?') |
| 1982 | 1982 | { |
| 1983 | 1983 | # Need to parse tag and following text using the HTML parser. |
@@ -1992,13 +1992,13 @@ discard block |
||
| 1992 | 1992 | # |
| 1993 | 1993 | else if ($enclosing_tag_re !== '' && |
| 1994 | 1994 | # Same name as enclosing tag. |
| 1995 | - preg_match('{^</?(?:'.$enclosing_tag_re.')\b}', $tag)) |
|
| 1995 | + preg_match('{^</?(?:' . $enclosing_tag_re . ')\b}', $tag)) |
|
| 1996 | 1996 | { |
| 1997 | 1997 | # |
| 1998 | 1998 | # Increase/decrease nested tag count. |
| 1999 | 1999 | # |
| 2000 | 2000 | if ($tag{1} == '/') $depth--; |
| 2001 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 2001 | + else if ($tag{strlen($tag) - 2} != '/') $depth++; |
|
| 2002 | 2002 | |
| 2003 | 2003 | if ($depth < 0) { |
| 2004 | 2004 | # |
@@ -2070,11 +2070,11 @@ discard block |
||
| 2070 | 2070 | ) |
| 2071 | 2071 | }xs'; |
| 2072 | 2072 | |
| 2073 | - $original_text = $text; # Save original text in case of faliure. |
|
| 2073 | + $original_text = $text; # Save original text in case of faliure. |
|
| 2074 | 2074 | |
| 2075 | - $depth = 0; # Current depth inside the tag tree. |
|
| 2076 | - $block_text = ""; # Temporary text holder for current text. |
|
| 2077 | - $parsed = ""; # Parsed text that will be returned. |
|
| 2075 | + $depth = 0; # Current depth inside the tag tree. |
|
| 2076 | + $block_text = ""; # Temporary text holder for current text. |
|
| 2077 | + $parsed = ""; # Parsed text that will be returned. |
|
| 2078 | 2078 | |
| 2079 | 2079 | # |
| 2080 | 2080 | # Get the name of the starting tag. |
@@ -2113,7 +2113,7 @@ discard block |
||
| 2113 | 2113 | # Check for: Auto-close tag (like <hr/>) |
| 2114 | 2114 | # Comments and Processing Instructions. |
| 2115 | 2115 | # |
| 2116 | - if (preg_match('{^</?(?:'.$this->auto_close_tags_re.')\b}', $tag) || |
|
| 2116 | + if (preg_match('{^</?(?:' . $this->auto_close_tags_re . ')\b}', $tag) || |
|
| 2117 | 2117 | $tag{1} == '!' || $tag{1} == '?') |
| 2118 | 2118 | { |
| 2119 | 2119 | # Just add the tag to the block as if it was text. |
@@ -2124,9 +2124,9 @@ discard block |
||
| 2124 | 2124 | # Increase/decrease nested tag count. Only do so if |
| 2125 | 2125 | # the tag's name match base tag's. |
| 2126 | 2126 | # |
| 2127 | - if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) { |
|
| 2127 | + if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
|
| 2128 | 2128 | if ($tag{1} == '/') $depth--; |
| 2129 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 2129 | + else if ($tag{strlen($tag) - 2} != '/') $depth++; |
|
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | 2132 | # |
@@ -2142,7 +2142,7 @@ discard block |
||
| 2142 | 2142 | # Check if text inside this tag must be parsed in span mode. |
| 2143 | 2143 | $this->mode = $attr_m[2] . $attr_m[3]; |
| 2144 | 2144 | $span_mode = $this->mode == 'span' || $this->mode != 'block' && |
| 2145 | - preg_match('{^<(?:'.$this->contain_span_tags_re.')\b}', $tag); |
|
| 2145 | + preg_match('{^<(?:' . $this->contain_span_tags_re . ')\b}', $tag); |
|
| 2146 | 2146 | |
| 2147 | 2147 | # Calculate indent before tag. |
| 2148 | 2148 | if (preg_match('/(?:^|\n)( *?)(?! ).*?$/', $block_text, $matches)) { |
@@ -2216,7 +2216,7 @@ discard block |
||
| 2216 | 2216 | $text = preg_replace_callback('{ |
| 2217 | 2217 | ( # wrap whole match in $1 |
| 2218 | 2218 | \[ |
| 2219 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 2219 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 2220 | 2220 | \] |
| 2221 | 2221 | |
| 2222 | 2222 | [ ]? # one optional space |
@@ -2235,14 +2235,14 @@ discard block |
||
| 2235 | 2235 | $text = preg_replace_callback('{ |
| 2236 | 2236 | ( # wrap whole match in $1 |
| 2237 | 2237 | \[ |
| 2238 | - ('.$this->nested_brackets_re.') # link text = $2 |
|
| 2238 | + ('.$this->nested_brackets_re . ') # link text = $2 |
|
| 2239 | 2239 | \] |
| 2240 | 2240 | \( # literal paren |
| 2241 | 2241 | [ \n]* |
| 2242 | 2242 | (?: |
| 2243 | 2243 | <(.+?)> # href = $3 |
| 2244 | 2244 | | |
| 2245 | - ('.$this->nested_url_parenthesis_re.') # href = $4 |
|
| 2245 | + ('.$this->nested_url_parenthesis_re . ') # href = $4 |
|
| 2246 | 2246 | ) |
| 2247 | 2247 | [ \n]* |
| 2248 | 2248 | ( # $5 |
@@ -2252,7 +2252,7 @@ discard block |
||
| 2252 | 2252 | [ \n]* # ignore any spaces/tabs between closing quote and ) |
| 2253 | 2253 | )? # title is optional |
| 2254 | 2254 | \) |
| 2255 | - (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes |
|
| 2255 | + (?:[ ]? '.$this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
| 2256 | 2256 | ) |
| 2257 | 2257 | }xs', |
| 2258 | 2258 | array(&$this, '_doAnchors_inline_callback'), $text); |
@@ -2275,9 +2275,9 @@ discard block |
||
| 2275 | 2275 | return $text; |
| 2276 | 2276 | } |
| 2277 | 2277 | protected function _doAnchors_reference_callback($matches) { |
| 2278 | - $whole_match = $matches[1]; |
|
| 2279 | - $link_text = $matches[2]; |
|
| 2280 | - $link_id =& $matches[3]; |
|
| 2278 | + $whole_match = $matches[1]; |
|
| 2279 | + $link_text = $matches[2]; |
|
| 2280 | + $link_id = & $matches[3]; |
|
| 2281 | 2281 | |
| 2282 | 2282 | if ($link_id == "") { |
| 2283 | 2283 | # for shortcut links like [this][] or [this]. |
@@ -2293,10 +2293,10 @@ discard block |
||
| 2293 | 2293 | $url = $this->encodeAttribute($url); |
| 2294 | 2294 | |
| 2295 | 2295 | $result = "<a href=\"$url\""; |
| 2296 | - if ( isset( $this->titles[$link_id] ) ) { |
|
| 2296 | + if (isset($this->titles[$link_id])) { |
|
| 2297 | 2297 | $title = $this->titles[$link_id]; |
| 2298 | 2298 | $title = $this->encodeAttribute($title); |
| 2299 | - $result .= " title=\"$title\""; |
|
| 2299 | + $result .= " title=\"$title\""; |
|
| 2300 | 2300 | } |
| 2301 | 2301 | if (isset($this->ref_attr[$link_id])) |
| 2302 | 2302 | $result .= $this->ref_attr[$link_id]; |
@@ -2311,11 +2311,11 @@ discard block |
||
| 2311 | 2311 | return $result; |
| 2312 | 2312 | } |
| 2313 | 2313 | protected function _doAnchors_inline_callback($matches) { |
| 2314 | - $whole_match = $matches[1]; |
|
| 2315 | - $link_text = $this->runSpanGamut($matches[2]); |
|
| 2316 | - $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 2317 | - $title =& $matches[7]; |
|
| 2318 | - $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]); |
|
| 2314 | + $whole_match = $matches[1]; |
|
| 2315 | + $link_text = $this->runSpanGamut($matches[2]); |
|
| 2316 | + $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
|
| 2317 | + $title = & $matches[7]; |
|
| 2318 | + $attr = $this->doExtraAttributes("a", $dummy = & $matches[8]); |
|
| 2319 | 2319 | |
| 2320 | 2320 | |
| 2321 | 2321 | $url = $this->encodeAttribute($url); |
@@ -2323,7 +2323,7 @@ discard block |
||
| 2323 | 2323 | $result = "<a href=\"$url\""; |
| 2324 | 2324 | if (isset($title)) { |
| 2325 | 2325 | $title = $this->encodeAttribute($title); |
| 2326 | - $result .= " title=\"$title\""; |
|
| 2326 | + $result .= " title=\"$title\""; |
|
| 2327 | 2327 | } |
| 2328 | 2328 | $result .= $attr; |
| 2329 | 2329 | |
@@ -2344,7 +2344,7 @@ discard block |
||
| 2344 | 2344 | $text = preg_replace_callback('{ |
| 2345 | 2345 | ( # wrap whole match in $1 |
| 2346 | 2346 | !\[ |
| 2347 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 2347 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 2348 | 2348 | \] |
| 2349 | 2349 | |
| 2350 | 2350 | [ ]? # one optional space |
@@ -2365,7 +2365,7 @@ discard block |
||
| 2365 | 2365 | $text = preg_replace_callback('{ |
| 2366 | 2366 | ( # wrap whole match in $1 |
| 2367 | 2367 | !\[ |
| 2368 | - ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 2368 | + ('.$this->nested_brackets_re . ') # alt text = $2 |
|
| 2369 | 2369 | \] |
| 2370 | 2370 | \s? # One optional whitespace character |
| 2371 | 2371 | \( # literal paren |
@@ -2373,7 +2373,7 @@ discard block |
||
| 2373 | 2373 | (?: |
| 2374 | 2374 | <(\S*)> # src url = $3 |
| 2375 | 2375 | | |
| 2376 | - ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 2376 | + ('.$this->nested_url_parenthesis_re . ') # src url = $4 |
|
| 2377 | 2377 | ) |
| 2378 | 2378 | [ \n]* |
| 2379 | 2379 | ( # $5 |
@@ -2383,7 +2383,7 @@ discard block |
||
| 2383 | 2383 | [ \n]* |
| 2384 | 2384 | )? # title is optional |
| 2385 | 2385 | \) |
| 2386 | - (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes |
|
| 2386 | + (?:[ ]? '.$this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
| 2387 | 2387 | ) |
| 2388 | 2388 | }xs', |
| 2389 | 2389 | array(&$this, '_doImages_inline_callback'), $text); |
@@ -2406,7 +2406,7 @@ discard block |
||
| 2406 | 2406 | if (isset($this->titles[$link_id])) { |
| 2407 | 2407 | $title = $this->titles[$link_id]; |
| 2408 | 2408 | $title = $this->encodeAttribute($title); |
| 2409 | - $result .= " title=\"$title\""; |
|
| 2409 | + $result .= " title=\"$title\""; |
|
| 2410 | 2410 | } |
| 2411 | 2411 | if (isset($this->ref_attr[$link_id])) |
| 2412 | 2412 | $result .= $this->ref_attr[$link_id]; |
@@ -2421,18 +2421,18 @@ discard block |
||
| 2421 | 2421 | return $result; |
| 2422 | 2422 | } |
| 2423 | 2423 | protected function _doImages_inline_callback($matches) { |
| 2424 | - $whole_match = $matches[1]; |
|
| 2425 | - $alt_text = $matches[2]; |
|
| 2424 | + $whole_match = $matches[1]; |
|
| 2425 | + $alt_text = $matches[2]; |
|
| 2426 | 2426 | $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
| 2427 | - $title =& $matches[7]; |
|
| 2428 | - $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); |
|
| 2427 | + $title = & $matches[7]; |
|
| 2428 | + $attr = $this->doExtraAttributes("img", $dummy = & $matches[8]); |
|
| 2429 | 2429 | |
| 2430 | 2430 | $alt_text = $this->encodeAttribute($alt_text); |
| 2431 | 2431 | $url = $this->encodeAttribute($url); |
| 2432 | 2432 | $result = "<img src=\"$url\" alt=\"$alt_text\""; |
| 2433 | 2433 | if (isset($title)) { |
| 2434 | 2434 | $title = $this->encodeAttribute($title); |
| 2435 | - $result .= " title=\"$title\""; # $title already quoted |
|
| 2435 | + $result .= " title=\"$title\""; # $title already quoted |
|
| 2436 | 2436 | } |
| 2437 | 2437 | $result .= $attr; |
| 2438 | 2438 | $result .= $this->empty_element_suffix; |
@@ -2455,7 +2455,7 @@ discard block |
||
| 2455 | 2455 | $text = preg_replace_callback( |
| 2456 | 2456 | '{ |
| 2457 | 2457 | (^.+?) # $1: Header text |
| 2458 | - (?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes |
|
| 2458 | + (?:[ ]+ '.$this->id_class_attr_catch_re . ' )? # $3 = id/class attributes |
|
| 2459 | 2459 | [ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer |
| 2460 | 2460 | }mx', |
| 2461 | 2461 | array(&$this, '_doHeaders_callback_setext'), $text); |
@@ -2473,7 +2473,7 @@ discard block |
||
| 2473 | 2473 | (.+?) # $2 = Header text |
| 2474 | 2474 | [ ]* |
| 2475 | 2475 | \#* # optional closing #\'s (not counted) |
| 2476 | - (?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes |
|
| 2476 | + (?:[ ]+ '.$this->id_class_attr_catch_re . ' )? # $3 = id/class attributes |
|
| 2477 | 2477 | [ ]* |
| 2478 | 2478 | \n+ |
| 2479 | 2479 | }xm', |
@@ -2485,14 +2485,14 @@ discard block |
||
| 2485 | 2485 | if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) |
| 2486 | 2486 | return $matches[0]; |
| 2487 | 2487 | $level = $matches[3]{0} == '=' ? 1 : 2; |
| 2488 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2]); |
|
| 2489 | - $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
| 2488 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[2]); |
|
| 2489 | + $block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
| 2490 | 2490 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 2491 | 2491 | } |
| 2492 | 2492 | protected function _doHeaders_callback_atx($matches) { |
| 2493 | 2493 | $level = strlen($matches[1]); |
| 2494 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3]); |
|
| 2495 | - $block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
| 2494 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[3]); |
|
| 2495 | + $block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
| 2496 | 2496 | return "\n" . $this->hashBlock($block) . "\n\n"; |
| 2497 | 2497 | } |
| 2498 | 2498 | |
@@ -2513,11 +2513,11 @@ discard block |
||
| 2513 | 2513 | $text = preg_replace_callback(' |
| 2514 | 2514 | { |
| 2515 | 2515 | ^ # Start of a line |
| 2516 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 2516 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 2517 | 2517 | [|] # Optional leading pipe (present) |
| 2518 | 2518 | (.+) \n # $1: Header row (at least one pipe) |
| 2519 | 2519 | |
| 2520 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 2520 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 2521 | 2521 | [|] ([ ]*[-:]+[-| :]*) \n # $2: Header underline |
| 2522 | 2522 | |
| 2523 | 2523 | ( # $3: Cells |
@@ -2541,10 +2541,10 @@ discard block |
||
| 2541 | 2541 | $text = preg_replace_callback(' |
| 2542 | 2542 | { |
| 2543 | 2543 | ^ # Start of a line |
| 2544 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 2544 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 2545 | 2545 | (\S.*[|].*) \n # $1: Header row (at least one pipe) |
| 2546 | 2546 | |
| 2547 | - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. |
|
| 2547 | + [ ]{0,'.$less_than_tab . '} # Allowed whitespace. |
|
| 2548 | 2548 | ([-:]+[ ]*[|][-| :]*) \n # $2: Header underline |
| 2549 | 2549 | |
| 2550 | 2550 | ( # $3: Cells |
@@ -2559,8 +2559,8 @@ discard block |
||
| 2559 | 2559 | return $text; |
| 2560 | 2560 | } |
| 2561 | 2561 | protected function _doTable_leadingPipe_callback($matches) { |
| 2562 | - $head = $matches[1]; |
|
| 2563 | - $underline = $matches[2]; |
|
| 2562 | + $head = $matches[1]; |
|
| 2563 | + $underline = $matches[2]; |
|
| 2564 | 2564 | $content = $matches[3]; |
| 2565 | 2565 | |
| 2566 | 2566 | # Remove leading pipe for each row. |
@@ -2577,14 +2577,14 @@ discard block |
||
| 2577 | 2577 | return " class=\"$classname\""; |
| 2578 | 2578 | } |
| 2579 | 2579 | protected function _doTable_callback($matches) { |
| 2580 | - $head = $matches[1]; |
|
| 2581 | - $underline = $matches[2]; |
|
| 2582 | - $content = $matches[3]; |
|
| 2580 | + $head = $matches[1]; |
|
| 2581 | + $underline = $matches[2]; |
|
| 2582 | + $content = $matches[3]; |
|
| 2583 | 2583 | |
| 2584 | 2584 | # Remove any tailing pipes for each line. |
| 2585 | - $head = preg_replace('/[|] *$/m', '', $head); |
|
| 2586 | - $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 2587 | - $content = preg_replace('/[|] *$/m', '', $content); |
|
| 2585 | + $head = preg_replace('/[|] *$/m', '', $head); |
|
| 2586 | + $underline = preg_replace('/[|] *$/m', '', $underline); |
|
| 2587 | + $content = preg_replace('/[|] *$/m', '', $content); |
|
| 2588 | 2588 | |
| 2589 | 2589 | # Reading alignement from header underline. |
| 2590 | 2590 | $separators = preg_split('/ *[|] */', $underline); |
@@ -2601,17 +2601,17 @@ discard block |
||
| 2601 | 2601 | |
| 2602 | 2602 | # Parsing span elements, including code spans, character escapes, |
| 2603 | 2603 | # and inline HTML tags, so that pipes inside those gets ignored. |
| 2604 | - $head = $this->parseSpan($head); |
|
| 2605 | - $headers = preg_split('/ *[|] */', $head); |
|
| 2606 | - $col_count = count($headers); |
|
| 2607 | - $attr = array_pad($attr, $col_count, ''); |
|
| 2604 | + $head = $this->parseSpan($head); |
|
| 2605 | + $headers = preg_split('/ *[|] */', $head); |
|
| 2606 | + $col_count = count($headers); |
|
| 2607 | + $attr = array_pad($attr, $col_count, ''); |
|
| 2608 | 2608 | |
| 2609 | 2609 | # Write column headers. |
| 2610 | 2610 | $text = "<table>\n"; |
| 2611 | 2611 | $text .= "<thead>\n"; |
| 2612 | 2612 | $text .= "<tr>\n"; |
| 2613 | 2613 | foreach ($headers as $n => $header) |
| 2614 | - $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n"; |
|
| 2614 | + $text .= " <th$attr[$n]>" . $this->runSpanGamut(trim($header)) . "</th>\n"; |
|
| 2615 | 2615 | $text .= "</tr>\n"; |
| 2616 | 2616 | $text .= "</thead>\n"; |
| 2617 | 2617 | |
@@ -2630,7 +2630,7 @@ discard block |
||
| 2630 | 2630 | |
| 2631 | 2631 | $text .= "<tr>\n"; |
| 2632 | 2632 | foreach ($row_cells as $n => $cell) |
| 2633 | - $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n"; |
|
| 2633 | + $text .= " <td$attr[$n]>" . $this->runSpanGamut(trim($cell)) . "</td>\n"; |
|
| 2634 | 2634 | $text .= "</tr>\n"; |
| 2635 | 2635 | } |
| 2636 | 2636 | $text .= "</tbody>\n"; |
@@ -2650,10 +2650,10 @@ discard block |
||
| 2650 | 2650 | $whole_list_re = '(?> |
| 2651 | 2651 | ( # $1 = whole list |
| 2652 | 2652 | ( # $2 |
| 2653 | - [ ]{0,'.$less_than_tab.'} |
|
| 2653 | + [ ]{0,'.$less_than_tab . '} |
|
| 2654 | 2654 | ((?>.*\S.*\n)+) # $3 = defined term |
| 2655 | 2655 | \n? |
| 2656 | - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition |
|
| 2656 | + [ ]{0,'.$less_than_tab . '}:[ ]+ # colon starting definition |
|
| 2657 | 2657 | ) |
| 2658 | 2658 | (?s:.+?) |
| 2659 | 2659 | ( # $4 |
@@ -2662,13 +2662,13 @@ discard block |
||
| 2662 | 2662 | \n{2,} |
| 2663 | 2663 | (?=\S) |
| 2664 | 2664 | (?! # Negative lookahead for another term |
| 2665 | - [ ]{0,'.$less_than_tab.'} |
|
| 2665 | + [ ]{0,'.$less_than_tab . '} |
|
| 2666 | 2666 | (?: \S.*\n )+? # defined term |
| 2667 | 2667 | \n? |
| 2668 | - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition |
|
| 2668 | + [ ]{0,'.$less_than_tab . '}:[ ]+ # colon starting definition |
|
| 2669 | 2669 | ) |
| 2670 | 2670 | (?! # Negative lookahead for another definition |
| 2671 | - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition |
|
| 2671 | + [ ]{0,'.$less_than_tab . '}:[ ]+ # colon starting definition |
|
| 2672 | 2672 | ) |
| 2673 | 2673 | ) |
| 2674 | 2674 | ) |
@@ -2676,7 +2676,7 @@ discard block |
||
| 2676 | 2676 | |
| 2677 | 2677 | $text = preg_replace_callback('{ |
| 2678 | 2678 | (?>\A\n?|(?<=\n\n)) |
| 2679 | - '.$whole_list_re.' |
|
| 2679 | + '.$whole_list_re . ' |
|
| 2680 | 2680 | }mx', |
| 2681 | 2681 | array(&$this, '_doDefLists_callback'), $text); |
| 2682 | 2682 | |
@@ -2708,7 +2708,7 @@ discard block |
||
| 2708 | 2708 | $list_str = preg_replace_callback('{ |
| 2709 | 2709 | (?>\A\n?|\n\n+) # leading line |
| 2710 | 2710 | ( # definition terms = $1 |
| 2711 | - [ ]{0,'.$less_than_tab.'} # leading whitespace |
|
| 2711 | + [ ]{0,'.$less_than_tab . '} # leading whitespace |
|
| 2712 | 2712 | (?!\:[ ]|[ ]) # negative lookahead for a definition |
| 2713 | 2713 | # mark (colon) or more whitespace. |
| 2714 | 2714 | (?> \S.* \n)+? # actual term (not whitespace). |
@@ -2722,13 +2722,13 @@ discard block |
||
| 2722 | 2722 | $list_str = preg_replace_callback('{ |
| 2723 | 2723 | \n(\n+)? # leading line = $1 |
| 2724 | 2724 | ( # marker space = $2 |
| 2725 | - [ ]{0,'.$less_than_tab.'} # whitespace before colon |
|
| 2725 | + [ ]{0,'.$less_than_tab . '} # whitespace before colon |
|
| 2726 | 2726 | \:[ ]+ # definition mark (colon) |
| 2727 | 2727 | ) |
| 2728 | 2728 | ((?s:.+?)) # definition text = $3 |
| 2729 | 2729 | (?= \n+ # stop at next definition mark, |
| 2730 | 2730 | (?: # next term or end of text |
| 2731 | - [ ]{0,'.$less_than_tab.'} \:[ ] | |
|
| 2731 | + [ ]{0,'.$less_than_tab . '} \:[ ] | |
|
| 2732 | 2732 | <dt> | \z |
| 2733 | 2733 | ) |
| 2734 | 2734 | ) |
@@ -2749,13 +2749,13 @@ discard block |
||
| 2749 | 2749 | protected function _processDefListItems_callback_dd($matches) { |
| 2750 | 2750 | $leading_line = $matches[1]; |
| 2751 | 2751 | $marker_space = $matches[2]; |
| 2752 | - $def = $matches[3]; |
|
| 2752 | + $def = $matches[3]; |
|
| 2753 | 2753 | |
| 2754 | 2754 | if ($leading_line || preg_match('/\n{2,}/', $def)) { |
| 2755 | 2755 | # Replace marker with the appropriate whitespace indentation |
| 2756 | 2756 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 2757 | 2757 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 2758 | - $def = "\n". $def ."\n"; |
|
| 2758 | + $def = "\n" . $def . "\n"; |
|
| 2759 | 2759 | } |
| 2760 | 2760 | else { |
| 2761 | 2761 | $def = rtrim($def); |
@@ -2786,7 +2786,7 @@ discard block |
||
| 2786 | 2786 | (?: |
| 2787 | 2787 | \.?([-_:a-zA-Z0-9]+) # 2: standalone class name |
| 2788 | 2788 | | |
| 2789 | - '.$this->id_class_attr_catch_re.' # 3: Extra attributes |
|
| 2789 | + '.$this->id_class_attr_catch_re . ' # 3: Extra attributes |
|
| 2790 | 2790 | )? |
| 2791 | 2791 | [ ]* \n # Whitespace and newline following marker. |
| 2792 | 2792 | |
@@ -2806,8 +2806,8 @@ discard block |
||
| 2806 | 2806 | return $text; |
| 2807 | 2807 | } |
| 2808 | 2808 | protected function _doFencedCodeBlocks_callback($matches) { |
| 2809 | - $classname =& $matches[2]; |
|
| 2810 | - $attrs =& $matches[3]; |
|
| 2809 | + $classname = & $matches[2]; |
|
| 2810 | + $attrs = & $matches[3]; |
|
| 2811 | 2811 | $codeblock = $matches[4]; |
| 2812 | 2812 | $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); |
| 2813 | 2813 | $codeblock = preg_replace_callback('/^\n+/', |
@@ -2816,15 +2816,15 @@ discard block |
||
| 2816 | 2816 | if ($classname != "") { |
| 2817 | 2817 | if ($classname{0} == '.') |
| 2818 | 2818 | $classname = substr($classname, 1); |
| 2819 | - $attr_str = ' class="'.$this->code_class_prefix.$classname.'"'; |
|
| 2819 | + $attr_str = ' class="' . $this->code_class_prefix . $classname . '"'; |
|
| 2820 | 2820 | } else { |
| 2821 | 2821 | $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs); |
| 2822 | 2822 | } |
| 2823 | 2823 | $pre_attr_str = $this->code_attr_on_pre ? $attr_str : ''; |
| 2824 | 2824 | $code_attr_str = $this->code_attr_on_pre ? '' : $attr_str; |
| 2825 | - $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
| 2825 | + $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
|
| 2826 | 2826 | |
| 2827 | - return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
| 2827 | + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
| 2828 | 2828 | } |
| 2829 | 2829 | protected function _doFencedCodeBlocks_newlines($matches) { |
| 2830 | 2830 | return str_repeat("<br$this->empty_element_suffix", |
@@ -2900,7 +2900,7 @@ discard block |
||
| 2900 | 2900 | |
| 2901 | 2901 | # Link defs are in the form: [^id]: url "optional title" |
| 2902 | 2902 | $text = preg_replace_callback('{ |
| 2903 | - ^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1 |
|
| 2903 | + ^[ ]{0,'.$less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1 |
|
| 2904 | 2904 | [ ]* |
| 2905 | 2905 | \n? # maybe *one* newline |
| 2906 | 2906 | ( # text = $2 (no blank lines allowed) |
@@ -2947,7 +2947,7 @@ discard block |
||
| 2947 | 2947 | if (!empty($this->footnotes_ordered)) { |
| 2948 | 2948 | $text .= "\n\n"; |
| 2949 | 2949 | $text .= "<div class=\"footnotes\">\n"; |
| 2950 | - $text .= "<hr". $this->empty_element_suffix ."\n"; |
|
| 2950 | + $text .= "<hr" . $this->empty_element_suffix . "\n"; |
|
| 2951 | 2951 | $text .= "<ol>\n\n"; |
| 2952 | 2952 | |
| 2953 | 2953 | $attr = ""; |
@@ -3007,7 +3007,7 @@ discard block |
||
| 3007 | 3007 | # Create footnote marker only if it has a corresponding footnote *and* |
| 3008 | 3008 | # the footnote hasn't been used by another marker. |
| 3009 | 3009 | if (isset($this->footnotes[$node_id])) { |
| 3010 | - $num =& $this->footnotes_numbers[$node_id]; |
|
| 3010 | + $num = & $this->footnotes_numbers[$node_id]; |
|
| 3011 | 3011 | if (!isset($num)) { |
| 3012 | 3012 | # Transfer footnote content to the ordered list and give it its |
| 3013 | 3013 | # number |
@@ -3035,12 +3035,12 @@ discard block |
||
| 3035 | 3035 | $node_id = $this->encodeAttribute($node_id); |
| 3036 | 3036 | |
| 3037 | 3037 | return |
| 3038 | - "<sup id=\"fnref$ref_count_mark:$node_id\">". |
|
| 3039 | - "<a href=\"#fn:$node_id\"$attr>$num</a>". |
|
| 3038 | + "<sup id=\"fnref$ref_count_mark:$node_id\">" . |
|
| 3039 | + "<a href=\"#fn:$node_id\"$attr>$num</a>" . |
|
| 3040 | 3040 | "</sup>"; |
| 3041 | 3041 | } |
| 3042 | 3042 | |
| 3043 | - return "[^".$matches[1]."]"; |
|
| 3043 | + return "[^" . $matches[1] . "]"; |
|
| 3044 | 3044 | } |
| 3045 | 3045 | |
| 3046 | 3046 | |
@@ -3054,7 +3054,7 @@ discard block |
||
| 3054 | 3054 | |
| 3055 | 3055 | # Link defs are in the form: [id]*: url "optional title" |
| 3056 | 3056 | $text = preg_replace_callback('{ |
| 3057 | - ^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
| 3057 | + ^[ ]{0,'.$less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
| 3058 | 3058 | (.*) # text = $2 (no blank lines allowed) |
| 3059 | 3059 | }xm', |
| 3060 | 3060 | array(&$this, '_stripAbbreviations_callback'), |
@@ -3079,10 +3079,10 @@ discard block |
||
| 3079 | 3079 | if ($this->abbr_word_re) { |
| 3080 | 3080 | // cannot use the /x modifier because abbr_word_re may |
| 3081 | 3081 | // contain significant spaces: |
| 3082 | - $text = preg_replace_callback('{'. |
|
| 3083 | - '(?<![\w\x1A])'. |
|
| 3084 | - '(?:'.$this->abbr_word_re.')'. |
|
| 3085 | - '(?![\w\x1A])'. |
|
| 3082 | + $text = preg_replace_callback('{' . |
|
| 3083 | + '(?<![\w\x1A])' . |
|
| 3084 | + '(?:' . $this->abbr_word_re . ')' . |
|
| 3085 | + '(?![\w\x1A])' . |
|
| 3086 | 3086 | '}', |
| 3087 | 3087 | array(&$this, '_doAbbreviations_callback'), $text); |
| 3088 | 3088 | } |
@@ -29,6 +29,10 @@ |
||
| 29 | 29 | # Main function. Performs some preprocessing on the input text |
| 30 | 30 | # and pass it through the document gamut. |
| 31 | 31 | # |
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 32 | 36 | public function transform($text); |
| 33 | 37 | |
| 34 | 38 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * Usage example: [BASEURL] |
| 278 | 278 | * |
| 279 | - * @return array with all the options. |
|
| 279 | + * @return string with all the options. |
|
| 280 | 280 | */ |
| 281 | 281 | protected function shortCodeBaseurl() |
| 282 | 282 | { |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * Usage example: [RELURL] |
| 292 | 292 | * |
| 293 | - * @return array with all the options. |
|
| 293 | + * @return string with all the options. |
|
| 294 | 294 | */ |
| 295 | 295 | protected function shortCodeRelurl() |
| 296 | 296 | { |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * Usage example: [RELURL] |
| 305 | 305 | * |
| 306 | - * @return array with all the options. |
|
| 306 | + * @return string with all the options. |
|
| 307 | 307 | */ |
| 308 | 308 | protected function shortCodeAsset() |
| 309 | 309 | { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | return preg_replace_callback( |
| 99 | 99 | '#\b(?<![href|src]=[\'"])https?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', |
| 100 | - function ($matches) { |
|
| 100 | + function($matches) { |
|
| 101 | 101 | return "<a href=\'{$matches[0]}\'>{$matches[0]}</a>"; |
| 102 | 102 | }, |
| 103 | 103 | $text |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | return preg_replace_callback( |
| 156 | 156 | $patterns, |
| 157 | - function ($matches) { |
|
| 157 | + function($matches) { |
|
| 158 | 158 | switch ($matches[1]) { |
| 159 | 159 | |
| 160 | 160 | case 'FIGURE': |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $res[$match] = true; |
| 202 | 202 | } else { |
| 203 | 203 | $key = substr($match, 0, $pos); |
| 204 | - $val = trim(substr($match, $pos+1), '"'); |
|
| 204 | + $val = trim(substr($match, $pos + 1), '"'); |
|
| 205 | 205 | $res[$key] = $val; |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -30,7 +30,6 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * Construct. |
| 32 | 32 | * |
| 33 | - * @param array $options to configure options. |
|
| 34 | 33 | */ |
| 35 | 34 | public function offsetSet($offset, $value) |
| 36 | 35 | { |
@@ -46,7 +45,6 @@ discard block |
||
| 46 | 45 | /** |
| 47 | 46 | * Construct. |
| 48 | 47 | * |
| 49 | - * @param array $options to configure options. |
|
| 50 | 48 | */ |
| 51 | 49 | public function offsetExists($offset) |
| 52 | 50 | { |
@@ -58,7 +56,6 @@ discard block |
||
| 58 | 56 | /** |
| 59 | 57 | * Construct. |
| 60 | 58 | * |
| 61 | - * @param array $options to configure options. |
|
| 62 | 59 | */ |
| 63 | 60 | public function offsetUnset($offset) |
| 64 | 61 | { |
@@ -70,7 +67,6 @@ discard block |
||
| 70 | 67 | /** |
| 71 | 68 | * Construct. |
| 72 | 69 | * |
| 73 | - * @param array $options to configure options. |
|
| 74 | 70 | */ |
| 75 | 71 | public function offsetGet($offset) |
| 76 | 72 | { |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | * Properties |
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | - public $data = []; // Store all configuration options here |
|
| 15 | + public $data = []; // Store all configuration options here |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * Loads the class file for a given class name. |
| 117 | 117 | * |
| 118 | 118 | * @param string $class The fully-qualified class name. |
| 119 | - * @return mixed The mapped file name on success, or boolean false on |
|
| 119 | + * @return string|false The mapped file name on success, or boolean false on |
|
| 120 | 120 | * failure. |
| 121 | 121 | */ |
| 122 | 122 | public function loadClass($class) |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string $prefix The namespace prefix. |
| 166 | 166 | * @param string $relative_class The relative class name. |
| 167 | 167 | * |
| 168 | - * @return mixed Boolean false if no mapped file can be loaded, or the |
|
| 168 | + * @return false|string Boolean false if no mapped file can be loaded, or the |
|
| 169 | 169 | * name of the mapped file that was loaded. |
| 170 | 170 | */ |
| 171 | 171 | protected function loadMappedFile($prefix, $relative_class) |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | /** |
| 88 | 88 | * Logs with an arbitrary level. |
| 89 | 89 | * |
| 90 | - * @param mixed $level |
|
| 90 | + * @param string $level |
|
| 91 | 91 | * @param string $message |
| 92 | 92 | * @param array $context |
| 93 | 93 | * @return null |
@@ -51,18 +51,18 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | public function setContext($context = 'development') { |
| 53 | 53 | |
| 54 | - switch($context) { |
|
| 54 | + switch ($context) { |
|
| 55 | 55 | |
| 56 | 56 | case 'production': |
| 57 | 57 | |
| 58 | 58 | break; |
| 59 | 59 | |
| 60 | 60 | case 'development': |
| 61 | - error_reporting(-1); // Report all type of errors |
|
| 62 | - ini_set('display_errors', 1); // Display all errors |
|
| 63 | - ini_set('output_buffering', 0); // Do not buffer output |
|
| 61 | + error_reporting(-1); // Report all type of errors |
|
| 62 | + ini_set('display_errors', 1); // Display all errors |
|
| 63 | + ini_set('output_buffering', 0); // Do not buffer output |
|
| 64 | 64 | |
| 65 | - set_exception_handler(function ($exception) { |
|
| 65 | + set_exception_handler(function($exception) { |
|
| 66 | 66 | echo "Anax: Uncaught exception: <p>" . |
| 67 | 67 | $exception->getMessage() . "</p><pre>" . |
| 68 | 68 | $exception->getTraceAsString() . "</pre>"; |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | /** |
| 67 | 67 | * Check if a controller exists with this name. |
| 68 | 68 | * |
| 69 | - * @return void |
|
| 69 | + * @return boolean |
|
| 70 | 70 | */ |
| 71 | 71 | public function isValidController() |
| 72 | 72 | { |
@@ -16,10 +16,10 @@ |
||
| 16 | 16 | * Properties |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | - private $controllerName; // Name of controller |
|
| 20 | - private $controller; // Actual controller |
|
| 21 | - private $action; // Name of action |
|
| 22 | - private $params; // Params |
|
| 19 | + private $controllerName; // Name of controller |
|
| 20 | + private $controller; // Actual controller |
|
| 21 | + private $action; // Name of action |
|
| 22 | + private $params; // Params |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | /** |
| 253 | 253 | * Set variable in the server array. |
| 254 | 254 | * |
| 255 | - * @param mixed $key the key an the , or an key-value array |
|
| 255 | + * @param string $key the key an the , or an key-value array |
|
| 256 | 256 | * @param string $value the value of the key |
| 257 | 257 | * |
| 258 | 258 | * @return $this |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | /** |
| 287 | 287 | * Set variable in the get array. |
| 288 | 288 | * |
| 289 | - * @param mixed $key the key an the , or an key-value array |
|
| 289 | + * @param string $key the key an the , or an key-value array |
|
| 290 | 290 | * @param string $value the value of the key |
| 291 | 291 | * |
| 292 | 292 | * @return $this |
@@ -16,19 +16,19 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | private $requestUri; // Request URI from $_SERVER |
| 18 | 18 | private $scriptName; // Scriptname from $_SERVER, actual scriptname part |
| 19 | - private $path; // Scriptname from $_SERVER, path-part |
|
| 19 | + private $path; // Scriptname from $_SERVER, path-part |
|
| 20 | 20 | |
| 21 | - private $route; // The route |
|
| 21 | + private $route; // The route |
|
| 22 | 22 | private $routeParts; // The route as an array |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | private $currentUrl; // Current url |
| 26 | - private $siteUrl; // Url to this site, http://dbwebb.se |
|
| 27 | - private $baseUrl; // Url to root dir, siteUrl . /some/installation/directory/ |
|
| 26 | + private $siteUrl; // Url to this site, http://dbwebb.se |
|
| 27 | + private $baseUrl; // Url to root dir, siteUrl . /some/installation/directory/ |
|
| 28 | 28 | |
| 29 | 29 | private $server; // Mapped to $_SERVER |
| 30 | - private $get; // Mapped to $_GET |
|
| 31 | - private $post; // Mapped to $_POST |
|
| 30 | + private $get; // Mapped to $_GET |
|
| 31 | + private $post; // Mapped to $_POST |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | public function setGlobals($globals = []) |
| 55 | 55 | { |
| 56 | 56 | $this->server = isset($globals['server']) ? array_merge($_SERVER, $globals['server']) : $_SERVER; |
| 57 | - $this->get = isset($globals['get']) ? array_merge($_GET, $globals['get']) : $_GET; |
|
| 58 | - $this->post = isset($globals['post']) ? array_merge($_POST, $globals['post']) : $_POST; |
|
| 57 | + $this->get = isset($globals['get']) ? array_merge($_GET, $globals['get']) : $_GET; |
|
| 58 | + $this->post = isset($globals['post']) ? array_merge($_POST, $globals['post']) : $_POST; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * Add an internal (not exposed to url-matching) route to the router. |
| 51 | 51 | * |
| 52 | 52 | * @param string $rule for this route |
| 53 | - * @param mixed $action null, string or callable to implement a controller for the route |
|
| 53 | + * @param \Closure $action null, string or callable to implement a controller for the route |
|
| 54 | 54 | * |
| 55 | 55 | * @return class as new route |
| 56 | 56 | */ |
@@ -68,7 +68,6 @@ discard block |
||
| 68 | 68 | * Add an internal (not exposed to url-matching) route to the router. |
| 69 | 69 | * |
| 70 | 70 | * @param string $rule for this route |
| 71 | - * @param mixed $action null, string or callable to implement a controller for the route |
|
| 72 | 71 | * |
| 73 | 72 | * @return class as new route |
| 74 | 73 | */ |
@@ -16,9 +16,9 @@ |
||
| 16 | 16 | * Properties |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | - private $routes; // All the routes |
|
| 20 | - private $internalRoutes; // All internal routes |
|
| 21 | - private $defaultRoute = null; // A default rout to catch all |
|
| 19 | + private $routes; // All the routes |
|
| 20 | + private $internalRoutes; // All internal routes |
|
| 21 | + private $defaultRoute = null; // A default rout to catch all |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | |