HaTeX-3.11.0.1: The Haskell LaTeX library.

Safe HaskellSafe-Inferred

Text.LaTeX.Base.Render

Contents

Description

The final purpose of this module is to render a Text value from a LaTeX value. The interface is abstracted via a typeclass so you can cast to Text other types as well. Also, some other handy Text-related functions are defined.

Synopsis

Re-exports

data Text

A space efficient, packed, unboxed Unicode text type.

Instances

Eq Text 
Data Text

This instance preserves data abstraction at the cost of inefficiency. We omit reflection services for the sake of data abstraction.

This instance was created by copying the updated behavior of Data.Set.Set and Data.Map.Map. If you feel a mistake has been made, please feel free to submit improvements.

The original discussion is archived here: could we get a Data instance for Data.Text.Text?

The followup discussion that changed the behavior of Set and Map is archived here: Proposal: Allow gunfold for Data.Map, ...

Ord Text 
Read Text 
Show Text 
Typeable Text 
IsString Text 
Chunk Text 
Monoid Text 
NFData Text 
Semigroup Text 
Pretty Text 
Render Text

This instance escapes LaTeX reserved characters.

Texy Text 
~ * a Text => IsString (Parser a) 

Render class

class Show a => Render a whereSource

Class of values that can be transformed to Text. You mainly will use this to obtain the Text output of a LaTeX value. If you are going to write the result in a file, consider to use renderFile.

Consider also to use rendertex to get Renderable values into LaTeX blocks.

If you want to make a type instance of Render and you already have a Show instance, you can use the default instance.

 render = fromString . show

Methods

render :: a -> TextSource

renderAppend :: Render a => [a] -> TextSource

Render every element of a list and append results.

renderChars :: Render a => Char -> [a] -> TextSource

Render every element of a list and append results, separated by the given Char.

renderCommas :: Render a => [a] -> TextSource

Render every element of a list and append results, separated by commas.

renderFile :: Render a => FilePath -> a -> IO ()Source

Use this function to render a LaTeX (or another one in the Render class) value directly in a file.

rendertex :: (Render a, LaTeXC l) => a -> lSource

If you can transform a value to Text, you can insert that Text in your LaTeX code. That is what this function does.

Warning: rendertex does not escape LaTeX reserved characters. Use protectText to escape them.

Reading files

readFileTex :: FilePath -> IO TextSource

If you are going to insert the content of a file in your LaTeX data, use this function to ensure your encoding is correct.

Util

showFloat :: RealFloat a => a -> StringSource

Show a signed floating number using standard decimal notation using 5 decimals.