latex-utensils is a TypeScript library providing robust parsing capabilities for LaTeX and BibTeX documents, along with various utility functions. Its current stable version is 7.0.0. The project demonstrates an active release cadence, with frequent beta releases preceding major versions, signaling continuous development and refinement. It uniquely offers both LaTeX and BibTeX parsers within a unified package, building upon established parser foundations like LaTeX.js and latex-parser to deliver comprehensive functionality. This library is particularly well-suited for applications that require programmatic interaction with LaTeX source code, such as creating linters, IDE extensions, or advanced document analysis tools. It achieves this by transforming raw LaTeX strings into a structured Abstract Syntax Tree (AST) that is easily traversable and manipulable. A key differentiator is its inclusion of full TypeScript type definitions, significantly improving developer experience and ensuring type safety when integrating parsing logic into modern JavaScript and TypeScript environments.
npm install latex-utensilsVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a LaTeX string into an Abstract Syntax Tree (AST) and basic AST traversal to find commands.
Consult the official API documentation for any changes to AST node types or parser configuration. Update existing parsing logic to match the new structure if necessary.
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` for Node.js) and use `import ... from 'latex-utensils';`. For older CommonJS projects, consider using dynamic `import()` or a transpilation step.
For performance-critical applications, consider optimizing input size, pre-processing documents, or implementing caching mechanisms for ASTs. Profile parsing operations to identify bottlenecks.
Ensure that the input string provided to `latexParser.parse` is correctly encoded, preferably UTF-8. If reading from a file, explicitly specify UTF-8 encoding during file read operations.
Switch to ES Module imports (`import { ... } from 'latex-utensils';`) or configure your project for ESM. For Node.js, add `"type": "module"` to your `package.json`.Ensure you are using `import { latexParser } from 'latex-utensils';` and that `latexParser` is properly destructured from the named export.Review the LaTeX input string for syntax errors. The error message usually provides line and column numbers to help pinpoint the issue. Ensure all environments are properly closed and commands have correct arguments.
No dependency data recorded yet.