![]() ![]() The purpose of the default value is to allow poetry to pass through unchanged, but not to allow a paragraph indentation from preventing the first line of the paragraph from being reflowed. ![]() If skipindented = 2 then any two or more adjacent indented lines will not be reflowed. If skipindented = 1 then any indented line will not be reflowed. If skipindented = 0 then all indented lines are flowed in with the surrounding paragraph. This is useful for skipping Project Gutenberg headers or contents tables. Skip to the first line starting with the given pattern before starting to reflow. To reflow a quoted email message and then restore the quotes you might want to use quote => "> ", indent => "> " skipto => "" quote => ""Ĭharacters to strip from the beginning of a line before processing. indent2 => ""Ī string which is used to indent the second and subsequent line in any paragraph. indent1 => ""Ī string which is used to indent the first line in any paragraph. indent => string is equivalent to indent1 => string, indent2 => string. indent => ""Įach line of output has this string prepended. This results in less ragged paragraphs, but some paragraphs will be wider or narrower overall than others. This can be either a number or a reference to an array of numbers: in the latter case, each optimal line length is tried in turn for each paragraph, and the one which leads to the best overall paragraph is chosen. The following options are currently implemented, with their default values: optimum => In which case the new options only apply to this call. Or they can be passed to a reflow_ function as a keyword parameter, for example: $out = reflow_string($in, maximum => 80, optimum => 75) Will set the maximum line length to 80 characters and the optimum line length to 75 characters for all subsequent reflow operations. These can be set globally by referencing the appropriate variable in the Text::Reflow package, for example: $Text::Reflow::maximum = 80 The behaviour of Reflow can be adjusted by setting various keyword options. Which reflows the whole of myfile and prints the result to STDOUT. Otherwise, $infile and $outfile may be a string, a FileHandle reference or a FileHandle glob.Ī typical invocation is: reflow_file("myfile", "") The result is a file with a more "ragged" right margin than is produced by fmt or Text::Wrap but it is easier to read since fewer phrases are broken across line breaks.įor reflow_file, if $infile is the empty string, then the input is taken from STDIN and if $outfile is the empty string, the output is written to STDOUT. The reflow 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.). If two or more lines in a row are "indented" then they are assumed to be a quoted poem and are passed through unchanged (but see below) ![]() These routines will reflow the paragraphs in the given file, filehandle, string or array using Knuth's paragraphing algorithm (as used in TeX) to pick "good" places to break the lines.Įach routine takes ascii text data with paragraphs separated by blank lines and reflows the paragraphs. ![]() $output = reflow_string($input, key => value. Reflow_file($infile, $outfile, key => value. SYNOPSIS use Text::Reflow qw(reflow_file reflow_string reflow_array) Text::Reflow - Perl module for reflowing text files using Knuth's paragraphing algorithm. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |