char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Constants refactor (#26908)e21152dc9

char/aliceai-t5-moe
2.1 KiB50 linesraw
1// Constants for the markdown code-block renderer: language/fence handling and CSS classes.
2
3/** Parsing and escaping helpers for the markdown code-block renderer. */
4export const CODE_BLOCK = {
5	AMPERSAND_REGEX: /&/g,
6	/** Language fallback used when no language is specified. */
7	DEFAULT_LANGUAGE: 'text',
8	/** Matches opening/closing markdown code fences. */
9	FENCE_PATTERN: /^```|\n```/g,
10	GT_REGEX: />/g,
11	/** Matches the language specifier at the start of a code fence. */
12	LANG_PATTERN: /^(\w*)\n?/,
13	LT_REGEX: /</g,
14
15	// Matches the `text:` prefix that file-type identifiers use to denote a
16	// plain-text language (e.g. `text:typescript`). Used by tool-call renderers
17	// to recover the underlying highlight.js language.
18	TEXT_LANGUAGE_PREFIX_REGEX: /^text:/,
19	// Whitespace-only empty lines (between start of string and first non-empty line).
20	// Used by trimCodePadding to drop leading/trailing phantom blank rows from LLM
21	// payload wrappers without touching internal blank lines.
22	TRIM_LEADING_PADDING_REGEX: /^(?:[ \t]*\n)+/,
23
24	TRIM_TRAILING_PADDING_REGEX: /(?:\n[ \t]*)+$/
25} as const;
26
27// Matches either Unix or Windows path separators so `String.split(REGEX)` can
28// recover the trailing file-name segment from either `/foo/bar.txt` or
29// `C:\foo\bar.txt`. Used wherever a parameter accepts a user-supplied path.
30export const FILE_PATH_SEPARATOR_REGEX = /[\\/]/;
31
32// Separates a file name from its extension, e.g. the '.' in `cover.png`.
33export const FILE_EXTENSION_SEPARATOR = '.';
34
35// Matches the `text:` prefix that file-type identifiers use to denote a
36// plain-text language (e.g. `text:typescript`). Used by tool-call renderers
37// to recover the underlying highlight.js language.
38export const TEXT_LANGUAGE_PREFIX_REGEX = /^text:/;
39
40/** CSS classes applied by the markdown code-block renderer. */
41export const CODE_BLOCK_CLASS = {
42	ACTIONS: 'code-block-actions',
43	COPY_BTN: 'copy-code-btn',
44	HEADER: 'code-block-header',
45	LANGUAGE: 'code-language',
46	PREVIEW_BTN: 'preview-code-btn',
47	RELATIVE: 'relative',
48	SCROLL_CONTAINER: 'code-block-scroll-container',
49	WRAPPER: 'code-block-wrapper'
50} as const;