texwritten
v0.1.0
Published
Reusable LaTeX processing utilities for converting handwritten math to LaTeX.
Readme
@texwritten/core
Reusable LaTeX processing utilities for converting handwritten math to LaTeX.
Installation
npm install @texwritten/coreUsage
import { cleanOcrResult, buildTexDocument, confidenceLabel } from "@texwritten/core";
// Clean OCR result
const cleaned = cleanOcrResult(ocrResult);
// Build LaTeX document
const latex = buildTexDocument(cleaned.full_latex, "My Notes");
// Check confidence
console.log(confidenceLabel(cleaned.confidence));API
Types
OcrBlock- Single block of OCR outputOcrResult- Complete OCR result with blocksDetectedLanguage- Language detection result
Cleaner
normalizeLatex()- Normalize unicode characters to LaTeXstripDisplayDelimiters()- Remove display math delimitershasBalancedBraces()- Check brace balancevalidateLatex()- Full validation with warningscleanBlockLatex()- Clean single blockcleanOcrResult()- Clean full result
Formatter
buildTexDocument()- Wrap in full TeX documentbuildMarkdownDocument()- Convert to MarkdownescapeLatexText()- Escape special characters
Heuristics
buildHeuristicResult()- Build result from raw textplainMathToLatex()- Convert plain math to LaTeX
Confidence
clampConfidence()- Clamp value to [0, 1]averageConfidence()- Average across blocksresultConfidence()- Get result confidenceconfidenceLabel()- Get "low" / "medium" / "good" label
