Open simonw opened 4 years ago
Might just be a documented pattern for how to configure this in YAML templates.
I think I can do this as a cunning trick in display_sql
. Consider this example query: https://til.simonwillison.net/tils?sql=select%0D%0A++path%2C%0D%0A++snippet%28til_fts%2C+-1%2C+%27b4de2a49c8%27%2C+%278c94a2ed4b%27%2C+%27...%27%2C+60%29+as+snippet%0D%0Afrom%0D%0A++til%0D%0A++join+til_fts+on+til.rowid+%3D+til_fts.rowid%0D%0Awhere%0D%0A++til_fts+match+escape_fts%28%3Aq%29%0D%0A++and+path+%3D+%27asgi_lifespan-test-httpx.md%27%0D%0A&q=pytest
select
path,
snippet(til_fts, -1, 'b4de2a49c8', '8c94a2ed4b', '...', 60) as snippet
from
til
join til_fts on til.rowid = til_fts.rowid
where
til_fts match escape_fts(:q)
and path = 'asgi_lifespan-test-httpx.md'
The and path = 'asgi_lifespan-test-httpx.md'
bit means we only get back a specific document - but the snippet highlighting is applied to it.
To do this I'll need the search term to be passed to the display_sql
SQL query:
https://github.com/dogsheep/dogsheep-beta/blob/4890ec87b5e2ec48940f32c9ad1f5aae25c75a4d/dogsheep_beta/__init__.py#L164-L171
Should I pass any other details to the display_sql
here as well?
I'm just going to add q
for the moment.
Like on https://til.simonwillison.net/til/search?q=Snippet