[pmwiki-users] Re: Re: recipe programming special markup
Karl Loncarek
dh2mll at web.de
Sun Sep 11 01:36:12 CDT 2005
>> Markup('preHeader', '<include', '/(?m:^)(!{1,6})\\s?(.*)$/',
>> "xxxxx\n$1 $2");
>>
>> -> When I do this PHP seems to hang (or do some infinte loop).
>
> This regexp won't ever match -- the '(.*)' won't match anything
> containing a newline, and the $ requires matching to the very
> end of the markup text. (Since this is being done before include,
> the markup text hasn't been broken into links yet -- i.e., you're
> still working with the full text.)
>
> It's "hanging" because that (.*) on the entire markup text gives
> it a huge number of possibilities to try.
Ah I see (could have thought of it myself.
>
> Here are my suggestions -- first, I wouldn't use (?m:^) to try
> to match the beginning of a line. Just match a newline directly,
> or do a lookbehind for a newline. Second, I don't think you need to
> capture the text following the !!!'s for this. So, something like
>
> Markup('preHeader', '<include',
> "/(\\n!{1,6})/",
> "xxxxx$1");
>
> is probably what you want.
>
>> Markup('preHeader', 'directives', '/(?m:^)(!{1,6})\\s?(.*)$/',
>> "xxxxx\n$1 $2");
>>
>> ->This works in that way that "xxxxx" is displayed before the header.
>> But the Header is not recognized or parsed anymore with the header
>> markup!
>
> Yes, because "directives" takes place after the full text is
> split into separate lines, so adding a newline here doesn't break
That's why, ok I always asked myself and coul not find out.
> this line into multiple "lines". The remainder of the markup rules
> see the whole thing as being a single "line", which no longer
> begins with '!!!' so it's not treated as a heading. There *is* a
> way to tell the markup rules to go ahead and reparse the current
> string for newlines (via the PRR() function), but you really don't
> need that here.
>
> Pm
I'm still no PHP expert but it's getting better. So thank you very much
--
Bye
Karl (aka Klonk)
More information about the pmwiki-users
mailing list