`SearchHeadline` would also accept an optional `options` argument which
is a where configuration options like `StartSel` and `StopSel` can be
specified.
My proposed implementation work look like this:
{{{#!python
>>> from django.contrib.postgres.search import SearchHeadline, SearchQuery
>>> query = SearchQuery('brave sir robin')
>>> first_line = Line.objects.annotate(
... headline=SearchHeadline('dialogue', query, options={
... 'StartSel': '<b>',
... 'StopSel': '</b>'
... })
... ).first()
>>> print(first_line.headline)
'<b>Robin</b>. He was not at all afraid to be killed in nasty ways.
<b>Brave</b>, <b>brave</b>, <b>brave</b>, <b>brave</b> <b>Sir</b>
<b>Robin</b>'
}}}
I have this implementation ready if this would be accepted:
https://github.com/django/django/compare/master...hannseman:ts_headline?expand=1
--
Ticket URL: <https://code.djangoproject.com/ticket/31147>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: (none) => Hannes Ljungberg
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/31147#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/31147#comment:2>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/12297
--
Ticket URL: <https://code.djangoproject.com/ticket/31147#comment:3>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31147#comment:4>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/31147#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/31147#comment:6>