path_lang.ts

Which syntax a file is written in, from its path — for highlighting source with fuz_code. Like diskfile_content_kind.ts, it reads the extension alone, since the file index says nothing about a file's type.

view source

Declarations
#

3 declarations

LANG_BY_EXTENSION
#

path_lang.ts view source

ReadonlyMap<string, string>

type ReadonlyMap<string, string>

import {LANG_BY_EXTENSION} from '@fuzdev/zzz/path_lang.js';

File extensions (lowercase, without the dot) and the fuz_code language each is highlighted as — a primary id registered on fuz_code's syntax_styler_global. JavaScript is highlighted by the TypeScript lexer (it registers js as an alias); JSX and TSX are left out, since that lexer doesn't read their markup.

lang_for_path
#

path_lang.ts view source

(path: string): string | null import {lang_for_path} from '@fuzdev/zzz/path_lang.js';

The fuz_code language to highlight the file at path as, by its extension (case-insensitive), or null when there's none — which disables highlighting.

path

the file's path or name

type string

returns

string | null

to_path_extension
#

path_lang.ts view source

(path: string): string | null import {to_path_extension} from '@fuzdev/zzz/path_lang.js';

The extension of the file at path, lowercased and without the dot: the text after the last . of its last segment, null when that segment has no .. A dotfile's name is its extension (.bashrc → bashrc), and a trailing dot gives ''.

path

the file's path or name

type string

returns

string | null

Imported by
#