From: Carsten K. <car...@us...> - 2003-11-14 21:06:17
|
Hi Bernd, This seems to fix the bug. It's probably not great, and incomplete (i.e. " /0 - -" still does not work as a line either), due to my limited experience with regex as well as my limited understanding of the BlockParser classes: class Block_blockquote extends BlockMarkup { var $_depth; - var $_re = '\ +(?=\S)'; + var $_re = '\ +(?=\S|\d)'; Not that I'm not discounting your patch just yet, it just doesn't work for me at the moment and I'm not 100% sure what is going on/program flow inside these classes. I don't really understand why my fix works either. I thought that \S included \d. If PHP's regex matching really is supposed to behave this way, then there may be a bug in PHP itself because clearly \S is not matching digits in this case. Carsten ref: http://ca3.php.net/manual/en/pcre.pattern.syntax.php The third use of backslash is for specifying generic character types: \d any decimal digit \D any character that is not a decimal digit \s any whitespace character \S any character that is not a whitespace character \w any "word" character \W any "non-word" character On Thursday, November 13, 2003, at 04:17 pm, Bernd Porr wrote: > Hi Carsten, > > is would like to suggest a very simple fix for that problem: > > BlockParser.php: > > class Block_blockquote extends BlockMarkup > { > var $_depth; > > var $_re = '\ +(?=\S)'; > > var $_really_match = true; > > function _match (&$input, $m) { > $this->_depth = strlen($m->match); > $indent = sprintf("\\ {%d}", $this->_depth); > $this->_element = new SubBlock($input, $indent, $m->match, > 'blockquote'); > return $this->_really_match; > } > > function merge ($nextBlock) { > if (get_class($nextBlock) == get_class($this)) { > if (!($nextBlock->_depth < $this->_depth)) { > $this->_really_match=false; > return false; > } > $nextBlock->_element->unshiftContent($this->_element); > $nextBlock->_tight_top = $this->_tight_top; > return $nextBlock; > } > return false; > } > } > > Match always returned a true value. Now it is so that if > !($nextBlock->_depth < $this->_depth) it returns the next time a > false. This prevents the main loop from looping forever. > > Maybe this is not the best fix but it does not generate a crash with > the "assert" function. > > /Bernd > > -- > Contact information: > http://www.cn.stir.ac.uk/~bp1/ > > |