Skip to main content

Crate texplain

Crate texplain 

Source
Expand description

Strip LaTeX down to the prose inside it, keeping every line where it was.

Line N of the output is line N of the input .tex. Markup lines come back empty and prose lines come back as prose, so a position reported against the stripped text is a position in the source: an alert on line 42 is an alert on line 42 of the .tex.

The output contains no backslashes, no { or }, and no LaTeX commands, only the human-readable text a linter such as Vale should be checking.

§API

FunctionResponsibility
stripStrip a whole document, preserving line numbers
strip_readerThe same, reading the source from an io::Read
strip_linePer-line LaTeX parsing (commands, braces, comments)
is_remnantIs this line leftover markup debris, not prose?

strip is the entry point most callers want. The other two are the pieces it is built from, exposed for callers assembling their own pipeline.

strip does more than apply them line by line: it also tracks state that spans lines (blanked environments, multi-line \author/\title blocks), so it is not simply strip_line in a loop.

Functions§

is_remnant
Return true if the line is leftover LaTeX debris rather than prose.
strip
Strip a LaTeX source to plain text, preserving line numbers.
strip_line
Strip a single line of LaTeX to plain text.
strip_reader
Strip a LaTeX source read from reader, preserving line numbers.