-- 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.7.1.9 -- | 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 :: String -> 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 GHC.Show.Show Text.BlogLiterately.Ghci.GhciLine instance GHC.Show.Show Text.BlogLiterately.Ghci.GhciOutput instance GHC.Show.Show Text.BlogLiterately.Ghci.GhciInput -- | 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 GHC.Classes.Eq Text.BlogLiterately.Highlight.HsHighlight instance GHC.Show.Show Text.BlogLiterately.Highlight.HsHighlight instance Data.Data.Data Text.BlogLiterately.Highlight.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 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 String -> Maybe Bool -> 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 -- | Generate a table of contents? [_toc] :: 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 -- | Format of the file (currently supported: markdown, rst) [_format] :: 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 -- | Process citations? (default: true) [_citations] :: 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) toc :: 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) format :: Lens' BlogLiterately (Maybe String) postid :: Lens' BlogLiterately (Maybe String) page :: Lens' BlogLiterately (Maybe Bool) publish :: Lens' BlogLiterately (Maybe Bool) htmlOnly :: Lens' BlogLiterately (Maybe Bool) citations :: Lens' BlogLiterately (Maybe Bool) xtra :: Lens' BlogLiterately [String] style' :: BlogLiterately -> String hsHighlight' :: BlogLiterately -> HsHighlight otherHighlight' :: BlogLiterately -> Bool toc' :: BlogLiterately -> Bool wplatex' :: BlogLiterately -> Bool math' :: BlogLiterately -> String ghci' :: BlogLiterately -> Bool uploadImages' :: BlogLiterately -> Bool blogid' :: BlogLiterately -> String profile' :: BlogLiterately -> String blog' :: BlogLiterately -> String user' :: BlogLiterately -> String password' :: BlogLiterately -> String title' :: BlogLiterately -> String file' :: BlogLiterately -> String format' :: BlogLiterately -> String postid' :: BlogLiterately -> String page' :: BlogLiterately -> Bool publish' :: BlogLiterately -> Bool htmlOnly' :: BlogLiterately -> Bool citations' :: BlogLiterately -> Bool instance GHC.Base.Monoid Text.BlogLiterately.Options.BlogLiterately instance Data.Data.Data Text.BlogLiterately.Options.BlogLiterately instance GHC.Show.Show Text.BlogLiterately.Options.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): -- -- standardTransforms :: [Transform] -- | Extract blocks tagged with [BLOpts] and use their contents as -- options. optionsXF :: Transform -- | Load options from a profile if one is specified. profileXF :: Transform -- | Read a user-supplied style file and add its contents to the -- highlighting options. highlightOptsXF :: Transform -- | Prompt the user for a password if the blog field is set but -- no password has been provided. passwordXF :: Transform -- | Potentially extract a title from the metadata block, and set it in the -- options record. titleXF :: Transform -- | Format embedded LaTeX for WordPress (if the wplatex flag is -- set). wptexifyXF :: Transform -- | Format embedded ghci sessions (if the ghci flag is -- set). ghciXF :: Transform -- | Upload embedded local images to the server (if the -- uploadImages flag is set). uploadImagesXF :: Transform -- | Perform syntax highlighting on code blocks. highlightXF :: Transform -- | Center any images which occur in a paragraph by themselves. Inline -- images are not affected. centerImagesXF :: Transform -- | Format citations. citationsXF :: Transform -- | A document transformation consists of two parts: an actual -- transformation, expressed as a function over Pandoc documents, and a -- condition specifying whether the transformation should actually be -- applied. -- -- The transformation itself takes a BlogLiterately configuration -- as an argument. You may of course ignore it if you do not need to know -- anything about the configuration. The --xtra (or -x) -- flag is also provided especially as a method of getting information -- from the command-line to custom extensions. Arguments passed via -- -x on the command line are available from the xtra -- field of the BlogLiterately configuration. -- -- The transformation is then specified as a stateful computation over -- both a BlogLiterately options record, and a Pandoc -- document. It may also have effects in the IO monad. -- -- -- -- For examples, see the implementations of the standard transforms -- below. data Transform Transform :: StateT (BlogLiterately, Pandoc) IO () -> (BlogLiterately -> Bool) -> Transform -- | A document transformation, which can transform both the document and -- the options and have effects in the IO monad. The options record can -- be transformed because the document itself may contain information -- which affects the options. [getTransform] :: Transform -> StateT (BlogLiterately, Pandoc) IO () -- | A condition under which to run the transformation. [xfCond] :: Transform -> BlogLiterately -> Bool -- | Construct a transformation from a pure function. pureTransform :: (BlogLiterately -> Pandoc -> Pandoc) -> (BlogLiterately -> Bool) -> Transform -- | Construct a transformation from a function in the IO monad. ioTransform :: (BlogLiterately -> Pandoc -> IO Pandoc) -> (BlogLiterately -> Bool) -> Transform -- | Run a Transform (if its condition is met). runTransform :: Transform -> StateT (BlogLiterately, Pandoc) IO () -- | Run a pipeline of Transforms. runTransforms :: [Transform] -> BlogLiterately -> Pandoc -> IO (BlogLiterately, Pandoc) -- | Transform a complete input document string to an HTML output string, -- given a list of transformation passes. xformDoc :: BlogLiterately -> [Transform] -> String -> IO (BlogLiterately, String) -- | Turn CRLF pairs into a single LF. This is necessary -- since readMarkdown is picky about line endings. fixLineEndings :: String -> String -- | Functions for creating BlogLiterately executables. By -- default, installing this library results in the installation of a -- standard executable, called BlogLiterately, which corresponds -- to blogLiterately from this module. However, you can create -- your own custom executables with extra custom functionality using -- blogLiteratelyWith or blogLiteratelyCustom. For example: -- --
--   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