在Algolia中包含整个搜索命中单词

时间:2017-10-02 09:23:46

标签: algolia

有没有办法让Algolia包裹搜索命中中突出显示的整个单词?因为现在它可能会导致单词在渲染时中断。举个例子,假设我已经搜索了“ example ”这个词,然后我得到一个标题的结果:«有很多很好的例子来说明这个< / em>的»。那么HTML将是<div>There are many good <em>example</em>s for how to do this</div>,给定一个窄元素可以像这样呈现:

There are many good example
s for how to do this

是否有这样的设置,或者我是否需要regex / voodoo?

修改:我发现这个词破解的原因是因为我设置了em {display:inline-block},这是我出于造型目的所需要的。我可以解决这个问题,但是以某种方式包含突出显示的单词会更加清晰,例如:<span><em>example</em>s</span>

1 个答案:

答案 0 :(得分:1)

这可能是与word-break相关的CSS问题,内联元素不应该打破流程,请参阅此笔:https://codepen.io/Haroenv/pen/zEdyZb

&#13;
&#13;
Private Sub Worksheet_Change(ByVal Target As Range)

'Code by Sumit Bansal from https://trumpexcel.com
' To Select Multiple Items from a Drop Down List in Excel

Dim Oldvalue As String
Dim Newvalue As String

On Error GoTo Exitsub
If Not Intersect(Target, Range("M7:M30")) Is Nothing Then
    If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
    ElseIf Target.Value = "All" Then GoTo Exitsub
    ElseIf Target.Value = "Select" Then GoTo Exitsub
    ElseIf Target.Value = "" Then GoTo Exitsub
    Else
        Application.EnableEvents = False
        Newvalue = Target.Value
        Application.Undo
        Oldvalue = Target.Value
        If Oldvalue = "" Then
            Target.Value = Newvalue
        ElseIf Oldvalue = "All" Then
            Target.Value = Newvalue
        ElseIf Oldvalue = "Select" Then
            Target.Value = Newvalue
        Else
            Target.Value = Oldvalue & ", " & Newvalue
        End If
    End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
&#13;
div {
  font-size: 2em;
  margin-bottom: 1em;
}

.broken {
  word-break: break-all;
}

.keep {
  word-break: keep-all;
}
&#13;
&#13;
&#13;