-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A tool for posting Haskelly articles to blogs -- -- Write blog posts in Markdown format, then use BlogLiterately to do -- syntax highlighting, format ghci sessions, and upload to any blog -- supporting the metaWeblog API (such as Wordpress): -- http://codex.wordpress.org/XML-RPC_MetaWeblog_API. -- -- To get started, use the provided executable BlogLiterately; -- see http://byorgey.wordpress.com/blogliterately/ for complete -- documentation. -- -- To make further customization possible, the internals of the -- executable are made available as a library. In particular, it is easy -- to create your own executable which adds extra custom transformations; -- see Text.BlogLiterately.Run. @package BlogLiterately @version 0.6.1 -- | Utilities for working with embedded LaTeX. module Text.BlogLiterately.LaTeX -- | WordPress can render LaTeX, but expects it in a special non-standard -- format ($latex foo$). The wpTeXify function formats -- LaTeX code using this format so that it can be processed by WordPress. wpTeXify :: Pandoc -> Pandoc -- | Utilities for working with code blocks. module Text.BlogLiterately.Block -- | Given a block, if begins with a tag in square brackets, strip off the -- tag and return a pair consisting of the tag and de-tagged block. -- Otherwise, return Nothing and the unchanged block. unTag :: String -> (Maybe String, String) -- | Run the given function on the attributes and source code of code -- blocks with a tag matching the given tag (case insensitive). On any -- other blocks (which don't have a matching tag, or are not code -- blocks), run the other function. onTag :: String -> (Attr -> String -> a) -> (Block -> a) -> Block -> a -- | Format specially marked blocks as interactive ghci sessions. Uses some -- ugly but effective code for interacting with an external ghci process -- taken from lhs2TeX. module Text.BlogLiterately.Ghci -- | Information about a running process: stdin, stdout, stderr, and a -- handle. type ProcessInfo = (Handle, Handle, Handle, ProcessHandle) -- | Evaluate an expression using an external ghci process. ghciEval :: GhciInput -> ReaderT ProcessInfo IO GhciOutput -- | Start an external ghci process, run a computation with access to it, -- and finally stop the process. withGhciProcess :: FilePath -> ReaderT ProcessInfo IO a -> IO a -- | Poor man's check to see whether we have a literate Haskell file. isLiterate :: FilePath -> IO Bool -- | Stop a ghci process by passing it :q and waiting for it to -- exit. stopGhci :: ProcessInfo -> IO () -- | There is nothing magic about the magic string. magic :: String extract' :: Handle -> IO String extract :: String -> String breaks :: ([a] -> Bool) -> [a] -> ([a], [a]) -- | Given the path to the .lhs source and its representation as a -- Pandoc document, formatInlineGhci finds any -- [ghci] blocks in it, runs them through ghci, and -- formats the results as an interactive ghci session. -- -- Lines beginning in the first column of the block are interpreted as -- inputs. Lines indented by one or more space are interpreted as -- expected outputs. Consecutive indented lines are interpreted as -- one multi-line expected output, with a number of spaces removed from -- the beginning of each line equal to the number of spaces at the start -- of the first indented line. -- -- If the output for a given input is the same as the expected output (or -- if no expected output is given), the result is typeset normally. If -- the actual and expected outputs differ, the actual output is typeset -- first in red, then the expected output in blue. formatInlineGhci :: FilePath -> Pandoc -> IO Pandoc instance Show GhciInput instance Show GhciOutput instance Show GhciLine -- | Syntax highlighting. module Text.BlogLiterately.Highlight -- | Four modes for highlighting Haskell. data HsHighlight -- | Use hscolour and inline the styles. HsColourInline :: StylePrefs -> HsHighlight -- | Use hscolour in conjunction with an external CSS style sheet. HsColourCSS :: HsHighlight -- | Use highlighting-kate. HsKate :: HsHighlight -- | Do not highlight Haskell. HsNoHighlight :: HsHighlight _HsColourInline :: Prism' HsHighlight StylePrefs -- | Use hscolour to syntax highlight some Haskell code. The first argument -- indicates whether the code is literate Haskell. colourIt :: Bool -> String -> String -- | Prepend literate Haskell markers to some source code. litify :: String -> String -- | Style preferences are specified as a list of mappings from class -- attributes to CSS style attributes. type StylePrefs = [(String, String)] -- | A default style that produces something that looks like the source -- listings on Hackage. defaultStylePrefs :: StylePrefs -- | Read style preferences in from a file using the Read instance -- for StylePrefs, or return the default style if the file name -- is empty. getStylePrefs :: Maybe FilePath -> IO StylePrefs -- | Take a String of HTML produced by hscolour, and "bake" styles -- into it by replacing class attributes with appropriate style -- attributes. bakeStyles :: StylePrefs -> String -> String -- | Replace <br/> tags with newlines. replaceBreaks :: String -> String -- | Transform a CodeBlock into a RawHtml block, where -- the content contains marked up Haskell (possibly with literate -- markers), or marked up non-Haskell, if highlighting of non-Haskell has -- been selected. colouriseCodeBlock :: HsHighlight -> Bool -> Block -> Block -- | Perform syntax highlighting on an entire Pandoc document. colourisePandoc :: HsHighlight -> Bool -> Pandoc -> Pandoc instance Typeable HsHighlight instance Data HsHighlight instance Show HsHighlight instance Eq HsHighlight -- | Configuation and command-line options. module Text.BlogLiterately.Options -- | Configuration record (and command-line options) for -- BlogLiterately. data BlogLiterately BlogLiterately :: Maybe String -> Maybe HsHighlight -> Maybe Bool -> Maybe Bool -> Maybe String -> Maybe Bool -> Maybe Bool -> [String] -> [String] -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe Bool -> Maybe Bool -> Maybe Bool -> [String] -> BlogLiterately -- | Name of a style file _style :: BlogLiterately -> Maybe String -- | Haskell highlighting mode _hsHighlight :: BlogLiterately -> Maybe HsHighlight -- | Use highlighting-kate for non-Haskell? _otherHighlight :: BlogLiterately -> Maybe Bool -- | Format LaTeX for WordPress? _wplatex :: BlogLiterately -> Maybe Bool -- | Indicate how to format math _math :: BlogLiterately -> Maybe String -- | Automatically process ghci sessions? _ghci :: BlogLiterately -> Maybe Bool -- | Automatically upload images? _uploadImages :: BlogLiterately -> Maybe Bool -- | Categories for the post _categories :: BlogLiterately -> [String] -- | Tags for the post _tags :: BlogLiterately -> [String] -- | Blog-specific identifier (e.g. for blogging software handling multiple -- blogs) _blogid :: BlogLiterately -> Maybe String -- | Name of profile to use. _profile :: BlogLiterately -> Maybe String -- | Blog xmlrpc URL _blog :: BlogLiterately -> Maybe String -- | Blog user name _user :: BlogLiterately -> Maybe String -- | Blog password (omit to be interactively prompted) _password :: BlogLiterately -> Maybe String -- | Post title _title :: BlogLiterately -> Maybe String -- | File to post _file :: BlogLiterately -> Maybe String -- | ID of a post to update _postid :: BlogLiterately -> Maybe String -- | Create a "page" instead of a post _page :: BlogLiterately -> Maybe Bool -- | Should the post be published? (Otherwise it is uploaded as a draft.) _publish :: BlogLiterately -> Maybe Bool -- | Don't upload anything; just output HTML to stdout. _htmlOnly :: BlogLiterately -> Maybe Bool -- | Extension arguments, for use e.g. by custom transforms _xtra :: BlogLiterately -> [String] -- | Command-line configuration for use with cmdargs. blOpts :: BlogLiterately style :: Lens' BlogLiterately (Maybe String) hsHighlight :: Lens' BlogLiterately (Maybe HsHighlight) otherHighlight :: Lens' BlogLiterately (Maybe Bool) wplatex :: Lens' BlogLiterately (Maybe Bool) math :: Lens' BlogLiterately (Maybe String) ghci :: Lens' BlogLiterately (Maybe Bool) uploadImages :: Lens' BlogLiterately (Maybe Bool) categories :: Lens' BlogLiterately [String] tags :: Lens' BlogLiterately [String] blogid :: Lens' BlogLiterately (Maybe String) profile :: Lens' BlogLiterately (Maybe String) blog :: Lens' BlogLiterately (Maybe String) user :: Lens' BlogLiterately (Maybe String) password :: Lens' BlogLiterately (Maybe String) title :: Lens' BlogLiterately (Maybe String) file :: Lens' BlogLiterately (Maybe String) postid :: Lens' BlogLiterately (Maybe String) page :: Lens' BlogLiterately (Maybe Bool) publish :: Lens' BlogLiterately (Maybe Bool) htmlOnly :: Lens' BlogLiterately (Maybe Bool) xtra :: Lens' BlogLiterately [String] style' :: BlogLiterately -> [Char] hsHighlight' :: BlogLiterately -> HsHighlight otherHighlight' :: BlogLiterately -> Bool wplatex' :: BlogLiterately -> Bool math' :: BlogLiterately -> [Char] ghci' :: BlogLiterately -> Bool uploadImages' :: BlogLiterately -> Bool blogid' :: BlogLiterately -> [Char] profile' :: BlogLiterately -> [Char] blog' :: BlogLiterately -> [Char] user' :: BlogLiterately -> [Char] password' :: BlogLiterately -> [Char] title' :: BlogLiterately -> [Char] file' :: BlogLiterately -> [Char] postid' :: BlogLiterately -> [Char] page' :: BlogLiterately -> Bool publish' :: BlogLiterately -> Bool htmlOnly' :: BlogLiterately -> Bool instance Monoid BlogLiterately instance Typeable BlogLiterately instance Show BlogLiterately instance Data BlogLiterately -- | Uploading images embedded in posts to the server. module Text.BlogLiterately.Image -- | Transform a document by uploading any "local" images to the server, -- and replacing their filenames with the URLs returned by the server. -- Only upload any given image once (determined by file name), even -- across runs: uploaded images and their associated URL on the server is -- tracked in a special dotfile, -- .BlogLiterately-uploaded-images. uploadAllImages :: BlogLiterately -> Pandoc -> IO Pandoc -- | Upload a file using the metaWeblog.newMediaObject XML-RPC -- method call. uploadIt :: String -> FilePath -> BlogLiterately -> IO (Maybe Value) -- | Prepare a file for upload. mkMediaObject :: FilePath -> IO (Maybe Value) -- | Uploading posts to the server. module Text.BlogLiterately.Post -- | Prepare a post for uploading by creating something of the proper form -- to be an argument to an XML-RPC call. mkPost :: String -> String -> [String] -> [String] -> Bool -> [(String, Value)] -- | Given a name and a list of values, create a named "array" field -- suitable for inclusion in an XML-RPC struct. mkArray :: XmlRpcType [a] => String -> [a] -> [(String, Value)] -- | Given a configuration and a formatted post, upload it to the server. postIt :: BlogLiterately -> String -> IO () -- | Parsing configuration options from special [BLOpts] blocks. module Text.BlogLiterately.Options.Parse -- | Convert the contents of a [BLOpts] block into an options -- record and a list of parse errors. readBLOptions :: String -> ([ParseError], BlogLiterately) -- | Read a single line from a [BLOpts] block. readBLOption :: String -> Either ParseError BlogLiterately -- | Parse a single line from a [BLOpts] block. parseBLOption :: Parser BlogLiterately -- | Tools for putting together a pipeline transforming the source for a -- post into a completely formatted HTML document. module Text.BlogLiterately.Transform -- | The standard set of transforms that are run by default (in order from -- top to bottom): -- --
-- module Main where -- import Text.BlogLiterately -- -- myCustomXF1 = pureTransform ... -- myCustomXF2 = Transform ... -- main = blogLiteratelyWith [myCustomXF1, myCustomXF2] ---- -- See Text.BlogLiterately.Transform for examples of transforms, -- additional transforms which are not enabled by default, and help in -- creating your own. module Text.BlogLiterately.Run -- | The default BlogLiterately application. blogLiterately :: IO () -- | Like blogLiterately, but with the ability to specify additional -- Transforms which will be applied after the standard -- ones. blogLiteratelyWith :: [Transform] -> IO () -- | Like blogLiterately, but with the ability to replace the -- standard Transforms. Use this to implement custom interleaving -- orders of the standard transforms and your own, to exclude some or all -- of the standard transforms, etc. blogLiteratelyCustom :: [Transform] -> IO () -- | This module is provided as a convenient wrapper which re-exports all -- the other Text.BlogLiterately.* modules. module Text.BlogLiterately