2022-03-16 23:17:45 +00:00
|
|
|
# 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
|
2022-03-16 23:39:12 +00:00
|
|
|
trying to inject spaces where it makes most sense.
|
2022-03-16 23:17:45 +00:00
|
|
|
|
|
|
|
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
|
2022-03-16 23:40:15 +00:00
|
|
|
(one with c++20 support - latest stable gcc or cmake will do)
|
|
|
|
and cmake.
|
2022-03-16 23:17:45 +00:00
|
|
|
|
|
|
|
## Building
|
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
The standard Makefile routine:
|
2022-03-16 23:17:45 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
make
|
|
|
|
|
|
|
|
On some unix systems (bsd's, irix,...) you may have to run ...
|
|
|
|
|
|
|
|
gmake
|
|
|
|
|
|
|
|
... in order to get the gnu version of make.
|
2022-03-16 23:17:45 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
Usage: ./justify [OPTION]...
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
Input / output options:
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
-i,--input [FILE] Input file to process, defaults to stdin.
|
|
|
|
-o,--output [FILE] Output file, defaults to stdout.
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
Column options:
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
-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)
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
Alignment options:
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
-w,--width [NUM] Text width to format text into.
|
|
|
|
(defaults to terminal width)
|
|
|
|
-a,--align [center|fill|left|right]
|
|
|
|
Justify method (default=fill).
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
Misc options:
|
2022-03-19 21:46:41 +00:00
|
|
|
|
2022-03-25 00:25:04 +00:00
|
|
|
-h,--help Show this help text.
|
2022-03-16 23:18:45 +00:00
|
|
|
|
2022-03-19 21:16:20 +00:00
|
|
|
## Screenshots
|
|
|
|
|
|
|
|
![2 column output example](./justify_2_column.png)
|
|
|
|
|
|
|
|
![3 column output example](./justify_3_column.png)
|
|
|
|
|
|
|
|
![2 column output with 5 character spacing example](./justify_2_column_5_char_spacing.png)
|
|
|
|
|
|
|
|
![2 column output with max. height of 20 characters per block example](./justify_2_column_max_20_tall.png)
|
|
|
|
|
|
|
|
|