mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +02:00
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:
@ -121,9 +121,15 @@
|
|||||||
// capturing subpattern (which precludes the use of conditional subpatterns).
|
// capturing subpattern (which precludes the use of conditional subpatterns).
|
||||||
( $wgLinkTitlesParseHeadings ) ? $delimiter = '' : $delimiter = '=+.+?=+|';
|
( $wgLinkTitlesParseHeadings ) ? $delimiter = '' : $delimiter = '=+.+?=+|';
|
||||||
$urlPattern = '[a-z]+?\:\/\/(?:\S+\.)+\S+(?:\/.*)?';
|
$urlPattern = '[a-z]+?\:\/\/(?:\S+\.)+\S+(?:\/.*)?';
|
||||||
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|' . $templatesDelimiter .
|
$delimiter = '/(' . // exclude from linking:
|
||||||
'|\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)' .
|
'\[\[.*?\]\]|' . // links
|
||||||
'|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b))/i';
|
$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( '_', ' ',
|
$black_list = str_replace( '_', ' ',
|
||||||
'("' . implode( '", "',$wgLinkTitlesBlackList ) . '")' );
|
'("' . implode( '", "',$wgLinkTitlesBlackList ) . '")' );
|
||||||
|
Reference in New Issue
Block a user