GithubHelp home page GithubHelp logo

latexjs / chktex.js Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 272 KB

ChkTeX 1.7.6 for node environments

License: Other

C 74.48% Perl 0.11% Makefile 3.80% C++ 1.07% TeX 2.35% Shell 9.44% Roff 3.88% M4 4.62% Objective-C 0.11% JavaScript 0.14%
latex chktex emscripten lint

chktex.js's Introduction

ChkTeX-JS

This is a lightly modified version of ChkTeX 1.7.6 that has been adapted to work inside a Node JS environment with Emscripten.

Building this code produces a single chktex.js Node module that is around 457kb (111kb compressed) that can be used interchangeably with chktex binaries. By that I mean:

> ./chktex.js -a -flag -or -two ./some/tex/file.tex

should perform identically to:

> chktex -a -flag -or -two ./some/tex/file.tex

If you find anything where this isn't true - it's a bug, please open an issue.

Prerequisites

Building

To build a release version of chktex.js just run

> ./build.sh

See the top of this script for more info (including how to make debug builds) if you run into issues.

FAQ

Why do this?

Well firstly it was a fun way to learn emscripten. :)

Secondly I'm a contributor to the LaTeX Workshop VS Code extension which includes rich ChkTeX support. This is an experiment to see if it would be possible to provide hassle-free LaTeX linting to all users by aiding them to install a version of chktex on their system if they don't already have it installed. This has the benefit that we can offer a consistent experience across platforms by helping users to download a 'binary' of chktex onto their system where we know it's up to date and works the same across platforms.

Can this be used in the browser?

Presently, no. For now I mapped through the FS access explicitly for Node (see Utility.h for details). This means we can offer a drop-in replacement for the existing chktex binary. For instance, by default chktex will follow other latex files included with \input{} and lint those also. This means chktex needs to call fopen of it's own valition and have something happen, which ain't happening in the browser sandbox.

However, chktex can be given input on stdin for a single file and you can disable following to other files with -I0. It would only be an hour or two's work to take this and get it working in the browser, and least for linting one file at a time.

How's the performance?

It's not bad. I actually discovered that at least on my MaxTeX install it seems chktex was compiled without optimizations! Given this, chktex.js is quite competitive linting my thesis:

> time node ~/gits/chktex-js/chktex.js thesis.tex > /dev/null
ChkTeX v1.7.6 - Copyright 1995-96 Jens T. Berger Thielemann.
Compiled with POSIX extended regex support.
No errors printed; 93 warnings printed; No user suppressed warnings; 92 line suppressed warnings.
See the manual for how to suppress some or all of these warnings/errors.

real	0m0.555s
user	0m0.709s
sys	0m0.042s

vs

> time chktex thesis.tex > /dev/null
ChkTeX v1.7.4 - Copyright 1995-96 Jens T. Berger Thielemann.
Compiled with POSIX extended regex support.
No errors printed; No warnings printed; No user suppressed warnings; 92 line suppressed warnings.

real	0m0.206s
user	0m0.172s
sys	0m0.013s

So, within a factor of two.

That's all folks!

Now follows is the original README of ChkTeX:

ChkTeX

ChkTeX is a tool to check for common errors in LaTeX files. It also supports checking CWEB files (uses a perl5 script). It is highly customizable allowing you turn off any warnings you don't like, as well as add your own warnings. It works easily with Emacs and AUCTeX, but should also be easy to interface with other editors. If you have interfaced ChkTeX with another editor, please contribute how you did it.

It is important to remember that ChkTeX is only intended as a guide to fixing faults. It is by no means always correct. This means that correct LaTeX code may produce errors in ChkTeX, and vice versa: incorrect LaTeX code may pass silently through. If you have ideas for new warnings or ways in which current warnings could be improved, please report them on the bug tracker.

For complete documentation see the manual.

ChkTeX is released under the GNU Public License version 2 or greater.

chktex.js's People

Contributors

jabooth avatar

Watchers

James Cloos avatar  avatar

Forkers

seuliang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.