From: Gabriel Wicke Date: Fri, 14 May 2004 00:18:43 +0000 (+0000) Subject: Made strong/em handling more forgiving against unbalanced ticks X-Git-Tag: 1.3.0beta1~70 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=d181a35170a12f30b0ebea0658f9954622fff6ee;p=lhc%2Fweb%2Fwiklou.git Made strong/em handling more forgiving against unbalanced ticks * close any open em's or strong tags before each heading * close any open em's or strong's at the end of the text --- diff --git a/includes/Parser.php b/includes/Parser.php index e65acb3683..05c6786e98 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -861,6 +861,19 @@ class Parser # empty token $txt=""; break; + case "h": + #heading- used to close all unbalanced bold or em tags in this section + $txt = ''; + if( $state['em'] !== false and + ( $state['strong'] === false or $state['em'] > $state['strong'] ) ) + { + $s .= ''; + $state['em'] = false; + } + if ( $state['strong'] !== false ) $txt .= ''; + if ( $state['em'] !== false ) $txt .= ''; + $state['strong'] = $state['em'] = false; + break; case "RFC ": if ( $tagIsOpen ) { $txt = "RFC "; @@ -904,6 +917,19 @@ class Parser $s .= $txt; } } #end while + + # make 100% sure all strong and em tags are closed + # doBlockLevels often messes the last bit up though, but invalid nesting is better than unclosed tags + # tidy solves this though + if( $state['em'] !== false and + ( $state['strong'] === false or $state['em'] > $state['strong'] ) ) + { + $s .= ''; + $state['em'] = false; + } + if ( $state['strong'] !== false ) $s .= ''; + if ( $state['em'] !== false ) $s .= ''; + if ( count( $tokenStack ) != 0 ) { # still objects on stack. opened [[ tag without closing ]] tag. diff --git a/includes/Tokenizer.php b/includes/Tokenizer.php index 0b313d5e26..ab18b106db 100644 --- a/includes/Tokenizer.php +++ b/includes/Tokenizer.php @@ -147,7 +147,7 @@ class Tokenizer { } break; case "\n": // for block levels, actually, only "----" is handled. - case "\r": + case "\r": // headings are detected to close any unbalanced em or strong tags in a section if ( $this->continues( "----" ) ) { $queueToken["type"] = "----"; @@ -160,6 +160,21 @@ class Tokenizer { $this->mPos ++; } break 2; + } else if ( + $this->continues( "continues( "continues( "continues( "continues( "continues( "continues( "mQueuedToken[] = $queueToken; + $this->mPos ++; + break 2; // switch + while } break; case "!": // French spacing rules have a space before exclamation