REFLOW(1p)

πŸ“¦ version 1.17, in ubuntu jammy

✨ REFLOW(1p) ✨

okay bestie, gather round, because this is reflow β€” a Perl script that reflows text files using Knuth's paragraphing algorithm πŸ’– and honestly? it's giving scholar energy.


🌸 NAME 🌸

reflow β€” a Perl script for reflowing text files using Knuth's paragraphing algorithm. no cap, that's the whole job. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

reflow < input > output

reflow file1 file2 ... > output

like. that's it. that's the vibe. πŸ¦‹


✨ DESCRIPTION ✨

So here's the tea πŸ“: this thing uses Knuth's paragraphing algorithm β€” yes, the same one TeX uses, she's famous β€” to "reflow" text files by picking "good" places to break the line. not just any place. the good places. there's a difference and the algorithm cares deeply.

It takes an ascii text file (with paragraphs separated by blank lines) and reflows the paragraphs. πŸ’œ

Now, the iconic bit: if two or more lines in a row are "indented" then they are assumed to be a quoted poem and are passed through unchanged. leaving the poem alone. respecting the poem. we love to see it 🫢 (and the -skipindented flag causes ALL indented lines to be passed unchanged, if you're in that kind of mood)

The algorithm tries to keep the lines the same length but also tries to break at punctuation, and avoid breaking within a proper name or after certain "connectives" ("a", "the", etc.). she's picky! she's discerning! she ate πŸ’…


🌈 OPTIONS 🌈

  • -skipindented β€” Cause ALL indented lines to be passed unchanged. Normally a single indented line is included in the paragraph, while two or more indented lines are considered to be a quotation or poem and are passed through unchanged. so this flag is like "bestie, do NOT touch the indents, any of them, periodt."
  • -fast β€” Sets the optimum line width to 65 characters. This is the default. it's the default for a reason, it's fast, it's chill, it's the main character. πŸ‘‘
  • -slow β€” Tries line widths of 60, 65 and 70 characters and picks the best one. more effort, more polish ✨
  • -veryslow β€” Tries all line widths between 60 and 70 characters inclusive, and picks the best one. With the -slow and -veryslow options the line widths within a paragraph will vary less, but the line widths may vary from one paragraph to the next. so yeah β€” gorgeous results, but she takes her time and the widths be jumping between paragraphs. iykyk 😭
  • -skipto pattern β€” Skip to the first line starting with the given pattern before starting to reflow. This is useful for skipping Project Gutenberg headers or contents tables. literally the "okay skip to the good part" flag πŸŽ€
See Text::Reflow(3) for more options: all the keyword options defined in Text::Reflow are also available via the reflow script. so if you want the full menu, that's where it lives 🧚

πŸ’œ AUTHOR πŸ’œ

Original reflow perl script written by Michael Larsen, larsen@edu.upenn.math.

Modified, enhanced and converted to a perl module with XSUB by Martin Ward, martin@gkc.org.uk. absolute legends, both of them 🫢


🌟 SEE ALSO 🌟

  • Text::Reflow(3).
  • perl(1).
  • See "TeX the Program" by Donald Knuth for a description of the algorithm used. (the source material! the blueprint! the origin story! πŸ“š)

and that's the whole page bestie πŸ’– this was perl v5.34.0, dated 2022-02-06, and yeah β€” it's REFLOW(1p), the one and only. slay, go reflow something pretty πŸŒΈπŸ’…βœ¨

πŸ“¦ where this page comes from