Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A LaTeX parser, a BibTeX parser, and utilities.

License

NotificationsYou must be signed in to change notification settings

tamuratak/latex-utensils

Repository files navigation

latex-utensilsCI Tests

A LaTeX parser, a BibTeX parser, and utilities.

The LaTeX parser is based on the following libraries:

Getting started

You can see LaTeX AST calling theluparse command. Without the option-i, you can obtain the output as JSON format.

$ cat sample/t.tex\documentclass{article}\usepackage{amsmath}\begin{document}ab cd $x + y$ e\begin{align}    i + j\end{align}\end{document}$ luparse --color -i sample/t.tex{  kind: 'ast.root',  content: [    {      kind: 'command',      name: 'documentclass',      args: [        {          kind: 'arg.group',          content: [ { kind: 'text.string', content: 'article' } ]        }      ]    },    { kind: 'softbreak' },    {      kind: 'command',      name: 'usepackage',      args: [        {          kind: 'arg.group',          content: [ { kind: 'text.string', content: 'amsmath' } ]        }      ]    },    {      kind: 'env',      name: 'document',      args: [],      content: [        { kind: 'text.string', content: 'ab' },        { kind: 'space' },        { kind: 'text.string', content: 'c' },        { kind: 'softbreak' },        { kind: 'text.string', content: 'd' },        { kind: 'space' },        {          kind: 'inlineMath',          content: [            { kind: 'math.character', content: 'x' },            { kind: 'math.character', content: '+' },            { kind: 'math.character', content: 'y' }          ]        },        { kind: 'space' },        { kind: 'text.string', content: 'e' },        {          kind: 'env.math.align',          name: 'align',          args: [],          content: [            { kind: 'math.character', content: 'i' },            { kind: 'math.character', content: '+' },            { kind: 'math.character', content: 'j' }          ]        }      ]    }  ],  comment: undefined}$ luparse --helpUsage: luparse [options]Options:  -i, --inspect            use util.inspect to output AST  --color                  turn on the color option of util.inspect  -l, --location           enable location  -c, --comment            enable comment  -s, --start-rule [rule]  set start rule. default is "Root".  -h, --help               output usage information

Usage

A typical usage is callinglatexParser.parse to parse LaTeX documents.

import{latexParser}from'latex-utensils';consttexString='a $x+y$ b';constast=latexParser.parse(texString);console.log(JSON.stringify(ast,undefined,'  '));

latexParser.parse returns anAstRoot object ifstartRule is'Root',

typeAstRoot={kind:'ast.root';content:Node[];comment?:Comment[];}

Docs

Repository

Development

To lint changes, run

npm run lint

To build, run

npm run build

To test, run

npm run test

About

A LaTeX parser, a BibTeX parser, and utilities.

Topics

Resources

License

Stars

Watchers

Forks

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp