Index: trunk/phase3/maintenance/parserTests.txt |
— | — | @@ -6550,9 +6550,9 @@ |
6551 | 6551 | !! test |
6552 | 6552 | Always escape literal '>' in output, not just after '<' |
6553 | 6553 | !! input |
6554 | | -><> |
| 6554 | +test ><> |
6555 | 6555 | !! result |
6556 | | -<p>><> |
| 6556 | +<p>test ><> |
6557 | 6557 | </p> |
6558 | 6558 | !! end |
6559 | 6559 | |
— | — | @@ -7320,6 +7320,24 @@ |
7321 | 7321 | </p> |
7322 | 7322 | !! end |
7323 | 7323 | |
| 7324 | +!! test |
| 7325 | +Leading > blockquote syntax |
| 7326 | +!! input |
| 7327 | +> Hi |
| 7328 | +> This |
| 7329 | +> Is |
| 7330 | +> A |
| 7331 | +> Quote |
| 7332 | +!! result |
| 7333 | +<blockquote><p> Hi |
| 7334 | +</p><p> This |
| 7335 | +</p><p> Is |
| 7336 | +</p><p> A |
| 7337 | +</p><p> Quote |
| 7338 | +</p></blockquote> |
| 7339 | + |
| 7340 | +!! end |
| 7341 | + |
7324 | 7342 | # |
7325 | 7343 | # |
7326 | 7344 | # |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -1947,7 +1947,7 @@ |
1948 | 1948 | elseif ( ';' === $char ) { |
1949 | 1949 | $result .= '<dl><dt>'; |
1950 | 1950 | $this->mDTopen = true; |
1951 | | - } |
| 1951 | + } elseif ( '>' === $char ) { $result .= "<blockquote><p>"; } |
1952 | 1952 | else { $result = '<!-- ERR 1 -->'; } |
1953 | 1953 | |
1954 | 1954 | return $result; |
— | — | @@ -1955,6 +1955,7 @@ |
1956 | 1956 | |
1957 | 1957 | /* private */ function nextItem( $char ) { |
1958 | 1958 | if ( '*' === $char || '#' === $char ) { return '</li><li>'; } |
| 1959 | + elseif ( '>' === $char ) { return "</p><p>"; } |
1959 | 1960 | elseif ( ':' === $char || ';' === $char ) { |
1960 | 1961 | $close = '</dd>'; |
1961 | 1962 | if ( $this->mDTopen ) { $close = '</dt>'; } |
— | — | @@ -1972,6 +1973,7 @@ |
1973 | 1974 | /* private */ function closeList( $char ) { |
1974 | 1975 | if ( '*' === $char ) { $text = '</li></ul>'; } |
1975 | 1976 | elseif ( '#' === $char ) { $text = '</li></ol>'; } |
| 1977 | + elseif ( '>' === $char ) { $text = "</p></blockquote>"; } |
1976 | 1978 | elseif ( ':' === $char ) { |
1977 | 1979 | if ( $this->mDTopen ) { |
1978 | 1980 | $this->mDTopen = false; |
— | — | @@ -2017,14 +2019,23 @@ |
2018 | 2020 | // # = ol |
2019 | 2021 | // ; = dt |
2020 | 2022 | // : = dd |
| 2023 | + // > = blockquote |
2021 | 2024 | |
2022 | 2025 | $lastPrefixLength = strlen( $lastPrefix ); |
2023 | 2026 | $preCloseMatch = preg_match('/<\\/pre/i', $oLine ); |
2024 | 2027 | $preOpenMatch = preg_match('/<pre/i', $oLine ); |
| 2028 | + |
| 2029 | + // Need to decode > --> > for blockquote syntax. Re-encode later. |
| 2030 | + // To avoid collision with real >s, we temporarily convert them to > |
| 2031 | + // This is a weird choice of armouring, but it's totally resistant to any |
| 2032 | + // collision. |
| 2033 | + $orig = $oLine; |
| 2034 | + $oLine = strtr( $oLine, array( '>' => '>', '>' => '>' ) ); |
| 2035 | + |
2025 | 2036 | // If not in a <pre> element, scan for and figure out what prefixes are there. |
2026 | 2037 | if ( !$this->mInPre ) { |
2027 | 2038 | # Multiple prefixes may abut each other for nested lists. |
2028 | | - $prefixLength = strspn( $oLine, '*#:;' ); |
| 2039 | + $prefixLength = strspn( $oLine, '*#:;>' ); |
2029 | 2040 | $prefix = substr( $oLine, 0, $prefixLength ); |
2030 | 2041 | |
2031 | 2042 | # eh? |
— | — | @@ -2040,6 +2051,9 @@ |
2041 | 2052 | $prefix = $prefix2 = ''; |
2042 | 2053 | $t = $oLine; |
2043 | 2054 | } |
| 2055 | + |
| 2056 | + // Re-encode >s now |
| 2057 | + $t = strtr( $t, array( '>' => '>', '>' => '>' ) ); |
2044 | 2058 | |
2045 | 2059 | # List generation |
2046 | 2060 | if( $prefixLength && $lastPrefix === $prefix2 ) { |