/// <summary> /// 设置高亮 /// </summary> /// <param name="keywords">关键字</param> /// <param name="matchField">字段信息</param> /// <returns></returns> public void SetHighLight(string keywords, LnMatchField matchField) { var format = new SimpleHTMLFormatter(matchField.KeywordPrefix, matchField.KeywordSuffix); var highLighter = new Highlighter(format, new Segment()); highLighter.FragmentSize = matchField.FragmentSize < 1 ? this.Value.Length : matchField.FragmentSize; var newValue = highLighter.GetBestFragment(keywords, this.Value); if (string.IsNullOrEmpty(newValue) == false) { this.Value = newValue; } }