Use recursive regex to deal with nested braces.

- Fix: Properly handle templates that include other templates.

Addresses #29.
This commit is contained in:
Daniel Kraus
2017-08-24 19:10:29 +02:00
parent 9d11c5b270
commit 0dbddc795a

View File

@ -464,7 +464,9 @@ class Extension {
if ( $wgLinkTitlesSkipTemplates ) if ( $wgLinkTitlesSkipTemplates )
{ {
$templatesDelimiter = '{{[^}]+}}|'; // Use recursive regex to balance curly braces;
// see http://www.regular-expressions.info/recurse.html
$templatesDelimiter = '{{(?>[^{}]|(?R))*}}|';
} else { } else {
// Match template names (ignoring any piped [[]] links in them) // Match template names (ignoring any piped [[]] links in them)
// along with the trailing pipe and parameter name or closing // along with the trailing pipe and parameter name or closing