summaryrefslogtreecommitdiff
path: root/searx/engines/searchcode_code.py
diff options
context:
space:
mode:
authorFilip Mikina <fm394471@students.mimuw.edu.pl>2025-08-20 07:35:31 +0200
committerGitHub <noreply@github.com>2025-08-20 07:35:31 +0200
commit6b57705e50875d9348c855700994395ce8a55b43 (patch)
treefd47dfeb6df94cc8efb92de068d9a925699ae177 /searx/engines/searchcode_code.py
parent25647c20d1904840d089892bb118390f46c66984 (diff)
[feat] engines: add GitHub Code Search engine (#5074)
This patch adds GitHub Code Search [1] engine to allow querying the codebases. Template code.html is changed to allow passthrough of strip and highlighting options. Engine Searchcode is adjusted to pass filename and not rely on hardcoded extensions. GitHub search code API does not return the exact code line indices, this implementation assigns the code arbitrary numbers starting from 1 (effectively relabeling the code). The API allows for unauth calls, and the default engine settings default to that, although the calls are heavily rate limited. The 'text' lexer is the default pygments lexer when parsing fails. [1] https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#search-code Co-authored-by: Markus Heiser <markus.heiser@darmarIT.de>
Diffstat (limited to 'searx/engines/searchcode_code.py')
-rw-r--r--searx/engines/searchcode_code.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/searx/engines/searchcode_code.py b/searx/engines/searchcode_code.py
index 7cfe2ce71..2196b0ad2 100644
--- a/searx/engines/searchcode_code.py
+++ b/searx/engines/searchcode_code.py
@@ -70,6 +70,8 @@ def response(resp):
'codelines': sorted(lines.items()),
'code_language': code_language,
'template': 'code.html',
+ 'strip_whitespace': True,
+ 'strip_new_lines': True,
}
)