texshake

7.0.0 • Public • Published

texshake

Shake your LaTeX syntax tree!

echo '\\newif\\ifah\\ahtrue\\ifah Shake it! :) \\else Do not shake it... :( \\fi' | texshake
 Shake it! :)

License Version Build Dependencies Dev dependencies GitHub issues Downloads

Code issues Code maintainability Code coverage (cov) Code coverage (clim) Code technical debt

Install it

$ npm i -g texshake

Shake away

$ texshake < 'my-awesome-latex-file-before.tex' > 'my-awesome-latex-file-after.tex'

Shake what?

\if... \else \fi conditionals

Prunes dead branches for \iftrue's, \iffalse's, and user-defined \if... variables.

\abctrue\ifabc ah\else oh\fi ~ ah

% comments

Only keeps the first % character of each comment.

hello, world % Lorem ipsum dolor sit amet ~ hello, world %

\def and \newcommand user-defined macros

Expands each user-defined macro and removes their definition.

\newcommand\swap[2]{#2#1}\swap{a}{b} ~ ba

\newenvironment user-defined environments

\newenvironment{items}{\begin{itemize}}{\end{itemize}}\begin{items}\end{items} ~ \begin{itemize}\end{itemize}

Altogether now!

\myfalse\ifmy\def\xyz{A cat.}\else\def\xyz{A dog.}\fi\xyz% $#@! ~ A dog.%

What for?

I use it for scientific publications. I often need different versions of the same paper for different occasions: conference proceedings, journal version, arXiv preprint. I just write the content once, with the right conditionals, macro definitions and \input calls. I flatten everything using flatex, shake the document with texshake, and finally get rid of all extraneous blanks with textrim.

How does it work?

It uses @aureooms/js-tape and @aureooms/js-grammar under the hood.

The tokens are produced according to this file and the shaking logic lies in this file.

Related

Package Sidebar

Install

npm i texshake

Weekly Downloads

0

Version

7.0.0

License

AGPL-3.0

Unpacked Size

239 kB

Total Files

17

Last publish

Collaborators

  • aureooms