mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +02:00
Add new option to skip parsing of templates.
This commit is contained in:
@ -75,6 +75,7 @@
|
||||
global $wgLinkTitlesMinimumTitleLength;
|
||||
global $wgLinkTitlesParseHeadings;
|
||||
global $wgLinkTitlesBlackList;
|
||||
global $wgLinkTitlesSkipTemplates;
|
||||
|
||||
// To prevent adding self-references, we now
|
||||
// extract the current page's title.
|
||||
@ -82,6 +83,13 @@
|
||||
|
||||
( $wgLinkTitlesPreferShortTitles ) ? $sort_order = 'ASC' : $sort_order = 'DESC';
|
||||
|
||||
if ( $wgLinkTitlesSkipTemplates )
|
||||
{
|
||||
$templatesDelimiter = '{{.+}}';
|
||||
} else {
|
||||
$templatesDelimiter = '{{[^|]+?}}|{{.+\|';
|
||||
};
|
||||
|
||||
// Build a regular expression that will capture existing wiki links ("[[...]]"),
|
||||
// wiki headings ("= ... =", "== ... ==" etc.),
|
||||
// urls ("http://example.com", "[http://example.com]", "[http://example.com Description]",
|
||||
@ -91,8 +99,9 @@
|
||||
// capturing subpattern (which precludes the use of conditional subpatterns).
|
||||
( $wgLinkTitlesParseHeadings ) ? $delimiter = '' : $delimiter = '=+.+?=+|';
|
||||
$urlPattern = '[a-z]+?\:\/\/(?:\S+\.)+\S+(?:\/.*)?';
|
||||
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|{{[^|]+?}}|{{.+\||{{.+\||\[' .
|
||||
$urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b))/i';
|
||||
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|' . $templatesDelimiter .
|
||||
'|\[' . $urlPattern . '\s.+?\]|'. $urlPattern .
|
||||
'(?=\s|$)|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b))/i';
|
||||
|
||||
$black_list = str_replace( '_', ' ',
|
||||
'("' . implode( '", "',$wgLinkTitlesBlackList ) . '")' );
|
||||
|
Reference in New Issue
Block a user