[pmwiki-users] Markup: Extract the group name from argument $1
John Rankin
john.rankin at affinity.co.nz
Mon Jan 31 14:47:32 CST 2005
On Monday, 31 January 2005 4:02 PM, Claude Montpetit <claude at montpetit.net> wrote:
> > [...]
>> Markup("x'", "inline",
>> "/x'(([^\\/.]+).*?)'x/",
>> "<div>[[$1 | $2]]</div>");
>>
>> The outer parens capture everything between x' and 'x into $1.
>> The inner parens capture the group part (everything before a dot
>> or slash) into $2.
>>
>> Pm
>
>Thank you for the regexp course! And it worked just great.
>
>John: the div is the reason why I use a markup: I want my language
>selector in a floating div somewhere on my page.
>
>Claude
Just a thought: you /could/ also do this without additional markup,
provided that you treat all 2 letter groups as languages.
SDV($LinkLanguageFmt,"<div class='language'><a class='languagelink' href='\$LinkUrl'>\$LinkText</a></div>");
Markup('[[lang','<[[','/\\[\\[(([[:upper:]][[:lower:]])[\\/.]][^\\|\\]]+)\\]\\]/e',
"Keep(MakeLink(\$pagename,PSS('$1'),PSS('$2'),'',\$GLOBALS['LinkLanguageFmt']),'L')");
Then any links of the form [[Aa.text]] will treat Aa as the link text.
If not now, the approach may come in useful one day...
--
JR
--
John Rankin
More information about the pmwiki-users
mailing list