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
1/* eslint no-console:0 */2/**3 * This is the main entry point for KaTeX. Here, we expose functions for4 * rendering expressions either to DOM nodes or to markup strings.5 *6 * We also expose the ParseError class to check if errors thrown from KaTeX are7 * errors in the expression, or errors in javascript handling.8 */9 10import ParseError from "./src/ParseError";11import Settings, {SETTINGS_SCHEMA} from "./src/Settings";12 13import {buildTree, buildHTMLTree} from "./src/buildTree";14import parseTree from "./src/parseTree";15import {makeSpan} from "./src/buildCommon";16import {17 Span,18 Anchor,19 SymbolNode,20 SvgNode,21 PathNode,22 LineNode,23} from "./src/domTree";24 25import type {SettingsOptions} from "./src/Settings";26import type {AnyParseNode} from "./src/parseNode";27import type {DomSpan} from "./src/domTree";28 29import {defineSymbol} from './src/symbols';30import defineFunction from './src/defineFunction';31import defineMacro from './src/defineMacro';32import {setFontMetrics} from './src/fontMetrics';33 34declare let __VERSION__: string;35 36/**37 * Parse and build an expression, and place that expression in the DOM node38 * given.39 */40let render: (41 expression: string,42 baseNode: Node,43 options: SettingsOptions,44) => void = function(45 expression: string,46 baseNode: Node,47 options: SettingsOptions,48) {49 baseNode.textContent = "";50 const node = renderToDomTree(expression, options).toNode();51 baseNode.appendChild(node);52};53 54// KaTeX's styles don't work properly in quirks mode. Print out an error, and55// disable rendering.56if (typeof document !== "undefined") {57 if (document.compatMode !== "CSS1Compat") {58 typeof console !== "undefined" && console.warn(59 "Warning: KaTeX doesn't work in quirks mode. Make sure your " +60 "website has a suitable doctype.");61 62 render = function() {63 throw new ParseError("KaTeX doesn't work in quirks mode.");64 };65 }66}67 68/**69 * Parse and build an expression, and return the markup for that.70 */71const renderToString = function(72 expression: string,73 options: SettingsOptions,74): string {75 const markup = renderToDomTree(expression, options).toMarkup();76 return markup;77};78 79/**80 * Parse an expression and return the parse tree.81 */82const generateParseTree = function(83 expression: string,84 options?: SettingsOptions,85): AnyParseNode[] {86 const settings = new Settings(options);87 return parseTree(expression, settings);88};89 90/**91 * If the given error is a KaTeX ParseError and options.throwOnError is false,92 * renders the invalid LaTeX as a span with hover title giving the KaTeX93 * error message. Otherwise, simply throws the error.94 */95const renderError = function(96 error: unknown,97 expression: string,98 options: Settings,99) {100 if (options.throwOnError || !(error instanceof ParseError)) {101 throw error;102 }103 const node = makeSpan(["katex-error"],104 [new SymbolNode(expression)]);105 node.setAttribute("title", error.toString());106 node.setAttribute("style", `color:${options.errorColor}`);107 return node;108};109 110/**111 * Generates and returns the katex build tree. This is used for advanced112 * use cases (like rendering to custom output).113 */114const renderToDomTree = function(115 expression: string,116 options: SettingsOptions,117): DomSpan {118 const settings = new Settings(options);119 try {120 const tree = parseTree(expression, settings);121 return buildTree(tree, expression, settings);122 } catch (error) {123 return renderError(error, expression, settings);124 }125};126 127/**128 * Generates and returns the katex build tree, with just HTML (no MathML).129 * This is used for advanced use cases (like rendering to custom output).130 */131const renderToHTMLTree = function(132 expression: string,133 options: SettingsOptions,134): DomSpan {135 const settings = new Settings(options);136 try {137 const tree = parseTree(expression, settings);138 return buildHTMLTree(tree, expression, settings);139 } catch (error) {140 return renderError(error, expression, settings);141 }142};143 144const version = __VERSION__;145 146const __domTree = {147 Span,148 Anchor,149 SymbolNode,150 SvgNode,151 PathNode,152 LineNode,153};154 155// ESM exports156export {157 version,158 render,159 renderToString,160 ParseError,161 SETTINGS_SCHEMA,162 generateParseTree as __parse,163 renderToDomTree as __renderToDomTree,164 renderToHTMLTree as __renderToHTMLTree,165 setFontMetrics as __setFontMetrics,166 defineSymbol as __defineSymbol,167 defineFunction as __defineFunction,168 defineMacro as __defineMacro,169 __domTree,170};171 172// CJS exports and ESM default export173export default {174 /**175 * Current KaTeX version176 */177 version,178 /**179 * Renders the given LaTeX into an HTML+MathML combination, and adds180 * it as a child to the specified DOM node.181 */182 render,183 /**184 * Renders the given LaTeX into an HTML+MathML combination string,185 * for sending to the client.186 */187 renderToString,188 /**189 * KaTeX error, usually during parsing.190 */191 ParseError,192 /**193 * The schema of Settings194 */195 SETTINGS_SCHEMA,196 /**197 * Parses the given LaTeX into KaTeX's internal parse tree structure,198 * without rendering to HTML or MathML.199 *200 * NOTE: This method is not currently recommended for public use.201 * The internal tree representation is unstable and is very likely202 * to change. Use at your own risk.203 */204 __parse: generateParseTree,205 /**206 * Renders the given LaTeX into an HTML+MathML internal DOM tree207 * representation, without flattening that representation to a string.208 *209 * NOTE: This method is not currently recommended for public use.210 * The internal tree representation is unstable and is very likely211 * to change. Use at your own risk.212 */213 __renderToDomTree: renderToDomTree,214 /**215 * Renders the given LaTeX into an HTML internal DOM tree representation,216 * without MathML and without flattening that representation to a string.217 *218 * NOTE: This method is not currently recommended for public use.219 * The internal tree representation is unstable and is very likely220 * to change. Use at your own risk.221 */222 __renderToHTMLTree: renderToHTMLTree,223 /**224 * extends internal font metrics object with a new object225 * each key in the new object represents a font name226 */227 __setFontMetrics: setFontMetrics,228 /**229 * adds a new symbol to builtin symbols table230 */231 __defineSymbol: defineSymbol,232 /**233 * adds a new function to builtin function list,234 * which directly produce parse tree elements235 * and have their own html/mathml builders236 */237 __defineFunction: defineFunction,238 /**239 * adds a new macro to builtin macro list240 */241 __defineMacro: defineMacro,242 /**243 * Expose the dom tree node types, which can be useful for type checking nodes.244 *245 * NOTE: These methods are not currently recommended for public use.246 * The internal tree representation is unstable and is very likely247 * to change. Use at your own risk.248 */249 __domTree,250};251 