Prevent linking inside preformatted text and code.

Ignore lines that start with a space as well as text enclosed in <nowiki> or
<code> tags.
This commit is contained in:
Daniel Kraus
2013-08-28 19:40:04 +02:00
parent ad700ca7f4
commit 8257471d89

View File

@ -121,9 +121,15 @@
// capturing subpattern (which precludes the use of conditional subpatterns).
( $wgLinkTitlesParseHeadings ) ? $delimiter = '' : $delimiter = '=+.+?=+|';
$urlPattern = '[a-z]+?\:\/\/(?:\S+\.)+\S+(?:\/.*)?';
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|' . $templatesDelimiter .
'|\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)' .
'|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b))/i';
$delimiter = '/(' . // exclude from linking:
'\[\[.*?\]\]|' . // links
$delimiter . // titles (if requested)
$templatesDelimiter . // templates (if requested)
'^ .+?\n|\n .+?\n|\n .+?$|^ .+?$|' . // preformatted text
'<nowiki>.*?<.nowiki>|<code>.*?<\/code>|' . // nowiki/code
'|\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)' . // urls
'|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses
')/i';
$black_list = str_replace( '_', ' ',
'("' . implode( '", "',$wgLinkTitlesBlackList ) . '")' );