### Define Derivative Command Patterns with Regex Syntax Source: https://github.com/wyatt915/treeblood/blob/main/TODO.md Example patterns for derivative commands using a condensed regex-like syntax. ```go dvConsumes := []CmdArgExpr{ "[,]?{}?'/'?'!'?{,}" } ``` -------------------------------- ### Define Derivative Command Patterns Source: https://github.com/wyatt915/treeblood/blob/main/TODO.md Example patterns for derivative commands using explicit argument sequences. ```go dvConsumes := []CmdArgExpr{ "[,]{,}", "[,]{}{,}", "[,]{}'/'{,}", "[,]{}'!'{,}", "[,]{}'/''!'{,}", } ``` -------------------------------- ### Initialize WebAssembly Module Source: https://github.com/wyatt915/treeblood/blob/main/cmd/wasm-demo/index.html Loads and executes the TreeBlood WebAssembly binary using the Go runtime. ```javascript const go = new Go(); WebAssembly.instantiateStreaming(fetch("treeblood.wasm"), go.importObject).then((result) => { go.run(result.instance); }); ``` -------------------------------- ### Import TreeBlood Library Source: https://github.com/wyatt915/treeblood/blob/main/README.md Include the library in your Go project. ```go import "github.com/wyatt915/treeblood" ``` -------------------------------- ### Convert LaTeX to MathML with DisplayStyle Source: https://github.com/wyatt915/treeblood/blob/main/README.md Perform a quick one-off conversion of a LaTeX string to display-style MathML. ```go package main import ( "fmt" "github.com/wyatt915/treeblood" ) func main() { tex := `x=\frac{-b\pm\sqrt{b^2 - 4ac}{2a}` mml, err := treeblood.DisplayStyle(tex, nil) if err == nil { fmt.Println(mml) } } ``` -------------------------------- ### treeblood.NewDocument(macros map[string]string, numbering bool) Source: https://github.com/wyatt915/treeblood/blob/main/README.md Creates a Pitziil object to manage document-wide settings, macros, and equation numbering for multiple conversions. ```APIDOC ## treeblood.NewDocument ### Description Initializes a new document context (Pitziil) for batch processing LaTeX equations. ### Parameters - **macros** (map[string]string) - Optional - Precompiled macros to apply to all equations in the document. - **numbering** (bool) - Required - Whether to enable equation numbering. ### Returns - **doc** (Pitziil) - A document object that provides DisplayStyle and InlineStyle methods for batch processing. ``` -------------------------------- ### Define Extension Function Types Source: https://github.com/wyatt915/treeblood/blob/main/TODO.md Defines the core structures and function signature for registering custom command extensions. ```go type CmdArg struct{ toks []Token kind CmdArgKind } type ExtFunc func(n *MMLNode, ctx parseContext, args []CmdArg) error // RegisterExtension associates all commands provided in the slice with the function f. // the 'consumes' argument behaves like a list of regular expressions that // define what types of arguments the command may accept. func RegisterExtension(commands []string, f ExtFunc, consumes []CmdArgExpr) ``` -------------------------------- ### Define Precompiled Macros Source: https://github.com/wyatt915/treeblood/blob/main/README.md Define a map of macros to be used across document conversions, following MathJax-style syntax. ```go macros := map[string]string{ "R": `\mathbb{R}`, "cuberoot": `\sqrt[3]{#1}`, "pathological": `\frac{\pathological}{2}`, "mutuallydependentA": `\thefrac{\mutuallydependentB}{#1}`, "mutuallydependentB": `\thefrac{\mutuallydependentA}{#1}`, "customint": `\int_{#1}^{#2}{#3}\mathrm{d}{#4}`, "thefrac": `\frac{1 + #1}{1 - #2}`, } ``` -------------------------------- ### Define Command Argument Expression Types Source: https://github.com/wyatt915/treeblood/blob/main/TODO.md Defines the structures and constants for representing command argument flavors and expressions. ```go type CmdArgExpr type CmdFlavor uint64 const ( CF_LITERAL CmdFlavor = iota << 1 CF_GROUPED CF_TOKEN CF_OPTION CF_COMMA_SEP ) type CmdArg struct{ Flavor CmdFlavor Value []Token } ``` -------------------------------- ### Process Multiple Equations with Pitziil Source: https://github.com/wyatt915/treeblood/blob/main/README.md Use a Pitziil document object to manage settings and process a collection of LaTeX expressions. ```go import "github.com/wyatt915/treeblood" func convert(expressions []string) []string{ result := make([]string, 0) doc := NewDocument(nil, false) // Create a Pitziil; no macros, no equation numbering for _, latex := range expressions{ mathML, err := doc.DisplayStyle(latex) if err != nil { result = append(result, mathML) } } return result } ``` -------------------------------- ### treeblood.DisplayStyle(tex string, macros map[string]string) Source: https://github.com/wyatt915/treeblood/blob/main/README.md Converts a LaTeX string into MathML using display style, which renders with larger text and centering. This is suitable for standalone equations. ```APIDOC ## treeblood.DisplayStyle ### Description Converts a LaTeX expression into MathML using display style formatting. ### Parameters - **tex** (string) - Required - The LaTeX equation string to convert. - **macros** (map[string]string) - Optional - A map of macro definitions where keys are command names (without backslash) and values are definitions. ### Returns - **mml** (string) - The resulting MathML string. - **err** (error) - An error object if the conversion fails. ``` -------------------------------- ### treeblood.InlineStyle(tex string, macros map[string]string) Source: https://github.com/wyatt915/treeblood/blob/main/README.md Converts a LaTeX string into MathML using inline style, suitable for rendering within a paragraph of text. ```APIDOC ## treeblood.InlineStyle ### Description Converts a LaTeX expression into MathML using inline style formatting. ### Parameters - **tex** (string) - Required - The LaTeX equation string to convert. - **macros** (map[string]string) - Optional - A map of macro definitions. ### Returns - **mml** (string) - The resulting MathML string. - **err** (error) - An error object if the conversion fails. ``` -------------------------------- ### Configure Custom Font for Math Source: https://github.com/wyatt915/treeblood/blob/main/cmd/wasm-demo/index.html Defines the TreeBlood font face and applies it to math elements. ```css @font-face{ font-family: "TreeBlood"; src: url("./Treeblood-LatinModern.woff2") format('woff2'); } math{ font-family: "TreeBlood"; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.