PyukiWiki CVS Commit
pyuki****@lists*****
2012年 2月 20日 (月) 01:16:00 JST
Index: PyukiWiki-Devel/lib/wiki.cgi diff -u PyukiWiki-Devel/lib/wiki.cgi:1.654 PyukiWiki-Devel/lib/wiki.cgi:1.655 --- PyukiWiki-Devel/lib/wiki.cgi:1.654 Sun Feb 19 23:55:45 2012 +++ PyukiWiki-Devel/lib/wiki.cgi Mon Feb 20 01:16:00 2012 @@ -1,6 +1,6 @@ ###################################################################### # wiki.cgi - This is PyukiWiki, yet another Wiki clone. -# $Id: wiki.cgi,v 1.654 2012/02/19 14:55:45 papu Exp $ +# $Id: wiki.cgi,v 1.655 2012/02/19 16:16:00 papu Exp $ # # "PyukiWiki" version 0.2.0-p2-preview3 $$ # Copyright (C) 2004-2012 Nekyo @@ -125,6 +125,8 @@ $::lfmode; $::escapeoff_exec; # Disable ESC key for IE # comment +$::highlight_exec=0; #nocompact + @::notes = (); # iniファイル読み込み # comment @@ -2550,40 +2552,8 @@ my $body=join("\n", @ result); $body=~s/edit\&mypage/edit\&mypage/g; - # add 0.2.0-p2 #nocompact - if($::form{word} ne '') {#nocompact - my $spc="";#nocompact - my $wd=$::form{word};#nocompact - if($::lang eq "ja") {#nocompact - if($::defaultcode eq 'utf8') {#nocompact - $spc="\xe3\x80\x80";#nocompact - } else {#nocompact - $spc="\xa1\xa1";#nocompact - }#nocompact - }#nocompact - if($spc ne "") {#nocompact - foreach(" ", $spc) {#nocompact - $wd=~s/$_/\t/g;#nocompact - }#nocompact - }#nocompact - my @wd=split(/\t/,$wd);#nocompact - my $searchcount=0;#nocompact - if(&load_module("Nana::Search")) {#nocompact - foreach(@wd) {#nocompact - $body=Nana::Search::SearchRe(#nocompact - $body, $_ #"(?!<.*>)$_"#nocompact - , '</strong>');#nocompact - $searchcount=($searchcount + 1) % 10;#nocompact - }#nocompact - } else {#nocompact - foreach(@wd) {#nocompact - my $strong='<strong class="word' . $searchcount . '">';#nocompact - $body=~s/(?^:((?:\G|>)[^<]*?))($_)/$1$strong$2<\/strong>/g;#nocompact - $searchcount=($searchcount + 1) % 10;#nocompact - }#nocompact - }#nocompact - }#nocompact - + # add 0.2.0-p2 + $body=&highlight($body, $::form{word}) if($::form{word} ne '');#nocompact return $body if($::usePukiWikiStyle eq 0); my $tmp=$body; $tmp=~s/(<p>|<\/p>|\n)//g; @@ -2593,6 +2563,79 @@ =lang ja +=head2 highlight + +=over 4 + +=item 入力値 + +HTML + +=item 出力 + +HTML + +=item オーバーライド + +可 + +=item 概要 + +検索結果に対して、ハイライトを付加する。 + +=item 参考 + +compact版には、この関数はありません。 + +=back + +=cut + +sub highlight {#nocompact + my ($text, $wd)=@_;#nocompact + my $spc="";#nocompact + + if($::highlight_exec eq 0) { + $::highlight_exec=1; + my $msg=$::resource{msg_word}; + my $cwd=&highlight($wd, $wd); # 検索ワードを再帰 # comment + $::bodyheaderbody.="<div>$msg$cwd</div>"; + } + + if($::lang eq "ja") {#nocompact + if($::defaultcode eq 'utf8') {#nocompact + $spc="\xe3\x80\x80";#nocompact + } else {#nocompact + $spc="\xa1\xa1";#nocompact + }#nocompact + }#nocompact + if($spc ne "") {#nocompact + foreach(" ", $spc) {#nocompact + $wd=~s/$_/\t/g;#nocompact + }#nocompact + }#nocompact + my @wd=split(/\t/,$wd);#nocompact + my $searchcount=0;#nocompact + if(&load_module("Nana::Search")) {#nocompact + foreach(@wd) {#nocompact + $body=Nana::Search::SearchRe(#nocompact + $body, $_ #nocompact + , '<strong class="word' . $searchcount . '">' #nocompact + , '</strong>');#nocompact + $searchcount=($searchcount + 1) % 10;#nocompact + }#nocompact + } else {#nocompact + foreach(@wd) {#nocompact + my $strong='<strong class="word' . $searchcount . '">';#nocompact + $body=~s/(?^:((?:\G|>)[^<]*?))($_)/$1$strong$2<\/strong>/g;#nocompact + $searchcount=($searchcount + 1) % 10;#nocompact + }#nocompact + }#nocompact + return $body;#nocompact; +}#nocompact + +=lang ja + =head2 pageanchorname =over 4 @@ -2794,6 +2837,7 @@ sub note { my ($msg) = @_; + $msg=&highlight($msg, $::form{word}) if($::form{word} ne '');#nocompact push(@::notes, $msg); # thanks to Ayase return "<a @{[$::is_xhtml ? 'id' : 'name']}=\"notetext_" . @::notes . "\" "