Modulehledger-lib-1.52.4GHC2021
Hledger.Utils.Text
Text formatting helpers, ported from String as needed. There may be better alternatives out there.
- 1 type
- 23 values
- Packagehledger-lib-1.52.4
- Exports24
- LanguageGHC2021
- LicenceGPL-3.0-or-later
- SourceText.hs
misc
9 declarationsRemove all matching pairs of square brackets and parentheses from the text.
Wrap a Text with the surrounding Text.
Remove trailing newlines/carriage returns.
Wrap a string in double quotes, and -prefix any embedded single quotes, if it contains whitespace and is not already single- or double-quoted.
Strip one matching pair of single or double quotes on the ends of a string.
single-line layout
2 declarationsClip and pad a string to a minimum & maximum width, andor leftright justify it. Works on multi-line strings too (but will rewrite non-unix line endings).
multi-line layout
6 declarationsJoin several multi-line strings as side-by-side rectangular strings of the same height, top-padded. Treats wide characters as double width.
Join several multi-line strings as side-by-side rectangular strings of the same height, bottom-padded. Treats wide characters as double width.
General-purpose wide-char-aware single-line text layout function. It can left- or right-pad a short string to a minimum width. It can left- or right-clip a long string to a maximum width, optionally inserting an ellipsis (the third argument). It clips and pads on the right when the fourth argument is true, otherwise on the left. It treats wide characters as double width.
Add a prefix to each line of a string.
Add a prefix to the first line of a string, and a different prefix to the remaining lines.
Join a list of Text Builders with a newline after each item.
wide-character-aware layout
5 declarationsHelper for constructing Builders while keeping track of text width.
Constructors
Instances3Show, Semigroup, Monoid
Show WideBuilderDefined in hledger-lib-1.52.4 · Text.WideStringSemigroup WideBuilderDefined in hledger-lib-1.52.4 · Text.WideStringMonoid WideBuilderDefined in hledger-lib-1.52.4 · Text.WideString
Convert a WideBuilder to a strict Text.
Convert a strict Text to a WideBuilder.
Convert a WideBuilder to a String.
Double-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg textTakeWidth 3 "りんご" = "り".
Reading
1 declarationRead a decimal number from a Text. Assumes the input consists only of digit characters.