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 defineFunction from "../defineFunction";2import type {Measurement} from "../units";3import {calculateSize, validUnit, makeEm} from "../units";4import ParseError from "../ParseError";5import {Img} from "../domTree";6import {MathNode} from "../mathMLTree";7import {assertNodeType} from "../parseNode";8import type {CssStyle} from "../domTree";9 10const sizeData = function(str: string): Measurement {11 if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) {12 // str is a number with no unit specified.13 // default unit is bp, per graphix package.14 return {number: +str, unit: "bp"};15 } else {16 const match = (/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(str);17 if (!match) {18 throw new ParseError("Invalid size: '" + str19 + "' in \\includegraphics");20 }21 const data = {22 number: +(match[1] + match[2]), // sign + magnitude, cast to number23 unit: match[3],24 };25 if (!validUnit(data)) {26 throw new ParseError("Invalid unit: '" + data.unit27 + "' in \\includegraphics.");28 }29 return data;30 }31};32 33defineFunction({34 type: "includegraphics",35 names: ["\\includegraphics"],36 props: {37 numArgs: 1,38 numOptionalArgs: 1,39 argTypes: ["raw", "url"],40 allowedInText: false,41 },42 handler: ({parser}, args, optArgs) => {43 let width = {number: 0, unit: "em"};44 let height = {number: 0.9, unit: "em"}; // sorta character sized.45 let totalheight = {number: 0, unit: "em"};46 let alt = "";47 48 if (optArgs[0]) {49 const attributeStr = assertNodeType(optArgs[0], "raw").string;50 51 // Parser.js does not parse key/value pairs. We get a string.52 const attributes = attributeStr.split(",");53 for (let i = 0; i < attributes.length; i++) {54 const keyVal = attributes[i].split("=");55 if (keyVal.length === 2) {56 const str = keyVal[1].trim();57 switch (keyVal[0].trim()) {58 case "alt":59 alt = str;60 break;61 case "width":62 width = sizeData(str);63 break;64 case "height":65 height = sizeData(str);66 break;67 case "totalheight":68 totalheight = sizeData(str);69 break;70 default:71 throw new ParseError("Invalid key: '" + keyVal[0] +72 "' in \\includegraphics.");73 }74 }75 }76 }77 78 const src = assertNodeType(args[0], "url").url;79 80 if (alt === "") {81 // No alt given. Use the file name. Strip away the path.82 alt = src;83 alt = alt.replace(/^.*[\\/]/, '');84 alt = alt.substring(0, alt.lastIndexOf('.'));85 }86 87 if (!parser.settings.isTrusted({88 command: "\\includegraphics",89 url: src,90 })) {91 return parser.formatUnsupportedCmd("\\includegraphics");92 }93 94 return {95 type: "includegraphics",96 mode: parser.mode,97 alt: alt,98 width: width,99 height: height,100 totalheight: totalheight,101 src: src,102 };103 },104 htmlBuilder: (group, options) => {105 const height = calculateSize(group.height, options);106 let depth = 0;107 108 if (group.totalheight.number > 0) {109 depth = calculateSize(group.totalheight, options) - height;110 }111 112 let width = 0;113 if (group.width.number > 0) {114 width = calculateSize(group.width, options);115 }116 117 const style: CssStyle = {height: makeEm(height + depth)};118 if (width > 0) {119 style.width = makeEm(width);120 }121 if (depth > 0) {122 style.verticalAlign = makeEm(-depth);123 }124 125 const node = new Img(group.src, group.alt, style);126 node.height = height;127 node.depth = depth;128 129 return node;130 },131 mathmlBuilder: (group, options) => {132 const node = new MathNode("mglyph", []);133 node.setAttribute("alt", group.alt);134 135 const height = calculateSize(group.height, options);136 let depth = 0;137 if (group.totalheight.number > 0) {138 depth = calculateSize(group.totalheight, options) - height;139 node.setAttribute("valign", makeEm(-depth));140 }141 node.setAttribute("height", makeEm(height + depth));142 143 if (group.width.number > 0) {144 const width = calculateSize(group.width, options);145 node.setAttribute("width", makeEm(width));146 }147 node.setAttribute("src", group.src);148 return node;149 },150});151 