]> Sergey Matveev's repositories - public-inbox.git/commitdiff
examples/cgit-commit-filter: improve quoted text handling
authorEric Wong <e@80x24.org>
Sat, 13 Feb 2021 02:15:03 +0000 (02:15 +0000)
committerEric Wong <e@80x24.org>
Sat, 27 Feb 2021 20:21:17 +0000 (16:21 -0400)
With an example such as:

something before "quoted phrase" something after

The Xapian will now see:

[ "something before", "quoted phrase", "something after" ]

whereas before it would see:

[ "something before", "quoted", "phrase", "something after" ]

which should improve search results accuracy when looking
up commits by commit title (subject).

examples/cgit-commit-filter.lua

index 8f9d3eb51d0d362814733449eacef1adf5660203..9614c94441e0149374f388e7bebc0df3662078d4 100644 (file)
@@ -32,7 +32,8 @@ function filter_close()
                        html(buffer)
                else
                        html('<a href="' .. u .. '?x=t&amp;q=')
-                       html_url_arg('"' .. buffer .. '"')
+                       s = string.gsub(buffer, '"', '""')
+                       html_url_arg('"' .. s .. '"')
                        html('"><tt>')
                        html_txt(buffer)
                        html('</tt></a>')