From 9de04ff5b4fbdcf37cae89d9275aaf945f58bd6b Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 9 Jul 2009 15:17:56 +0000 Subject: [PATCH] * Allow leading-> as syntax for quoting. --- includes/parser/Parser.php | 18 ++++++++++++++++-- maintenance/parserTests.txt | 22 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index f4fc48455d..dbc6e39823 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1947,7 +1947,7 @@ class Parser elseif ( ';' === $char ) { $result .= '
'; $this->mDTopen = true; - } + } elseif ( '>' === $char ) { $result .= "

"; } else { $result = ''; } return $result; @@ -1955,6 +1955,7 @@ class Parser /* private */ function nextItem( $char ) { if ( '*' === $char || '#' === $char ) { return '

  • '; } + elseif ( '>' === $char ) { return "

    "; } elseif ( ':' === $char || ';' === $char ) { $close = ''; if ( $this->mDTopen ) { $close = '

  • '; } @@ -1972,6 +1973,7 @@ class Parser /* private */ function closeList( $char ) { if ( '*' === $char ) { $text = ''; } elseif ( '#' === $char ) { $text = ''; } + elseif ( '>' === $char ) { $text = "

    "; } elseif ( ':' === $char ) { if ( $this->mDTopen ) { $this->mDTopen = false; @@ -2017,14 +2019,23 @@ class Parser // # = ol // ; = dt // : = dd + // > = blockquote $lastPrefixLength = strlen( $lastPrefix ); $preCloseMatch = preg_match('/<\\/pre/i', $oLine ); $preOpenMatch = preg_match('/
     > for blockquote syntax. Re-encode later.
    +			// To avoid collision with real >s, we temporarily convert them to >
    +			// This is a weird choice of armouring, but it's totally resistant to any
    +			//  collision.
    +			$orig = $oLine;
    +			$oLine = strtr( $oLine, array( '>' => '>', '>' => '>' ) );
    +			
     			// If not in a 
     element, scan for and figure out what prefixes are there.
     			if ( !$this->mInPre ) {
     				# Multiple prefixes may abut each other for nested lists.
    -				$prefixLength = strspn( $oLine, '*#:;' );
    +				$prefixLength = strspn( $oLine, '*#:;>' );
     				$prefix = substr( $oLine, 0, $prefixLength );
     
     				# eh?
    @@ -2040,6 +2051,9 @@ class Parser
     				$prefix = $prefix2 = '';
     				$t = $oLine;
     			}
    +			
    +			// Re-encode >s now
    +			$t = strtr( $t, array( '>' => '>', '>' => '>' ) );
     
     			# List generation
     			if( $prefixLength && $lastPrefix === $prefix2 ) {
    diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt
    index 3771941b6c..e7ebd96e38 100644
    --- a/maintenance/parserTests.txt
    +++ b/maintenance/parserTests.txt
    @@ -6550,9 +6550,9 @@ RAW magic word
     !! test
     Always escape literal '>' in output, not just after '<'
     !! input
    -><>
    +test ><>
     !! result
    -

    ><> +

    test ><>

    !! end @@ -7320,6 +7320,24 @@ wgUseDynamicDates=true

    !! end +!! test +Leading > blockquote syntax +!! input +> Hi +> This +> Is +> A +> Quote +!! result +

    Hi +

    This +

    Is +

    A +

    Quote +

    + +!! end + # # # -- 2.20.1