Error[8]: Undefined offset: 2, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有一个微型迷你搜索引擎,突出了我的rails应用程序中的搜索条件.搜索忽略重音,突出显示不区分大小写.几乎完美. 但是,例如,如果我有一个带有“pãodequeijo”文本的记录并搜索“pao de queijo”,则返回记录,但不突出显示iext.同样,如果我搜索“pÃodede queijo”,则会返回记录但不会正确突出显示. 我的代码很简单: <%= highlight(result_pe 我有一个微型迷你搜索引擎,突出了我的rails应用程序中的搜索条件.搜索忽略重音,突出显示不区分大小写.几乎完美.
但是,例如,如果我有一个带有“pãodequeijo”文本的记录并搜索“pao de queijo”,则返回记录,但不突出显示IExt.同样,如果我搜索“pÃodede queijo”,则会返回记录但不会正确突出显示.

我的代码很简单:

<%= highlight(result_pessoa.observacoes,search_string,'<span ></span>') %>
解决方法 我刚刚向Rails提交了补丁,解决了这个问题.

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3593-patch-support-for-highlighting-with-ignoring-special-chars

# Highlights one or more +phrases+ everywhere in +text+ by inserting it into  # a <tt>:Highlighter</tt> string. The Highlighter can be specialized by passing <tt>:Highlighter</tt>  # as a single-quoted string with  where the phrase is to be inserted (defaults to  # '<strong ></strong>')  #  # ==== Examples  #   highlight('You searched for: rails','rails')  #   # => You searched for: <strong >rails</strong>  #  #   highlight('You searched for: ruby,rails,dhh','actionpack')  #   # => You searched for: ruby,dhh  #  #   highlight('You searched for: rails',['for','rails'],:Highlighter => '<em></em>')  #   # => You searched <em>for</em>: <em>rails</em>  #  #   highlight('You searched for: rails','rails',:Highlighter => '<a href="search?q="></a>')  #   # => You searched for: <a href="search?q=rails">rails</a>  #  #   highlight('Šumné dIEvčatá',['šumňe','dIEvca'],:ignore_special_chars => true)  #   # => <strong >Šumné</strong> <strong >dIEvča</strong>tá    #  # You can still use <tt>highlight</tt> with the old API that accepts the  # +Highlighter+ as its optional third parameter:  #   highlight('You searched for: rails','<a href="search?q="></a>')     # => You searched for: <a href="search?q=rails">rails</a>  def highlight(text,phrases,*args)    options = args.extract_options!    unless args.empty?      options[:Highlighter] = args[0] || '<strong ></strong>'    end    options.reverse_merge!(:Highlighter => '<strong ></strong>')    if text.blank? || phrases.blank?      text    else      haystack = text.clone      match = Array(phrases).map { |p| Regexp.escape(p) }.join('|')      if options[:ignore_special_chars]        haystack = haystack.mb_chars.normalize(:kd)        match = match.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]+/n,'').gsub(/\w/,'[+++][^\x00-\x7F]*')      end      highlighted = haystack.gsub(/(#{match})(?!(?:[^<]*?)(?:["'])[^<>]*>)/i,options[:Highlighter])      highlighted = highlighted.mb_chars.normalize(:kc) if options[:ignore_special_chars]      highlighted    end  end
总结

以上是内存溢出为你收集整理的ruby-on-rails – 如何忽略高亮功能中的重音全部内容,希望文章能够帮你解决ruby-on-rails – 如何忽略高亮功能中的重音所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
ruby-on-rails – 如何忽略高亮功能中的重音_语言综合_内存溢出

ruby-on-rails – 如何忽略高亮功能中的重音

ruby-on-rails – 如何忽略高亮功能中的重音,第1张

概述我有一个微型迷你搜索引擎,突出了我的rails应用程序中的搜索条件.搜索忽略重音,突出显示不区分大小写.几乎完美. 但是,例如,如果我有一个带有“pãodequeijo”文本的记录并搜索“pao de queijo”,则返回记录,但不突出显示iext.同样,如果我搜索“pÃodede queijo”,则会返回记录但不会正确突出显示. 我的代码很简单: <%= highlight(result_pe 我有一个微型迷你搜索引擎,突出了我的rails应用程序中的搜索条件.搜索忽略重音,突出显示不区分大小写.几乎完美.
但是,例如,如果我有一个带有“pãodequeijo”文本的记录并搜索“pao de queijo”,则返回记录,但不突出显示IExt.同样,如果我搜索“pÃodede queijo”,则会返回记录但不会正确突出显示.

我的代码很简单:

<%= highlight(result_pessoa.observacoes,search_string,'<span ></span>') %>
解决方法 我刚刚向Rails提交了补丁,解决了这个问题.

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3593-patch-support-for-highlighting-with-ignoring-special-chars

# Highlights one or more +phrases+ everywhere in +text+ by inserting it into  # a <tt>:Highlighter</tt> string. The Highlighter can be specialized by passing <tt>:Highlighter</tt>  # as a single-quoted string with  where the phrase is to be inserted (defaults to  # '<strong ></strong>')  #  # ==== Examples  #   highlight('You searched for: rails','rails')  #   # => You searched for: <strong >rails</strong>  #  #   highlight('You searched for: ruby,rails,dhh','actionpack')  #   # => You searched for: ruby,dhh  #  #   highlight('You searched for: rails',['for','rails'],:Highlighter => '<em></em>')  #   # => You searched <em>for</em>: <em>rails</em>  #  #   highlight('You searched for: rails','rails',:Highlighter => '<a href="search?q="></a>')  #   # => You searched for: <a href="search?q=rails">rails</a>  #  #   highlight('Šumné dIEvčatá',['šumňe','dIEvca'],:ignore_special_chars => true)  #   # => <strong >Šumné</strong> <strong >dIEvča</strong>tá    #  # You can still use <tt>highlight</tt> with the old API that accepts the  # +Highlighter+ as its optional third parameter:  #   highlight('You searched for: rails','<a href="search?q="></a>')     # => You searched for: <a href="search?q=rails">rails</a>  def highlight(text,phrases,*args)    options = args.extract_options!    unless args.empty?      options[:Highlighter] = args[0] || '<strong ></strong>'    end    options.reverse_merge!(:Highlighter => '<strong ></strong>')    if text.blank? || phrases.blank?      text    else      haystack = text.clone      match = Array(phrases).map { |p| Regexp.escape(p) }.join('|')      if options[:ignore_special_chars]        haystack = haystack.mb_chars.normalize(:kd)        match = match.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]+/n,'').gsub(/\w/,'[^\x00-\x7F]*')      end      highlighted = haystack.gsub(/(#{match})(?!(?:[^<]*?)(?:["'])[^<>]*>)/i,options[:Highlighter])      highlighted = highlighted.mb_chars.normalize(:kc) if options[:ignore_special_chars]      highlighted    end  end
总结

以上是内存溢出为你收集整理的ruby-on-rails – 如何忽略高亮功能中的重音全部内容,希望文章能够帮你解决ruby-on-rails – 如何忽略高亮功能中的重音所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1212455.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存