Code Monkey home page Code Monkey logo

pstools's Introduction

PSTools — A collection of PostScript shell tools

These are all smaller helper scripts for postscript output. In my personal editing environment, I use troff to create postscript files. Sometimes it is necessary to manually adjust the postscript file.

These tools are intentionally not the most performant. They are meant to just work. Feel free to contribute more performant versions as well as other tools.

psmove — move pages around

Use this tool to move pages around. E. g. move the last page (table of contents) to the beginning, so we have a nicely formatted document with ordered pages. All other pages are renumbered to fit the moved page.

# psmove from to <file.ps >output.ps
; psmove 6 2 <file.ps >output.ps

from must be greater than to!

psmovem — move pages around according to a map

This tool can shuffle pages at will. It needs two parameters: number of pages and a mapping table.

The mapping table is a comma separated list of page numbers.

# reorder a document with 5 pages
; psmovem 5 1,2,3,5,4 <file.ps >output.ps

psnumseq — create mapping table

This tools provides a generator for mapping tables for psmovem. It uses a simple mapping syntax similar to rc shell redirections.

# move page 5 to 2, then the last page to 1
; psnumseq file.ps '5=2' '-0=1'
# the output can be directly used with psmovem
; psmovem «numpages» `{psnumseq file.ps '5=2' '-0=1'}

Note that 0 is invalid while -0 is valid!

pspnumber — renumber pages

This tool takes postscript input and renumbers all pages sequentially. It can be used to clean up after moving pages around with psmove.

It also fixes the %%Pages: page number attribute, but only if it's set after the pages.

; pspnumber <file.ps >output.ps

Additional troff tools

Note: I currently use me macros almost exclusively. Some of these scripts might not work properly with other macro packages.

refx — double references (troff)

This troff preprocessor is able to produce double references with refer. This way you can have both footnotes and bibliography, which is not possible with the ported refer.

# refx flags
; refx <file | troff ...

refx will invoke refer two times (with and without the accumulate flag).

txt2ms — text to troff-ms preprocessor

Convert formatted text files to a troff language (-ms like).

# sample usage
; txt2ms <file.txt | troff -ms ...

The format uses the two point glyph for special parsing of bold/italic: ‥italic‥ and ‥‥bold‥‥. To disable this parsing enable the dontparse flag. Otherwise the format is markdown-like:

# sample section
## sample subsection
### sample subsubsection

New paragraph with ‥‥bold‥‥ and ‥italic‥ text.

Another paragraph with \fBbold\fR and \fIitalic\fR text.

Keep in mind that the format only borrows from markdown. Many features are not supported (links, ...).

The converter is line oriented. Therefore troff content can be included where needed. Only empty lines and lines beginning with # are converted.

One special feature: The script is able to use the first line as a title, allowing quick ms-flavored documents. To use this feature the firstheader variable needs to be set.

Set variables like this:

; txt2ms -v 'firstheader=1' 'dontparse=1' < file.txt

Using txt2ms allows the creation of tables of contents. The important lines are printed to stderr.

; txt2ms < file.txt | troff >[2] aux.file

txt2ms also introduces the .KT macro for keep titles.

.KT "index" "Prefix" "Title."

This will typeset a keep title in the form: Prefix 5: Title.

Using the *t string and number (.ds *t "text, .nr *t 10) allows setting the indentation level and a hanging tag.

lib/txtmk is an mk library file and can be used to compile indexes that can be included in the source text file (with .so file.msi). To use the lib/txtmk library you should include the global $MACROS variable in your mkfile (with contents like: -ms -mpictures).

Note: You need to filter the output if you have errors/warnings!

pstools's People

Contributors

sirjofri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.