「利用者:Nijcadmin/FY2013」の版間の差分

編集の要約なし
編集の要約なし
210行目: 210行目:
**UTF-8なページであれば WORD 境界を検索条件にしないように改造
**UTF-8なページであれば WORD 境界を検索条件にしないように改造
**一文字目を抜き出す処理はマルチバイト関数を利用
**一文字目を抜き出す処理はマルチバイト関数を利用
**XMLタグは delimiter として扱うよう改造
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
--- LinkTitles.body.php.orig 2013-05-03 22:26:22.000000000 +0900
--- LinkTitles.body.php.orig 2013-05-03 22:26:22.000000000 +0900
+++ LinkTitles.body.php 2013-05-10 15:55:15.475792240 +0900
+++ LinkTitles.body.php 2013-05-10 18:36:10.138947085 +0900
@@ -162,6 +162,8 @@
@@ -120,6 +120,9 @@
// optional. Note that in order to use preg_split(), it is important to have only one
// capturing subpattern (which precludes the use of conditional subpatterns).
( $wgLinkTitlesParseHeadings ) ? $delimiter = '' : $delimiter = '=+.+?=+|';
+ // NIJC: append XML tag to delimiter
+ $xmlPattern = '(?:<\/?\S+(?:\s+\S+=(?:\"[^\"]*\"|\'[^\']*\'))*\s*\/?>)|';
+ $delimiter = $delimiter . $xmlPattern;
$urlPattern = '[a-z]+?\:\/\/(?:\S+\.)+\S+(?:\/.*)?';
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|' . $templatesDelimiter .
'|\[' . $urlPattern . '\s.+?\]|'. $urlPattern .
@@ -162,6 +165,8 @@
   
   
  if ( $title != $myTitle ) {
  if ( $title != $myTitle ) {
222行目: 233行目:
  // split the string by [[...]] groups
  // split the string by [[...]] groups
  // credits to inhan @ StackOverflow for suggesting preg_split
  // credits to inhan @ StackOverflow for suggesting preg_split
@@ -173,17 +175,25 @@
@@ -173,17 +178,25 @@
  // way, or in a 'fuzzy' way where the first letter of the title may
  // way, or in a 'fuzzy' way where the first letter of the title may
  // be either case.
  // be either case.
250行目: 261行目:
  break;  
  break;  
  };
  };
@@ -201,9 +211,16 @@
@@ -201,9 +214,16 @@
   
   
  for ( $i = 0; $i < count( $arr ); $i+=2 ) {
  for ( $i = 0; $i < count( $arr ); $i+=2 ) {
267行目: 278行目:
  break;  
  break;  
  };
  };
@@ -216,7 +233,8 @@
@@ -216,7 +236,8 @@
  }
  }
   
   
277行目: 288行目:
  } else  {
  } else  {
  return '[[' . LinkTitles::$safeTitle . '|' . $matches[0] . ']]';
  return '[[' . LinkTitles::$safeTitle . '|' . $matches[0] . ']]';
@@ -224,7 +242,8 @@
@@ -224,7 +245,8 @@
  }
  }