@@ -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 |
@@ -38,8 +38,9 @@ discard block |
||
| 38 | 38 | $parser =& $parser_list[$parser_class]; |
| 39 | 39 | |
| 40 | 40 | # create the parser it not already set |
| 41 | - if (!$parser) |
|
| 42 | - $parser = new $parser_class; |
|
| 41 | + if (!$parser) { |
|
| 42 | + $parser = new $parser_class; |
|
| 43 | + } |
|
| 43 | 44 | |
| 44 | 45 | # Transform text using parser. |
| 45 | 46 | return $parser->transform($text); |
@@ -223,7 +224,9 @@ discard block |
||
| 223 | 224 | |
| 224 | 225 | |
| 225 | 226 | protected function hashHTMLBlocks($text) { |
| 226 | - if ($this->no_markup) return $text; |
|
| 227 | + if ($this->no_markup) { |
|
| 228 | + return $text; |
|
| 229 | + } |
|
| 227 | 230 | |
| 228 | 231 | $less_than_tab = $this->tab_width - 1; |
| 229 | 232 | |
@@ -511,7 +514,9 @@ discard block |
||
| 511 | 514 | # |
| 512 | 515 | # Turn Markdown link shortcuts into XHTML <a> tags. |
| 513 | 516 | # |
| 514 | - if ($this->in_anchor) return $text; |
|
| 517 | + if ($this->in_anchor) { |
|
| 518 | + return $text; |
|
| 519 | + } |
|
| 515 | 520 | $this->in_anchor = true; |
| 516 | 521 | |
| 517 | 522 | # |
@@ -605,8 +610,7 @@ discard block |
||
| 605 | 610 | $link_text = $this->runSpanGamut($link_text); |
| 606 | 611 | $result .= ">$link_text</a>"; |
| 607 | 612 | $result = $this->hashPart($result); |
| 608 | - } |
|
| 609 | - else { |
|
| 613 | + } else { |
|
| 610 | 614 | $result = $whole_match; |
| 611 | 615 | } |
| 612 | 616 | return $result; |
@@ -707,8 +711,7 @@ discard block |
||
| 707 | 711 | } |
| 708 | 712 | $result .= $this->empty_element_suffix; |
| 709 | 713 | $result = $this->hashPart($result); |
| 710 | - } |
|
| 711 | - else { |
|
| 714 | + } else { |
|
| 712 | 715 | # If there's no such link ID, leave intact: |
| 713 | 716 | $result = $whole_match; |
| 714 | 717 | } |
@@ -766,8 +769,9 @@ discard block |
||
| 766 | 769 | } |
| 767 | 770 | protected function _doHeaders_callback_setext($matches) { |
| 768 | 771 | # Terrible hack to check we haven't found an empty list item. |
| 769 | - if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) |
|
| 770 | - return $matches[0]; |
|
| 772 | + if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) { |
|
| 773 | + return $matches[0]; |
|
| 774 | + } |
|
| 771 | 775 | |
| 772 | 776 | $level = $matches[2]{0} == '=' ? 1 : 2; |
| 773 | 777 | $block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>"; |
@@ -834,8 +838,7 @@ discard block |
||
| 834 | 838 | '.$whole_list_re.' |
| 835 | 839 | }mx', |
| 836 | 840 | array(&$this, '_doLists_callback'), $text); |
| 837 | - } |
|
| 838 | - else { |
|
| 841 | + } else { |
|
| 839 | 842 | $text = preg_replace_callback('{ |
| 840 | 843 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
| 841 | 844 | '.$whole_list_re.' |
@@ -925,8 +928,7 @@ discard block |
||
| 925 | 928 | # Replace marker with the appropriate whitespace indentation |
| 926 | 929 | $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
| 927 | 930 | $item = $this->runBlockGamut($this->outdent($item)."\n"); |
| 928 | - } |
|
| 929 | - else { |
|
| 931 | + } else { |
|
| 930 | 932 | # Recursion for sub-lists: |
| 931 | 933 | $item = $this->doLists($this->outdent($item)); |
| 932 | 934 | $item = preg_replace('/\n+$/', '', $item); |
@@ -1196,8 +1198,7 @@ discard block |
||
| 1196 | 1198 | $value = preg_replace('/^([ ]*)/', "<p>", $value); |
| 1197 | 1199 | $value .= "</p>"; |
| 1198 | 1200 | $grafs[$key] = $this->unhash($value); |
| 1199 | - } |
|
| 1200 | - else { |
|
| 1201 | + } else { |
|
| 1201 | 1202 | # Is a block. |
| 1202 | 1203 | # Modify elements of @grafs in-place... |
| 1203 | 1204 | $graf = $value; |
@@ -1352,8 +1353,11 @@ discard block |
||
| 1352 | 1353 | # roughly 10% raw, 45% hex, 45% dec |
| 1353 | 1354 | # '@' *must* be encoded. I insist. |
| 1354 | 1355 | if ($r > 90 && $char != '@') /* do nothing */; |
| 1355 | - else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1356 | - else $chars[$key] = '&#'.$ord.';'; |
|
| 1356 | + else if ($r < 45) { |
|
| 1357 | + $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1358 | + } else { |
|
| 1359 | + $chars[$key] = '&#'.$ord.';'; |
|
| 1360 | + } |
|
| 1357 | 1361 | } |
| 1358 | 1362 | } |
| 1359 | 1363 | |
@@ -1415,8 +1419,7 @@ discard block |
||
| 1415 | 1419 | if (isset($parts[1])) { |
| 1416 | 1420 | $output .= $this->handleSpanToken($parts[1], $parts[2]); |
| 1417 | 1421 | $str = $parts[2]; |
| 1418 | - } |
|
| 1419 | - else { |
|
| 1422 | + } else { |
|
| 1420 | 1423 | break; |
| 1421 | 1424 | } |
| 1422 | 1425 | } |
@@ -1498,7 +1501,9 @@ discard block |
||
| 1498 | 1501 | # function that will loosely count the number of UTF-8 characters with a |
| 1499 | 1502 | # regular expression. |
| 1500 | 1503 | # |
| 1501 | - if (function_exists($this->utf8_strlen)) return; |
|
| 1504 | + if (function_exists($this->utf8_strlen)) { |
|
| 1505 | + return; |
|
| 1506 | + } |
|
| 1502 | 1507 | $this->utf8_strlen = create_function('$text', 'return preg_match_all( |
| 1503 | 1508 | "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", |
| 1504 | 1509 | $text, $m);'); |
@@ -1620,8 +1625,9 @@ discard block |
||
| 1620 | 1625 | $this->footnote_counter = 1; |
| 1621 | 1626 | |
| 1622 | 1627 | foreach ($this->predef_abbr as $abbr_word => $abbr_desc) { |
| 1623 | - if ($this->abbr_word_re) |
|
| 1624 | - $this->abbr_word_re .= '|'; |
|
| 1628 | + if ($this->abbr_word_re) { |
|
| 1629 | + $this->abbr_word_re .= '|'; |
|
| 1630 | + } |
|
| 1625 | 1631 | $this->abbr_word_re .= preg_quote($abbr_word); |
| 1626 | 1632 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
| 1627 | 1633 | } |
@@ -1656,7 +1662,9 @@ discard block |
||
| 1656 | 1662 | # |
| 1657 | 1663 | # Currently supported attributes are .class and #id. |
| 1658 | 1664 | # |
| 1659 | - if (empty($attr)) return ""; |
|
| 1665 | + if (empty($attr)) { |
|
| 1666 | + return ""; |
|
| 1667 | + } |
|
| 1660 | 1668 | |
| 1661 | 1669 | # Split on components |
| 1662 | 1670 | preg_match_all('/[#.][-_:a-zA-Z0-9]+/', $attr, $matches); |
@@ -1669,7 +1677,9 @@ discard block |
||
| 1669 | 1677 | if ($element{0} == '.') { |
| 1670 | 1678 | $classes[] = substr($element, 1); |
| 1671 | 1679 | } else if ($element{0} == '#') { |
| 1672 | - if ($id === false) $id = substr($element, 1); |
|
| 1680 | + if ($id === false) { |
|
| 1681 | + $id = substr($element, 1); |
|
| 1682 | + } |
|
| 1673 | 1683 | } |
| 1674 | 1684 | } |
| 1675 | 1685 | |
@@ -1765,7 +1775,9 @@ discard block |
||
| 1765 | 1775 | # _HashHTMLBlocks_InMarkdown to handle the Markdown syntax within the tag. |
| 1766 | 1776 | # These two functions are calling each other. It's recursive! |
| 1767 | 1777 | # |
| 1768 | - if ($this->no_markup) return $text; |
|
| 1778 | + if ($this->no_markup) { |
|
| 1779 | + return $text; |
|
| 1780 | + } |
|
| 1769 | 1781 | |
| 1770 | 1782 | # |
| 1771 | 1783 | # Call the HTML-in-Markdown hasher. |
@@ -1802,7 +1814,9 @@ discard block |
||
| 1802 | 1814 | # |
| 1803 | 1815 | # Returns an array of that form: ( processed text , remaining text ) |
| 1804 | 1816 | # |
| 1805 | - if ($text === '') return array('', ''); |
|
| 1817 | + if ($text === '') { |
|
| 1818 | + return array('', ''); |
|
| 1819 | + } |
|
| 1806 | 1820 | |
| 1807 | 1821 | # Regex to check for the presense of newlines around a block tag. |
| 1808 | 1822 | $newline_before_re = '/(?:^\n?|\n\n)*$/'; |
@@ -1922,8 +1936,7 @@ discard block |
||
| 1922 | 1936 | # End marker found: pass text unchanged until marker. |
| 1923 | 1937 | $parsed .= $tag . $matches[0]; |
| 1924 | 1938 | $text = substr($text, strlen($matches[0])); |
| 1925 | - } |
|
| 1926 | - else { |
|
| 1939 | + } else { |
|
| 1927 | 1940 | # No end marker: just skip it. |
| 1928 | 1941 | $parsed .= $tag; |
| 1929 | 1942 | } |
@@ -1949,8 +1962,7 @@ discard block |
||
| 1949 | 1962 | # End marker found: pass text unchanged until marker. |
| 1950 | 1963 | $parsed .= $tag . $matches[0]; |
| 1951 | 1964 | $text = substr($text, strlen($matches[0])); |
| 1952 | - } |
|
| 1953 | - else { |
|
| 1965 | + } else { |
|
| 1954 | 1966 | # Unmatched marker: just skip it. |
| 1955 | 1967 | $parsed .= $tag; |
| 1956 | 1968 | } |
@@ -1997,8 +2009,11 @@ discard block |
||
| 1997 | 2009 | # |
| 1998 | 2010 | # Increase/decrease nested tag count. |
| 1999 | 2011 | # |
| 2000 | - if ($tag{1} == '/') $depth--; |
|
| 2001 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 2012 | + if ($tag{1} == '/') { |
|
| 2013 | + $depth--; |
|
| 2014 | + } else if ($tag{strlen($tag)-2} != '/') { |
|
| 2015 | + $depth++; |
|
| 2016 | + } |
|
| 2002 | 2017 | |
| 2003 | 2018 | if ($depth < 0) { |
| 2004 | 2019 | # |
@@ -2010,8 +2025,7 @@ discard block |
||
| 2010 | 2025 | } |
| 2011 | 2026 | |
| 2012 | 2027 | $parsed .= $tag; |
| 2013 | - } |
|
| 2014 | - else { |
|
| 2028 | + } else { |
|
| 2015 | 2029 | $parsed .= $tag; |
| 2016 | 2030 | } |
| 2017 | 2031 | } while ($depth >= 0); |
@@ -2029,7 +2043,9 @@ discard block |
||
| 2029 | 2043 | # |
| 2030 | 2044 | # Returns an array of that form: ( processed text , remaining text ) |
| 2031 | 2045 | # |
| 2032 | - if ($text === '') return array('', ''); |
|
| 2046 | + if ($text === '') { |
|
| 2047 | + return array('', ''); |
|
| 2048 | + } |
|
| 2033 | 2049 | |
| 2034 | 2050 | # Regex to match `markdown` attribute inside of a tag. |
| 2035 | 2051 | $markdown_attr_re = ' |
@@ -2080,8 +2096,9 @@ discard block |
||
| 2080 | 2096 | # Get the name of the starting tag. |
| 2081 | 2097 | # (This pattern makes $base_tag_name_re safe without quoting.) |
| 2082 | 2098 | # |
| 2083 | - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) |
|
| 2084 | - $base_tag_name_re = $matches[1]; |
|
| 2099 | + if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) { |
|
| 2100 | + $base_tag_name_re = $matches[1]; |
|
| 2101 | + } |
|
| 2085 | 2102 | |
| 2086 | 2103 | # |
| 2087 | 2104 | # Loop through every tag until we find the corresponding closing tag. |
@@ -2118,15 +2135,17 @@ discard block |
||
| 2118 | 2135 | { |
| 2119 | 2136 | # Just add the tag to the block as if it was text. |
| 2120 | 2137 | $block_text .= $tag; |
| 2121 | - } |
|
| 2122 | - else { |
|
| 2138 | + } else { |
|
| 2123 | 2139 | # |
| 2124 | 2140 | # Increase/decrease nested tag count. Only do so if |
| 2125 | 2141 | # the tag's name match base tag's. |
| 2126 | 2142 | # |
| 2127 | 2143 | if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) { |
| 2128 | - if ($tag{1} == '/') $depth--; |
|
| 2129 | - else if ($tag{strlen($tag)-2} != '/') $depth++; |
|
| 2144 | + if ($tag{1} == '/') { |
|
| 2145 | + $depth--; |
|
| 2146 | + } else if ($tag{strlen($tag)-2} != '/') { |
|
| 2147 | + $depth++; |
|
| 2148 | + } |
|
| 2130 | 2149 | } |
| 2131 | 2150 | |
| 2132 | 2151 | # |
@@ -2173,13 +2192,17 @@ discard block |
||
| 2173 | 2192 | } |
| 2174 | 2193 | |
| 2175 | 2194 | # Append tag content to parsed text. |
| 2176 | - if (!$span_mode) $parsed .= "\n\n$block_text\n\n"; |
|
| 2177 | - else $parsed .= "$block_text"; |
|
| 2195 | + if (!$span_mode) { |
|
| 2196 | + $parsed .= "\n\n$block_text\n\n"; |
|
| 2197 | + } else { |
|
| 2198 | + $parsed .= "$block_text"; |
|
| 2199 | + } |
|
| 2178 | 2200 | |
| 2179 | 2201 | # Start over with a new block. |
| 2180 | 2202 | $block_text = ""; |
| 2203 | + } else { |
|
| 2204 | + $block_text .= $tag; |
|
| 2181 | 2205 | } |
| 2182 | - else $block_text .= $tag; |
|
| 2183 | 2206 | } |
| 2184 | 2207 | |
| 2185 | 2208 | } while ($depth > 0); |
@@ -2207,7 +2230,9 @@ discard block |
||
| 2207 | 2230 | # |
| 2208 | 2231 | # Turn Markdown link shortcuts into XHTML <a> tags. |
| 2209 | 2232 | # |
| 2210 | - if ($this->in_anchor) return $text; |
|
| 2233 | + if ($this->in_anchor) { |
|
| 2234 | + return $text; |
|
| 2235 | + } |
|
| 2211 | 2236 | $this->in_anchor = true; |
| 2212 | 2237 | |
| 2213 | 2238 | # |
@@ -2298,14 +2323,14 @@ discard block |
||
| 2298 | 2323 | $title = $this->encodeAttribute($title); |
| 2299 | 2324 | $result .= " title=\"$title\""; |
| 2300 | 2325 | } |
| 2301 | - if (isset($this->ref_attr[$link_id])) |
|
| 2302 | - $result .= $this->ref_attr[$link_id]; |
|
| 2326 | + if (isset($this->ref_attr[$link_id])) { |
|
| 2327 | + $result .= $this->ref_attr[$link_id]; |
|
| 2328 | + } |
|
| 2303 | 2329 | |
| 2304 | 2330 | $link_text = $this->runSpanGamut($link_text); |
| 2305 | 2331 | $result .= ">$link_text</a>"; |
| 2306 | 2332 | $result = $this->hashPart($result); |
| 2307 | - } |
|
| 2308 | - else { |
|
| 2333 | + } else { |
|
| 2309 | 2334 | $result = $whole_match; |
| 2310 | 2335 | } |
| 2311 | 2336 | return $result; |
@@ -2408,12 +2433,12 @@ discard block |
||
| 2408 | 2433 | $title = $this->encodeAttribute($title); |
| 2409 | 2434 | $result .= " title=\"$title\""; |
| 2410 | 2435 | } |
| 2411 | - if (isset($this->ref_attr[$link_id])) |
|
| 2412 | - $result .= $this->ref_attr[$link_id]; |
|
| 2436 | + if (isset($this->ref_attr[$link_id])) { |
|
| 2437 | + $result .= $this->ref_attr[$link_id]; |
|
| 2438 | + } |
|
| 2413 | 2439 | $result .= $this->empty_element_suffix; |
| 2414 | 2440 | $result = $this->hashPart($result); |
| 2415 | - } |
|
| 2416 | - else { |
|
| 2441 | + } else { |
|
| 2417 | 2442 | # If there's no such link ID, leave intact: |
| 2418 | 2443 | $result = $whole_match; |
| 2419 | 2444 | } |
@@ -2482,8 +2507,9 @@ discard block |
||
| 2482 | 2507 | return $text; |
| 2483 | 2508 | } |
| 2484 | 2509 | protected function _doHeaders_callback_setext($matches) { |
| 2485 | - if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) |
|
| 2486 | - return $matches[0]; |
|
| 2510 | + if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) { |
|
| 2511 | + return $matches[0]; |
|
| 2512 | + } |
|
| 2487 | 2513 | $level = $matches[3]{0} == '=' ? 1 : 2; |
| 2488 | 2514 | $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2]); |
| 2489 | 2515 | $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>"; |
@@ -2570,8 +2596,9 @@ discard block |
||
| 2570 | 2596 | } |
| 2571 | 2597 | protected function _doTable_makeAlignAttr($alignname) |
| 2572 | 2598 | { |
| 2573 | - if (empty($this->table_align_class_tmpl)) |
|
| 2574 | - return " align=\"$alignname\""; |
|
| 2599 | + if (empty($this->table_align_class_tmpl)) { |
|
| 2600 | + return " align=\"$alignname\""; |
|
| 2601 | + } |
|
| 2575 | 2602 | |
| 2576 | 2603 | $classname = str_replace('%%', $alignname, $this->table_align_class_tmpl); |
| 2577 | 2604 | return " class=\"$classname\""; |
@@ -2589,14 +2616,15 @@ discard block |
||
| 2589 | 2616 | # Reading alignement from header underline. |
| 2590 | 2617 | $separators = preg_split('/ *[|] */', $underline); |
| 2591 | 2618 | foreach ($separators as $n => $s) { |
| 2592 | - if (preg_match('/^ *-+: *$/', $s)) |
|
| 2593 | - $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 2594 | - else if (preg_match('/^ *:-+: *$/', $s)) |
|
| 2595 | - $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 2596 | - else if (preg_match('/^ *:-+ *$/', $s)) |
|
| 2597 | - $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 2598 | - else |
|
| 2599 | - $attr[$n] = ''; |
|
| 2619 | + if (preg_match('/^ *-+: *$/', $s)) { |
|
| 2620 | + $attr[$n] = $this->_doTable_makeAlignAttr('right'); |
|
| 2621 | + } else if (preg_match('/^ *:-+: *$/', $s)) { |
|
| 2622 | + $attr[$n] = $this->_doTable_makeAlignAttr('center'); |
|
| 2623 | + } else if (preg_match('/^ *:-+ *$/', $s)) { |
|
| 2624 | + $attr[$n] = $this->_doTable_makeAlignAttr('left'); |
|
| 2625 | + } else { |
|
| 2626 | + $attr[$n] = ''; |
|
| 2627 | + } |
|
| 2600 | 2628 | } |
| 2601 | 2629 | |
| 2602 | 2630 | # Parsing span elements, including code spans, character escapes, |
@@ -2610,8 +2638,9 @@ discard block |
||
| 2610 | 2638 | $text = "<table>\n"; |
| 2611 | 2639 | $text .= "<thead>\n"; |
| 2612 | 2640 | $text .= "<tr>\n"; |
| 2613 | - foreach ($headers as $n => $header) |
|
| 2614 | - $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n"; |
|
| 2641 | + foreach ($headers as $n => $header) { |
|
| 2642 | + $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n"; |
|
| 2643 | + } |
|
| 2615 | 2644 | $text .= "</tr>\n"; |
| 2616 | 2645 | $text .= "</thead>\n"; |
| 2617 | 2646 | |
@@ -2629,8 +2658,9 @@ discard block |
||
| 2629 | 2658 | $row_cells = array_pad($row_cells, $col_count, ''); |
| 2630 | 2659 | |
| 2631 | 2660 | $text .= "<tr>\n"; |
| 2632 | - foreach ($row_cells as $n => $cell) |
|
| 2633 | - $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n"; |
|
| 2661 | + foreach ($row_cells as $n => $cell) { |
|
| 2662 | + $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n"; |
|
| 2663 | + } |
|
| 2634 | 2664 | $text .= "</tr>\n"; |
| 2635 | 2665 | } |
| 2636 | 2666 | $text .= "</tbody>\n"; |
@@ -2756,8 +2786,7 @@ discard block |
||
| 2756 | 2786 | $def = str_repeat(' ', strlen($marker_space)) . $def; |
| 2757 | 2787 | $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
| 2758 | 2788 | $def = "\n". $def ."\n"; |
| 2759 | - } |
|
| 2760 | - else { |
|
| 2789 | + } else { |
|
| 2761 | 2790 | $def = rtrim($def); |
| 2762 | 2791 | $def = $this->runSpanGamut($this->outdent($def)); |
| 2763 | 2792 | } |
@@ -2814,8 +2843,9 @@ discard block |
||
| 2814 | 2843 | array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock); |
| 2815 | 2844 | |
| 2816 | 2845 | if ($classname != "") { |
| 2817 | - if ($classname{0} == '.') |
|
| 2818 | - $classname = substr($classname, 1); |
|
| 2846 | + if ($classname{0} == '.') { |
|
| 2847 | + $classname = substr($classname, 1); |
|
| 2848 | + } |
|
| 2819 | 2849 | $attr_str = ' class="'.$this->code_class_prefix.$classname.'"'; |
| 2820 | 2850 | } else { |
| 2821 | 2851 | $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs); |
@@ -3064,8 +3094,9 @@ discard block |
||
| 3064 | 3094 | protected function _stripAbbreviations_callback($matches) { |
| 3065 | 3095 | $abbr_word = $matches[1]; |
| 3066 | 3096 | $abbr_desc = $matches[2]; |
| 3067 | - if ($this->abbr_word_re) |
|
| 3068 | - $this->abbr_word_re .= '|'; |
|
| 3097 | + if ($this->abbr_word_re) { |
|
| 3098 | + $this->abbr_word_re .= '|'; |
|
| 3099 | + } |
|
| 3069 | 3100 | $this->abbr_word_re .= preg_quote($abbr_word); |
| 3070 | 3101 | $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); |
| 3071 | 3102 | return ''; # String that will replace the block |
@@ -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 | { |
@@ -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 | { |
@@ -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 |
@@ -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 | { |
@@ -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 |
@@ -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 | */ |