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

Safe Haskell | None
Language | Haskell2010

Hledger.Utils.Text

Description

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

Synopsis

- textstrip :: Text -> Text
- textlstrip :: Text -> Text
- textrstrip :: Text -> Text
- textElideRight :: Int -> Text -> Text
- quoteIfSpaced :: Text -> Text
- quotechars :: [Char]
- whitespacechars :: [Char]
- escapeDoubleQuotes :: Text -> Text
- escapeSingleQuotes :: Text -> Text
- stripquotes :: Text -> Text
- isSingleQuoted :: Text -> Bool
- isDoubleQuoted :: Text -> Bool
- textUnbracket :: Text -> Text
- textConcatTopPadded :: [Text] -> Text
- difforzero :: (Num a, Ord a) => a -> a -> a
- fitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text
- textPadLeftWide :: Int -> Text -> Text
- textPadRightWide :: Int -> Text -> Text
- textTakeWidth :: Int -> Text -> Text
- textWidth :: Text -> Int

# Documentation

textstrip :: Text -> Text #

Remove leading and trailing whitespace.

textlstrip :: Text -> Text #

Remove leading whitespace.

textrstrip :: Text -> Text #

Remove trailing whitespace.

textElideRight :: Int -> Text -> Text #

quoteIfSpaced :: Text -> Text #

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

quotechars :: [Char] #

whitespacechars :: [Char] #

escapeDoubleQuotes :: Text -> Text #

escapeSingleQuotes :: Text -> Text #

stripquotes :: Text -> Text #

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

isSingleQuoted :: Text -> Bool #

isDoubleQuoted :: Text -> Bool #

textUnbracket :: Text -> Text #

textConcatTopPadded :: [Text] -> Text #

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

difforzero :: (Num a, Ord a) => a -> a -> a #

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

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.

textPadLeftWide :: Int -> Text -> Text #

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 #

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).

textTakeWidth :: Int -> Text -> Text #

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

textWidth :: Text -> Int #

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 ).