Use more accurate language detection for syntax highlighting (#1891)

Updated spotter to version 4 in order to get prism syntax mode for detected coding languages.
Expose syntax modes of coding languages as headers on content endpoint and as fields on diff dto.
Remove leading line break on search result fragments.
Use mark instead of span or strong for highlighted search results.
Add option to use syntax highlighting in TextHitField component.

Co-authored-by: Matthias Thieroff <matthias.thieroff@cloudogu.com>
This commit is contained in:
Sebastian Sdorra
2021-12-13 17:03:08 +01:00
committed by GitHub
parent 6eba01161f
commit e2d63cc2a1
34 changed files with 809 additions and 802 deletions

View File

@@ -28,6 +28,9 @@ import { ApiResultWithFetching } from "./base";
export type ContentType = {
type: string;
language?: string;
aceMode?: string;
codemirrorMode?: string;
prismMode?: string;
};
function getContentType(url: string): Promise<ContentType> {
@@ -35,6 +38,9 @@ function getContentType(url: string): Promise<ContentType> {
return {
type: response.headers.get("Content-Type") || "application/octet-stream",
language: response.headers.get("X-Programming-Language") || undefined,
aceMode: response.headers.get("X-Syntax-Mode-Ace") || undefined,
codemirrorMode: response.headers.get("X-Syntax-Mode-Codemirror") || undefined,
prismMode: response.headers.get("X-Syntax-Mode-Prism") || undefined,
};
});
}