Name : perl-Text-Format
| |
Version : 0.63
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.1.1
| Date : 2024-09-08 06:28:00
|
Group : Unspecified
| Source RPM : perl-Text-Format-0.63-lp155.1.1.src.rpm
|
Size : 0.06 MB
| |
Packager : https://www_suse_com/
| |
Summary : Various subroutines to format text
|
Description :
The *format* routine will format under all circumstances even if the width isn\'t enough to contain the longest words. _Text::Wrap_ will die under these circumstances, although I am told this is fixed. If columns is set to a small number and words are longer than that and the leading \'whitespace\' than there will be a single word on each line. This will let you make a simple word list which could be indented or right aligned. There is a chance for croaking if you try to subvert the module. If you don\'t pass in text then the internal text is worked on, though not modified.
_Text::Format_ is meant for more powerful text formatting than what _Text::Wrap_ allows. I also have a module called _Text::NWrap_ that is meant as a direct replacement for _Text::Wrap_. _Text::NWrap_ requires _Text::Format_ since it uses _Text::Format->format_ to do the actual wrapping but gives you the interface of _Text::Wrap_.
General setup should be explained with the below graph.
columns < ------------------------------------------------------------> < ---------->< ------>< --------------------------->< -----------> leftMargin indent text is formatted into here rightMargin
indent is firstIndent or bodyIndent depending on where we are in the paragraph.
* *format* AATTARRAY || \\AATTARRAY || [< FILEHANDLE>] || NOTHING
Allows one to do some advanced formatting of text into a paragraph, with indent for first line and body set separately. Can specify total width of text, right fill with spaces or right align or justify (align to both margins), right margin and left margin, non-breaking space, two spaces at end of sentence, hanging indents (tagged paragraphs). Strips all leading and trailing whitespace before proceeding. Text is first split into words and then reassembled. If no text is passed in then the internal text in the object is formatted.
* *paragraphs* AATTARRAY || \\AATTARRAY || [< FILEHANDLE>] || NOTHING
Considers each element of text as a paragraph and if the indents are the same for first line and the body then the paragraphs are separated by a single empty line otherwise they follow one under the other. If hanging indent is set then a single empty line will separate each paragraph as well. Calls _format_ to do the actual formatting. If no text is passed in then the internal text in the object is formatted, though not changed.
* *center* AATTARRAY || NOTHING
Centers a list of strings in AATTARRAY or internal text. Empty lines appear as, you guessed it, empty lines. Center strips all leading and trailing whitespace before proceeding. Left margin and right margin can be set. If no text is passed in then the internal text in the object is formatted.
* *expand* AATTARRAY || NOTHING
Expand tabs in the list of text to tabstop number of spaces in AATTARRAY or internal text. Doesn\'t modify the internal text just passes back the modified text. If no text is passed in then the internal text in the object is formatted.
* *unexpand* AATTARRAY || NOTHING
Tabstop number of spaces are turned into tabs in AATTARRAY or internal text. Doesn\'t modify the internal text just passes back the modified text. If no text is passed in then the internal text in the object is formatted.
* *new* \\%HASH || NOTHING
Instantiates the object. If you pass a reference to a hash, or an anonymous hash then it is used in setting attributes.
* *config* \\%HASH
Allows the configuration of all object attributes at once. Returns the object prior to configuration. You can use it to make a clone of your object before you change attributes.
* *columns* NUMBER || NOTHING
Set width of text or retrieve width. This is total width and includes indentation and the right and left margins.
* *tabstop* NUMBER || NOTHING
Set tabstop size or retrieve tabstop size, only used by expand, unexpand and center.
* *firstIndent* NUMBER || NOTHING
Set or get indent for the first line of paragraph. This is the number of spaces to indent.
* *bodyIndent* NUMBER || NOTHING
Set or get indent for the body of paragraph. This is the number of spaces to indent.
* *leftMargin* NUMBER || NOTHING
Set or get width of left margin. This is the number of spaces used for the margin.
* *rightMargin* NUMBER || NOTHING
Set or get width of right margin. This is the number of spaces used for the margin.
* *rightFill* 0 || 1 || NOTHING
Set right fill or retrieve its value. The filling is done with spaces. Keep in mind that if _rightAlign_ is also set then both _rightFill_ and _rightAlign_ are ignored.
* *rightAlign* 0 || 1 || NOTHING
Set right align or retrieve its value. Text is aligned with the right side of the margin. Keep in mind that if _rightFill_ is also set then both _rightFill_ and _rightAlign_ are ignored.
* *justify* 0 || 1 || NOTHING
Set justify or retrieve its value. Text is aligned with both margins, adding extra spaces as necessary to align text with left and right margins. Keep in mind that if either of _rightAlign_ or _rightFill_ are set then _justify_ is ignored, even if both are set in which case they are all ignored.
* *text* \\AATTARRAY || NOTHING
Pass in a reference to your text, or an anonymous array of text that you want the routines to manipulate. Returns the text held in the object.
* *hangingIndent* 0 || 1 || NOTHING
Use hanging indents in front of a paragraph, returns current value of attribute. This is also called a tagged paragraph.
* *hangingText* \\AATTARRAY || NOTHING
The text that will be displayed in front of each paragraph, if you call _format_ then only the first element is used, if you call _paragraphs_ then _paragraphs_ cycles through all of them. If you have more paragraphs than elements in your array than the remainder of the paragraphs will not have a hanging indented text. Pass a reference to your array. This is also called a tagged paragraph.
* *noBreak* 0 || 1 || NOTHING
Set whether you want to use the non-breaking space feature (see *noBreakRegex* below).
* *noBreakRegex* \\%HASH || NOTHING
Pass in a reference to a hash that would hold the regexes on which not to break. In order for this to happen, it requires *noBreak* to be set to *true* - see above. Without any arguments, it returns the hash. E.g:
{\'^Mrs?\\.$\' => \'^\\S+$\',\'^\\S+$\' => \'^(?:S|J)r\\.$\'}
don\'t break names such as Mr. Jones, Mrs. Jones, Jones Jr.
The breaking algorithm is simple. If there should not be a break at the current end of sentence, then a backtrack is done till there are two words on which breaking is allowed. If no two such words are found then the end of sentence is broken anyhow. If there is a single word on current line then no backtrack is done and the word is stuck on the end. This is so you can make a list of names for example.
*Note*: this feature requires *noBreak* to be set to true.
* *extraSpace* 0 || 1 || NOTHING
Add extra space after end of sentence, normally _format_ would add 1 space after end of sentence, if this is set to 1 then 2 spaces are used. Abbreviations are not followed by two spaces. There are a few internal abbreviations and you can add your own to the object with _abbrevs_
* *abbrevs* \\%HASH || AATTARRAY || NOTHING
Add to the current abbreviations, takes a reference to your hash or an array of abbreviations, if called a second time the original reference is removed and replaced by the new one. Returns the current INTERNAL abbreviations.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/15.5/noarch |