Rbpar is a program and an accompanying library suite designed for formatting text paragraphs. In this sense, it resembles very much the venerable UNIX programs fmt and par. The difference is that rbpar sports a more modern design: it is written completely with Ruby and offers an internal API for several paragraph formatting tasks. However, the more advanced features that fmt and par provide are currently not implemented in rbpar.
The library includes an implementation of the optimal line breaking algorithm by Donald E. Knuth. The library also has a semi-intelligent paragraph parser that is not confused by email quotes: this is due to the fact that rbpar was first designed for email writing. Rbpar ships with a full suite of unit tests, which are designed to make further refactoring and development easier.
The program executable 'rbpar.rb' is installed to the executable path by default. The program read input from stdin and outputs formatted paragraphs to stdout. A working Ruby environment is required for running rbpar.
rbpar.rb [-v] [-w < number >]
rbpar.rb accepts the following parameters:
-w, --width : Set the desired line width
-v, --vim : Use vim-style line endings (with an ending space)
Example usage to format a text file:
cat unprocessed.txt | rbpar.rb > processed.txt
To make vim 'gq' operator use rbpar, use the following command either in vim command menu or in your vimrc file:
set formatprg=rbpar.rb -w 63 -v
This sets the desired line width to be 62 characters. One extra space is inserted after every line that does not end a paragraph. This enables vim (with format-option 'w') to understand the paragraph lines. This is handy when using the 'auto-format' format option. See vim help for 'formatoptions', 'fo-table' and 'auto-format' for details.
What's New in This Release:
· Speedups, bugfixes, cleanups, and support for DOS-style end-of-line characters were added.
· This version is about two times as fast as 0.1.0.