Skip to main content

Clean Latex sources without loosing track of positions

Reason this release was yanked:

Deprecated because it sucks

Project description

Goal

Protex aims at providing a flexible, extensible and interfaced way to remove TeX macros from a TeX/LaTeX document while keeping the mapping of position from cleaned text to source. This should make it easier to apply different language checkers to the plain text and convert the plain text position to source positions. When possible the resulting file should also be a reasonably readable text file (no big blanks, no strange holes...).

Non-goal

This project won't try to parse TeX in a complex way. The cleaning has to be extensible, but nor recursive, neither Turing complete as TeX is itself.

Principle

A command prototype set is first built from the default commands.json, updated by the user ~/.commands.json (if it exists) and then all the commands.json files found in the file tree from root to the current directory.

A command prototype tell the parser how many arguments at maximum take the command and how to use them. There are four sections in commands.json files. The three below consist in a list of special prototype:

  • print_name: the command take no argument and is replace by its name (ex: \phi, \sum)

  • print_one: the command take one argument and print it unchanged

  • discard: the command take up to 100 arguments and print nothing The fourth section is other and have a mapping as value. The mapping is of the form {<command_name>: [<# max args>, <template>]}. The template is a string where everything will be printed as is but:

  • %0 will be replace with the command name

  • %1 will be replaced with the first argument (and so on for %2, %3 etc without limit)

  • %% will be replaced with a raw %

  • % followed by anything else will not be replaced

When parsing the TeX source, the argument collection end as soon as one of those conditions is fulfilled:

  • the max number of arguments have been reached
  • the next token is a blank
  • the next token is a "word" of more than one letter (a word a sequence of contiguous everything that is neither whitespace nor a special thing in TeX (comments, commands, curly brackets, square bracket), be carefull, punctuation like "." is a valid one letter word that can be the last argument of a command)
  • the last argument was a non bracketed one letter "word"

Those rules can seem a bit convoluted but if you have a valid TeX document and valid command prototypes, the result should be what you expect.

Installation

From source: in the folder of this README run pip install . in a terminal. With pip directly: run pip install -U protex

Usage

See the command line help by running protex or python -m protex.

Notes

The requirements.txt is only for development and test, not for normal usage. There are no dependencies at all.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protex-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

protex-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file protex-0.1.0.tar.gz.

File metadata

  • Download URL: protex-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for protex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5fa627e5091f20d70072a18c0f3271c318e33d20b1e1d4d3099256bcddf46539
MD5 0d5bb6136237f88a949832c82bc14fc6
BLAKE2b-256 a44d0582836be6a19d0dce97c7d129308643615e57e4b695824e3cf25926eece

See more details on using hashes here.

File details

Details for the file protex-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: protex-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for protex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 635377d541560b44434f666be949d66d6c6f3e41e3e2a5cb60a08349d48d1e13
MD5 fee9185d20a4554be5c19ec898f5766d
BLAKE2b-256 eae12cf419bde2978b6cb7bb25f154e8d4f717397284c02b6499259f12acbd97

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page