Copyright | (C) 2014 Francesco Ariis |
---|---|
License | BSD3 (see LICENSE file) |
Maintainer | Francesco Ariis <fa-ml@ariis.it> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Simple functions to break a String to fit a maximum text width, using Knuth-Liang hyphenation algorithm.
Example:
import Text.LineBreak hyp = Just english_US bf = BreakFormat 25 4 '-' hyp cs = "Using hyphenation with gruesomely non parsimonious wording." main = putStr $ breakString bf cs
will output:
Using hyphenation with gruesomely non parsimo- nious wording.
Synopsis
- breakString :: BreakFormat -> String -> String
- breakStringLn :: BreakFormat -> String -> [String]
- data BreakFormat = BreakFormat {
- bfMaxCol :: Int
- bfTabRep :: Int
- bfHyphenSymbol :: Char
- bfHyphenator :: Maybe Hyphenator
- data Hyphenator
- afrikaans :: Hyphenator
- armenian :: Hyphenator
- assamese :: Hyphenator
- basque :: Hyphenator
- bengali :: Hyphenator
- bulgarian :: Hyphenator
- catalan :: Hyphenator
- chinese :: Hyphenator
- coptic :: Hyphenator
- croatian :: Hyphenator
- czech :: Hyphenator
- danish :: Hyphenator
- dutch :: Hyphenator
- english_US :: Hyphenator
- english_GB :: Hyphenator
- esperanto :: Hyphenator
- estonian :: Hyphenator
- ethiopic :: Hyphenator
- finnish :: Hyphenator
- french :: Hyphenator
- friulan :: Hyphenator
- galician :: Hyphenator
- georgian :: Hyphenator
- german_1901 :: Hyphenator
- german_1996 :: Hyphenator
- german_Swiss :: Hyphenator
- greek_Ancient :: Hyphenator
- greek_Mono :: Hyphenator
- greek_Poly :: Hyphenator
- gujarati :: Hyphenator
- hindi :: Hyphenator
- hungarian :: Hyphenator
- icelandic :: Hyphenator
- indonesian :: Hyphenator
- interlingua :: Hyphenator
- irish :: Hyphenator
- italian :: Hyphenator
- kannada :: Hyphenator
- kurmanji :: Hyphenator
- latin :: Hyphenator
- latin_Classic :: Hyphenator
- latvian :: Hyphenator
- lithuanian :: Hyphenator
- malayalam :: Hyphenator
- marathi :: Hyphenator
- mongolian :: Hyphenator
- norwegian_Bokmal :: Hyphenator
- norwegian_Nynorsk :: Hyphenator
- occitan :: Hyphenator
- oriya :: Hyphenator
- panjabi :: Hyphenator
- piedmontese :: Hyphenator
- polish :: Hyphenator
- portuguese :: Hyphenator
- romanian :: Hyphenator
- romansh :: Hyphenator
- russian :: Hyphenator
- sanskrit :: Hyphenator
- serbian_Cyrillic :: Hyphenator
- serbocroatian_Cyrillic :: Hyphenator
- serbocroatian_Latin :: Hyphenator
- slovak :: Hyphenator
- slovenian :: Hyphenator
- spanish :: Hyphenator
- swedish :: Hyphenator
- tamil :: Hyphenator
- telugu :: Hyphenator
- thai :: Hyphenator
- turkish :: Hyphenator
- turkmen :: Hyphenator
- ukrainian :: Hyphenator
- uppersorbian :: Hyphenator
- welsh :: Hyphenator
Line breaking
breakString :: BreakFormat -> String -> String Source #
Breaks some text (String) to make it fit in a certain width. The output is a String, suitable for writing to screen or file.
breakStringLn :: BreakFormat -> String -> [String] Source #
Convenience for lines $ breakString bf cs
.
data BreakFormat Source #
How to break the strings: maximum width of the lines, number of spaces
to replace tabs with (dumb replacement), symbol to use to hyphenate
words, hypenator to use (language, exceptions, etc.; refer to
Text.Hyphenation for usage instructions). To break lines without
hyphenating, put Nothing
in bfHyphenator
.
BreakFormat | |
|
Hypenators
Convenience reexport from Text.Hyphenation.Language.
data Hyphenator #
A Hyphenator
is combination of an alphabet normalization scheme, a set of Patterns
, a set of Exceptions
to those patterns
and a number of characters at each end to skip hyphenating.
afrikaans :: Hyphenator #
Hyphenators for a wide array of languages.
armenian :: Hyphenator #
Hyphenators for a wide array of languages.
assamese :: Hyphenator #
Hyphenators for a wide array of languages.
basque :: Hyphenator #
Hyphenators for a wide array of languages.
bengali :: Hyphenator #
Hyphenators for a wide array of languages.
bulgarian :: Hyphenator #
Hyphenators for a wide array of languages.
catalan :: Hyphenator #
Hyphenators for a wide array of languages.
chinese :: Hyphenator #
Hyphenators for a wide array of languages.
coptic :: Hyphenator #
Hyphenators for a wide array of languages.
croatian :: Hyphenator #
Hyphenators for a wide array of languages.
czech :: Hyphenator #
Hyphenators for a wide array of languages.
danish :: Hyphenator #
Hyphenators for a wide array of languages.
dutch :: Hyphenator #
Hyphenators for a wide array of languages.
>>>
hyphenate english_US "supercalifragilisticexpialadocious"
["su","per","cal","ifrag","ilis","tic","ex","pi","al","ado","cious"]
favors US hyphenation
>>>
hyphenate english_GB "supercalifragilisticexpialadocious"
["su","per","cal","i","fra","gil","istic","ex","pi","alado","cious"]
favors UK hyphenation
esperanto :: Hyphenator #
Hyphenators for a wide array of languages.
estonian :: Hyphenator #
Hyphenators for a wide array of languages.
ethiopic :: Hyphenator #
Hyphenators for a wide array of languages.
finnish :: Hyphenator #
Hyphenators for a wide array of languages.
french :: Hyphenator #
>>>
hyphenate french "anticonstitutionnellement"
["an","ti","cons","ti","tu","tion","nel","le","ment"]
friulan :: Hyphenator #
Hyphenators for a wide array of languages.
galician :: Hyphenator #
Hyphenators for a wide array of languages.
georgian :: Hyphenator #
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
gujarati :: Hyphenator #
Hyphenators for a wide array of languages.
hindi :: Hyphenator #
Hyphenators for a wide array of languages.
hungarian :: Hyphenator #
Hyphenators for a wide array of languages.
icelandic :: Hyphenator #
>>>
hyphenate icelandic "va\240lahei\240avegavinnuverkf\230rageymslusk\250r"
["va\240la","hei\240a","vega","vinnu","verk","f\230ra","geymslu","sk\250r"]
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
irish :: Hyphenator #
Hyphenators for a wide array of languages.
italian :: Hyphenator #
Hyphenators for a wide array of languages.
kannada :: Hyphenator #
Hyphenators for a wide array of languages.
kurmanji :: Hyphenator #
Hyphenators for a wide array of languages.
latin :: Hyphenator #
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
latvian :: Hyphenator #
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
malayalam :: Hyphenator #
Hyphenators for a wide array of languages.
marathi :: Hyphenator #
Hyphenators for a wide array of languages.
mongolian :: Hyphenator #
Hyphenators for a wide array of languages.
norwegian_Bokmal :: Hyphenator #
Hyphenators for a wide array of languages.
norwegian_Nynorsk :: Hyphenator #
Hyphenators for a wide array of languages.
occitan :: Hyphenator #
Hyphenators for a wide array of languages.
oriya :: Hyphenator #
Hyphenators for a wide array of languages.
panjabi :: Hyphenator #
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
polish :: Hyphenator #
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
romanian :: Hyphenator #
Hyphenators for a wide array of languages.
romansh :: Hyphenator #
Hyphenators for a wide array of languages.
russian :: Hyphenator #
Hyphenators for a wide array of languages.
sanskrit :: Hyphenator #
Hyphenators for a wide array of languages.
serbian_Cyrillic :: Hyphenator #
Hyphenators for a wide array of languages.
serbocroatian_Cyrillic :: Hyphenator #
Hyphenators for a wide array of languages.
serbocroatian_Latin :: Hyphenator #
Hyphenators for a wide array of languages.
slovak :: Hyphenator #
Hyphenators for a wide array of languages.
slovenian :: Hyphenator #
Hyphenators for a wide array of languages.
spanish :: Hyphenator #
Hyphenators for a wide array of languages.
swedish :: Hyphenator #
Hyphenators for a wide array of languages.
tamil :: Hyphenator #
Hyphenators for a wide array of languages.
telugu :: Hyphenator #
Hyphenators for a wide array of languages.
thai :: Hyphenator #
Hyphenators for a wide array of languages.
turkish :: Hyphenator #
Hyphenators for a wide array of languages.
turkmen :: Hyphenator #
Hyphenators for a wide array of languages.
ukrainian :: Hyphenator #
Hyphenators for a wide array of languages.
Hyphenators for a wide array of languages.
welsh :: Hyphenator #
Hyphenators for a wide array of languages.