From: Jakub Narebski Date: Mon, 27 Feb 2012 01:55:20 GMT Subject: [PATCHv3 2/4] gitweb: Highlight matched part of project name when searching projects Message-ID: <1330307722-25351-3-git-send-email-jnareb@gmail.com> In-Reply-To: <1330307722-25351-1-git-send-email-jnareb@gmail.com> Use esc_html_match_hl() introduced in previous commit to escape HTML and mark match, using span element with 'match' class. Currently only the 'path' part (i.e. the project name) is highlighted; match might be on the project description. Highlighting match in description is left for next commit. The code makes use of the fact that defined $search_regexp means that there was search going on. Signed-off-by: Jakub Narebski --- Changes from v2: * Introducing esc_html_match_hl() had been put together with introduction of esc_html_hl_regions() in previuos commit. Commit message got updated accordingly. Changes from v1: * Main part of esc_html_match_hl() got split into esc_html_hl_regions(), which was introduced in previous commit. gitweb/gitweb.perl | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index b790f67..829526f 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -5407,7 +5407,9 @@ sub git_project_list_rows { print "\n"; } print "" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"), - -class => "list"}, esc_html($pr->{'path'})) . "\n" . + -class => "list"}, + esc_html_match_hl($pr->{'path'}, $search_regexp)) . + "\n" . "" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"), -class => "list", -title => $pr->{'descr_long'}}, esc_html($pr->{'descr'})) . "\n" . -- 1.7.9