text...just(3tcl)
β¨ NAME β¨
textutil::adjust β the procedures that adjust, indent, and undent your paragraphs π
π¦ SYNOPSIS π¦
package require Tcl 8.5 9
package require textutil::adjust ?0.7.4?
::textutil::adjust::adjust string ?option value...?
::textutil::adjust::readPatterns filename
::textutil::adjust::listPredefined
::textutil::adjust::getPredefined filename
::textutil::adjust::indent string prefix ?skip?
::textutil::adjust::undent string
π DESCRIPTION π
okay so bestie, the package textutil::adjust gives you commands that mess with strings and texts (a.k.a. long strings, or strings with embedded newlines, or straight up paragraphs) β adjusting them, or indenting them. literally the whole glow-up package for your text's formatting π«Ά
The complete set of procedures is described below, no gatekeeping here β¨
::textutil::adjust::adjust string ?option value...?
Do a justification on the string according to the options. The string is taken as one big paragraph, ignoring any newlines. Then the line is formatted according to the options used, and the command returns a new string with enough lines to contain all the printable chars in the input string. A line is a set of characters between the beginning of the string and a newline, or between 2 newlines, or between a newline and the end of the string. If the input string is small enough, the returned string won't contain any newlines at all β it's giving compact π
Together with ::textutil::adjust::indent it is possible to create properly wrapped paragraphs with arbitrary indentations π
By default, any occurrence of space or tabulation characters are replaced by a single space so that each word in a line is separated from the next one by exactly one space character, and this forms a real line. Each real line is placed in a logical line, which has exactly a given length (see the option -length below). The real line may be shorter. Again by default, trailing spaces are ignored before returning the string (see the option -full below).
The following options may be used after the string parameter, and change the way the command places a real line in a logical line.
-fullboolean β If set tofalse(default), trailing space characters are deleted before returning the string. If set totrue, any trailing space characters are left in the string. no scrubbing, we keep the spaces π-hyphenateboolean β If set tofalse(default), no hyphenation will be done. If set totrue, the command will try to hyphenate the last word of a line. Note: Hyphenation patterns must be loaded prior, using the command::textutil::adjust::readPatterns. like, do that first or it's not gonna work, fr fr π-justifycenter|left|plain|rightβ Sets the justification of the returned string to eitherleft(default),center,plainorright. The justification means that any line in the returned string but the last one is build according to the value. If the justification is set toplainand the number of printable chars in the last line is less than 90% of the length of a line (see the option-length), then this line is justified with theleftvalue, avoiding the expansion of this line when it is too small. The meaning of each value is:centerβ The real line is centered in the logical line. If needed, a set of space characters are added at the beginning (half of the needed set) and at the end (half of the needed set) of the line if required (see the option-full). main character energy, dead center β¨leftβ The real line is set on the left of the logical line. It means that there are no space chars at the beginning of this line. If required, all needed space chars are added at the end of the line (see the option-full).plainβ The real line is exactly set in the logical line. It means that there are no leading or trailing space chars. All the needed space chars are added in the real line, between 2 (or more) words.rightβ The real line is set on the right of the logical line. It means that there are no space chars at the end of this line, and there may be some space chars at the beginning, despite of the-fulloption. yes, even with-fullon, ok, that's just how she is π
-lengthinteger β Set the length of the logical line in the string to integer. integer must be a positive integer value. Defaults to72.-strictlengthboolean β If set tofalse(default), a line can exceed the specified-lengthif a single word is longer than-length. If set totrue, words that are longer than-lengthare split so that no line exceeds the specified-length. violent but effective, periodt βοΈ
::textutil::adjust::readPatterns filename
Loads the internal storage for hyphenation patterns with the contents of the file filename. This has to be done prior to calling command ::textutil::adjust::adjust with "-hyphenate true", or the hyphenation process will not work correctly. do not skip this step bestie, I'm begging π
The package comes with a number of predefined pattern files, and the command ::textutil::adjust::listPredefined can be used to find out their names.
::textutil::adjust::listPredefined
This command returns a list containing the names of the hyphenation files coming with this package. lil freebie drop π
::textutil::adjust::getPredefined filename
Use this command to query the package for the full path name of the hyphenation file filename coming with the package. Only the filenames found in the list returned by ::textutil::adjust::listPredefined are legal arguments for this command. anything else? not legal, sorry babe π
::textutil::adjust::indent string prefix ?skip?
Each line in the string is indented by adding the string prefix at its beginning. The modified string is returned as the result of the command.
If skip is specified the first skip lines are left untouched. The default for skip is 0, causing the modification of all lines. Negative values for skip are treated like 0. In other words, skip > 0 creates a hanging indentation. cute, right? πΈ
Together with ::textutil::adjust::adjust it is possible to create properly wrapped paragraphs with arbitrary indentations π
::textutil::adjust::undent string
The command computes the common prefix for all lines in string consisting solely out of whitespace, removes this from each line and returns the modified string.
Lines containing only whitespace are always reduced to completely empty lines. They and empty lines are also ignored when computing the prefix to remove. so yes, they get β¨simplifiedβ¨
Together with ::textutil::adjust::adjust it is possible to create properly wrapped paragraphs with arbitrary indentations π
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category textutil of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas for enhancements you may have for either package and/or documentation. we want the feedback, we love the feedback π«Ά
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. (yes, the left-most one, that's the one π)
π SEE ALSO π
regexp(3tcl), split(3tcl), string(3tcl)
π KEYWORDS π
TeX, adjusting, formatting, hyphenation, indenting, justification, paragraph, string, undenting
π CATEGORY π
Text processing
and that's the whole page, bestie β this was the text...just(3tcl) manual from tcllib, version 0.7.4, and it lives under the category Text processing. mwah, slay, go format something pretty πβ¨
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms