Go to file
John Sennesael 5ad543aec3 Add page sep feature 2022-03-31 19:46:07 -05:00
src Add page sep feature 2022-03-31 19:46:07 -05:00
.gitignore Add page sep feature 2022-03-31 19:46:07 -05:00
COPYING Initial commit. 2022-03-16 18:38:12 -05:00
LICENSE Initial commit 2022-03-16 23:18:45 +00:00
Makefile Add page sep feature 2022-03-31 19:46:07 -05:00
README.md Remove optional usage to make old compilers happy, update readme 2022-03-24 19:25:04 -05:00
justify_2_column.png Support multi-column output. 2022-03-19 16:18:28 -05:00
justify_2_column_5_char_spacing.png Support multi-column output. 2022-03-19 16:18:28 -05:00
justify_2_column_max_20_tall.png Support multi-column output. 2022-03-19 16:18:28 -05:00
justify_3_column.png Support multi-column output. 2022-03-19 16:18:28 -05:00

README.md

JUSTIFY

Summary

A simple text alignment tool that supports left/right/center/fill justify alignment.

The fill justification tries to be smarter than most tools by trying to inject spaces where it makes most sense.

For fill justify, it keeps an internal score system, where each word gets a score based on a few criterea, like did the previous word end with punctuation, distance to the nearest space, word length,... in the case of ties, it will flip flop between the word nearest to the start of the line and the word nearest to the end of the line in order to ensure a more even distribution of spaces.

WHY?!

Yes yes, there's tools that do this, like par and fmt but they are harder to use, and less clever with space distribution. I wanted something better for writing gopher content. :)

Dependencies

Nothing other than a relatively modern c++ compiler (one with c++20 support - latest stable gcc or cmake will do) and cmake.

Building

The standard Makefile routine:

make

On some unix systems (bsd's, irix,...) you may have to run ...

gmake

... in order to get the gnu version of make.

Usage

Usage: ./justify [OPTION]...

    Input / output options:

        -i,--input [FILE]     Input file to process, defaults to stdin.
        -o,--output [FILE]    Output file, defaults to stdout.

    Column options:

        -c,--cols [COLS]      Number of columns for multi-column
                            output.
        -s,--hspacing [COLS]  Column horizontal spacing.
                            (default: 2)
        -v,--vspacing [ROWS]  Column vertical spacing.
                            (default: 1)
        -m,--colheight [ROWS] Column max. height.
                            (default: 0, =infinite)

    Alignment options: 

        -w,--width [NUM]      Text width to format text into.
                            (defaults to terminal width)
        -a,--align [center|fill|left|right]
                            Justify method (default=fill).

    Misc options: 

        -h,--help             Show this help text.

Screenshots

2 column output example

3 column output example

2 column output with 5 character spacing example

2 column output with max. height of 20 characters per block example