Alternative to look-behind (was: [SVN] Revision 1203 (markdown))

Charilaos Skiadas cskiadas at uchicago.edu
Fri Jun 24 06:36:21 UTC 2005


On Jun 24, 2005, at 12:46 AM, Allan Odgaard wrote:
>
> Problem is that if there's no legal end pattern, the begin pattern  
> shouldn't have been taken.
>
> I was thinking one could perhaps do something like:
>
> {   name = "markup.bold.markdown";
>     begin = "\\*(?=.*?<pattern-to-verify-legal-end-marker>)";
>     end = "\\*";
>     patterns = (
>         { include = "#escape";
>     );
> },
>
> Though I don't think that “pattern-to-verify-legal-end-marker” is  
> any simpler than doing the actual match, since the match would just  
> be to remove “(?=” and “)”.

Here is one suggestion for "markup.italic.markdown":

([*_])(?=\\S)((.*[^\\\\])?([^\\\\](\\\\\\\\)*)?[^\\s\\\\]?)(\\1)

There might be a simpler way to ensure that the closing character is  
not precluded by a space or an odd number of backslashes, but too  
late for me to figure it out now. Maybe in the morning. Currently it  
fails for _\\\\_ but passes most other cases I tried. Tomorrow I'll  
do a checkout of the bundles and check with the recent test-markdown,  
but maybe someone else can check earlier.

Ok, a better one, dealing with the case of only \\\\, is:

([*_])(?=\\S)(((.*[^\\\\])?([^\\\\](\\\\\\\\)*)?[^\\s\\\\]?)|((\\\\\\\ 
\)*))(\\1)

but I have to admit, at that point I start wondering whether we  
should disregard things that are "highly unlikely to be of any  
practical use", as for instance emphasizing a sequence of  
backslashes. I feel there is a balance between the complexity of the  
RE and the breadth of cases it deals with. Of course, if there is no  
processing time penalty, then more is better. :-)

Haris


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-dev/attachments/20050624/bd898520/attachment.html>


More information about the textmate-dev mailing list