From: Martin G. <gim...@gi...> - 2002-11-22 21:05:57
|
Hallo again, I think I've found a small but in the regexp that deals with nestled emphasis. The problem is, that you cannot start the emphasis immediately after one of (, ", or '. So the following doesn't work: (*foo* bar) (foo *bar*) (*foo bar*) Also, it's now possible to combine bold with italic, but not with monospace. (And it's also not possible to combine monospace with italic, but on my system monospace made the font upright, so I've left that possibility out. That's also why I left out the possibility of having all three kinds of emphasis in play simultaneously.) By the way, would you rather have me report these bugs using the SourceForge bug-tracking system, or is it okay to use the mailinglist for this too? Anyway, the revised class is here: class Markup_nestled_emphasis extends BalancedMarkup { //var $_start_regexp = "(?<! [[:alnum:]] ) [*_=] (?=[[:alnum:]])"; var $_start_regexp = "(?<= \s | ^ | [\"'(] ) (?: _\\* | \\*_ | =\\* | \\*= | [*_=] ) (?= \S)"; function getEndRegexp ($match) { //return "(?<= [[:alnum:]]) \\$match (?![[:alnum:]])"; $rev = preg_quote(strrev($match)); return "(?<= \S) $rev (?= \s | [.,:;\"'?)] | $)"; } function markup ($match, $body) { switch ($match) { case '*': return new HtmlElement('b', $body); case '=': return new HtmlElement('tt', $body); case '_': return new HtmlElement('i', $body); case '_*': return new HtmlElement('i', new HtmlElement('b', $body)); case '*_': return new HtmlElement('b', new HtmlElement('i', $body)); case '=*': return new HtmlElement('tt', new HtmlElement('b', $body)); case '*=': return new HtmlElement('b', new HtmlElement('tt', $body)); default: return new HtmlElement('b', new HtmlElement('i', $body)); } } } -- Martin Geisler My GnuPG Key: 0xF7F6B57B See http://gimpster.com/ and http://phpweather.net/ for: PHP Weather => Shows the current weather on your webpage and PHP Shell => A telnet-connection (almost :-) in a PHP page. |