Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import { decodeXML, decodeHTML, DecodingMode } from "./decode.js";2import { encodeHTML, encodeNonAsciiHTML } from "./encode.js";3import {4 encodeXML,5 escapeUTF8,6 escapeAttribute,7 escapeText,8} from "./escape.js";9 10/** The level of entities to support. */11export enum EntityLevel {12 /** Support only XML entities. */13 XML = 0,14 /** Support HTML entities, which are a superset of XML entities. */15 HTML = 1,16}17 18export enum EncodingMode {19 /**20 * The output is UTF-8 encoded. Only characters that need escaping within21 * XML will be escaped.22 */23 UTF8,24 /**25 * The output consists only of ASCII characters. Characters that need26 * escaping within HTML, and characters that aren't ASCII characters will27 * be escaped.28 */29 ASCII,30 /**31 * Encode all characters that have an equivalent entity, as well as all32 * characters that are not ASCII characters.33 */34 Extensive,35 /**36 * Encode all characters that have to be escaped in HTML attributes,37 * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.38 */39 Attribute,40 /**41 * Encode all characters that have to be escaped in HTML text,42 * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.43 */44 Text,45}46 47export interface DecodingOptions {48 /**49 * The level of entities to support.50 * @default {@link EntityLevel.XML}51 */52 level?: EntityLevel;53 /**54 * Decoding mode. If `Legacy`, will support legacy entities not terminated55 * with a semicolon (`;`).56 *57 * Always `Strict` for XML. For HTML, set this to `true` if you are parsing58 * an attribute value.59 *60 * The deprecated `decodeStrict` function defaults this to `Strict`.61 *62 * @default {@link DecodingMode.Legacy}63 */64 mode?: DecodingMode | undefined;65}66 67/**68 * Decodes a string with entities.69 *70 * @param input String to decode.71 * @param options Decoding options.72 */73export function decode(74 input: string,75 options: DecodingOptions | EntityLevel = EntityLevel.XML,76): string {77 const level = typeof options === "number" ? options : options.level;78 79 if (level === EntityLevel.HTML) {80 const mode = typeof options === "object" ? options.mode : undefined;81 return decodeHTML(input, mode);82 }83 84 return decodeXML(input);85}86 87/**88 * Decodes a string with entities. Does not allow missing trailing semicolons for entities.89 *90 * @param input String to decode.91 * @param options Decoding options.92 * @deprecated Use `decode` with the `mode` set to `Strict`.93 */94export function decodeStrict(95 input: string,96 options: DecodingOptions | EntityLevel = EntityLevel.XML,97): string {98 const normalizedOptions =99 typeof options === "number" ? { level: options } : options;100 normalizedOptions.mode ??= DecodingMode.Strict;101 102 return decode(input, normalizedOptions);103}104 105/**106 * Options for `encode`.107 */108export interface EncodingOptions {109 /**110 * The level of entities to support.111 * @default {@link EntityLevel.XML}112 */113 level?: EntityLevel;114 /**115 * Output format.116 * @default {@link EncodingMode.Extensive}117 */118 mode?: EncodingMode;119}120 121/**122 * Encodes a string with entities.123 *124 * @param input String to encode.125 * @param options Encoding options.126 */127export function encode(128 input: string,129 options: EncodingOptions | EntityLevel = EntityLevel.XML,130): string {131 const { mode = EncodingMode.Extensive, level = EntityLevel.XML } =132 typeof options === "number" ? { level: options } : options;133 134 switch (mode) {135 case EncodingMode.UTF8: {136 return escapeUTF8(input);137 }138 case EncodingMode.Attribute: {139 return escapeAttribute(input);140 }141 case EncodingMode.Text: {142 return escapeText(input);143 }144 case EncodingMode.ASCII: {145 return level === EntityLevel.HTML146 ? encodeNonAsciiHTML(input)147 : encodeXML(input);148 }149 // eslint-disable-next-line unicorn/no-useless-switch-case150 case EncodingMode.Extensive:151 default: {152 return level === EntityLevel.HTML153 ? encodeHTML(input)154 : encodeXML(input);155 }156 }157}158 159export {160 encodeXML,161 escape,162 escapeUTF8,163 escapeAttribute,164 escapeText,165} from "./escape.js";166 167export {168 encodeHTML,169 encodeNonAsciiHTML,170 // Legacy aliases (deprecated)171 encodeHTML as encodeHTML4,172 encodeHTML as encodeHTML5,173} from "./encode.js";174 175export {176 EntityDecoder,177 DecodingMode,178 decodeXML,179 decodeHTML,180 decodeHTMLStrict,181 decodeHTMLAttribute,182 // Legacy aliases (deprecated)183 decodeHTML as decodeHTML4,184 decodeHTML as decodeHTML5,185 decodeHTMLStrict as decodeHTML4Strict,186 decodeHTMLStrict as decodeHTML5Strict,187 decodeXML as decodeXMLStrict,188} from "./decode.js";189 