hledger-lib-1.10: Core data types, parsers and functionality for the hledger accounting tools

Safe HaskellNone
LanguageHaskell2010

Hledger.Utils.Text

Description

Text formatting helpers, ported from String as needed. There may be better alternatives out there.

Synopsis

Documentation

quoteIfSpaced :: Text -> Text Source #

Wrap a string in double quotes, and -prefix any embedded single quotes, if it contains whitespace and is not already single- or double-quoted.

stripquotes :: Text -> Text Source #

Strip one matching pair of single or double quotes on the ends of a string.

textstrip :: Text -> Text Source #

Remove leading and trailing whitespace.

textlstrip :: Text -> Text Source #

Remove leading whitespace.

textrstrip :: Text -> Text Source #

Remove trailing whitespace.

textConcatTopPadded :: [Text] -> Text Source #

Join several multi-line strings as side-by-side rectangular strings of the same height, top-padded. Treats wide characters as double width.

fitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text Source #

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.

textWidth :: Text -> Int Source #

Calculate the designated render width of a string, taking into account wide characters and line breaks (the longest line within a multi-line string determines the width ).

textTakeWidth :: Int -> Text -> Text Source #

Double-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg textTakeWidth 3 "りんご" = "り".

textPadLeftWide :: Int -> Text -> Text Source #

Left-pad a text to the specified width. Treats wide characters as double width. Works on multi-line texts too (but will rewrite non-unix line endings).

textPadRightWide :: Int -> Text -> Text Source #

Right-pad a string to the specified width. Treats wide characters as double width. Works on multi-line strings too (but will rewrite non-unix line endings).