From 6b57705e50875d9348c855700994395ce8a55b43 Mon Sep 17 00:00:00 2001 From: Filip Mikina Date: Wed, 20 Aug 2025 07:35:31 +0200 Subject: [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 --- tests/unit/settings/test_github_code.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/unit/settings/test_github_code.yml (limited to 'tests/unit/settings/test_github_code.yml') diff --git a/tests/unit/settings/test_github_code.yml b/tests/unit/settings/test_github_code.yml new file mode 100644 index 000000000..2cf039138 --- /dev/null +++ b/tests/unit/settings/test_github_code.yml @@ -0,0 +1,13 @@ +# This SearXNG setup is used in unit tests + +use_default_settings: + + engines: + keep_only: [] + +engines: + + - name: github code + engine: github_code + shortcut: "ghc" + disabled: true -- cgit v1.2.3