BlogLiterately 0.5 → 0.5.1
raw patch · 8 files changed
+110/−15 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.BlogLiterately.Transform: centerImagesXF :: Transform
Files
- BlogLiterately.cabal +13/−2
- CHANGES +17/−0
- doc/BlogLiteratelyDoc.lhs +11/−1
- src/Text/BlogLiterately.hs +2/−0
- src/Text/BlogLiterately/Ghci.hs +14/−4
- src/Text/BlogLiterately/Options.hs +4/−1
- src/Text/BlogLiterately/Run.hs +10/−7
- src/Text/BlogLiterately/Transform.hs +39/−0
BlogLiterately.cabal view
@@ -1,5 +1,5 @@ Name: BlogLiterately-Version: 0.5+Version: 0.5.1 Synopsis: A tool for posting Haskelly articles to blogs Description: Write blog posts in Markdown format, then use BlogLiterately to do syntax highlighting, format ghci sessions, and upload@@ -26,7 +26,7 @@ But if pandoc is already installed against blaze-html-0.4 you may need to reinstall it with the blaze_html_0_5 flag explicitly set.-Cabal-Version: >= 1.8+Cabal-Version: >= 1.10 Homepage: http://byorgey.wordpress.com/blogliterately/ License: GPL License-file: LICENSE@@ -41,6 +41,8 @@ doc/BlogLiteratelyDoc.lhs style/*.css style/hs-style+Bug-reports: http://code.google.com/p/byorgey/issues/list?q=Project:BlogLiterately+ Source-repository head type: darcs location: http://patch-tag.com/r/byorgey/BlogLiterately@@ -71,7 +73,15 @@ Text.BlogLiterately.Post Text.BlogLiterately.Run Text.BlogLiterately.Transform+ Other-modules: Paths_BlogLiterately hs-source-dirs: src+ Other-extensions: DeriveDataTypeable+ FlexibleContexts+ PatternGuards+ RecordWildCards+ TypeOperators+ ViewPatterns+ Default-language: Haskell2010 Executable BlogLiterately Build-Depends: base,@@ -81,3 +91,4 @@ Main-Is: BlogLiterately.hs hs-source-dirs: main Ghc-Options: -fwarn-unused-imports+ Default-language: Haskell2010
CHANGES view
@@ -1,3 +1,20 @@+0.5.1: 30 July 2012++ * Escape < and > characters in ghci output++ * Supress vertical whitespace following ghci commands that produce+ no output++ * add centerImagesXF transform (disabled by default)++ * create bug tracker and add Bug-reports: field to .cabal file++ * re-export Text.BlogLiterately.Run from Text.BlogLiterately++ * improved documentation++ * fix output of --version+ 0.5: 7 July 2012 * expose internals as a library, and create framework for adding
doc/BlogLiteratelyDoc.lhs view
@@ -244,6 +244,14 @@ images). Once you're confident everything looks good, do a final upload with `--upload-images` (and perhaps `--publish`) set. +Customization+-------------++It is possible to create your own variants of `BlogLiterately` which+include custom processing steps. See the [`Text.BlogLiterately.Run`+module](http://hackage.haskell.org/packages/archive/BlogLiterately/latest/doc/html/Text-BlogLiterately-Run.html)+to get started.+ Command-line options -------------------- @@ -314,7 +322,8 @@ For questions, support, feature suggestions, etc., feel free to contact me (Brent Yorgey): `byorgey` on IRC (freenode), or `byorgey`-at gmail.+at gmail. There is also a [bug tracker][] where you can file bugs and+feature requests. [`BlogLiterately`]: http://hackage.haskell.org/package/BlogLiterately [markdown]: http://daringfireball.net/projects/markdown/@@ -326,3 +335,4 @@ [Hackage]: http://hackage.haskell.org/ [MathML]: http://www.w3.org/Math/ [MathJax]: http://www.mathjax.org/+[bug tracker]: http://code.google.com/p/byorgey/issues/list?q=Project:BlogLiterately
src/Text/BlogLiterately.hs view
@@ -19,6 +19,7 @@ , module Text.BlogLiterately.LaTeX , module Text.BlogLiterately.Options , module Text.BlogLiterately.Post+ , module Text.BlogLiterately.Run , module Text.BlogLiterately.Transform ) where @@ -29,4 +30,5 @@ import Text.BlogLiterately.LaTeX import Text.BlogLiterately.Options import Text.BlogLiterately.Post+import Text.BlogLiterately.Run import Text.BlogLiterately.Transform
src/Text/BlogLiterately/Ghci.hs view
@@ -218,10 +218,20 @@ ghciPrompt = colored "gray" "ghci> " formatGhciResult (GhciLine (GhciInput input _) (OK output))- = ghciPrompt ++ input ++ "\n" ++ indent 2 output ++ "\n"+ | all isSpace output+ = ghciPrompt ++ esc input+ | otherwise+ = ghciPrompt ++ esc input ++ "\n" ++ indent 2 (esc output) ++ "\n" formatGhciResult (GhciLine (GhciInput input _) (Unexpected output exp))- = ghciPrompt ++ input ++ "\n" ++ indent 2 (coloredBlock "red" output)- ++ "\n" ++ indent 2 (coloredBlock "blue" exp)- ++ "\n"+ = ghciPrompt ++ esc input ++ "\n" ++ indent 2 (coloredBlock "red" (esc output))+ ++ "\n" ++ indent 2 (coloredBlock "blue" (esc exp))+ ++ "\n" -- XXX the styles above should be configurable...++esc :: String -> String+esc = concatMap escapeOne+ where+ escapeOne '<' = "<"+ escapeOne '>' = ">"+ escapeOne c = [c]
src/Text/BlogLiterately/Options.hs view
@@ -17,6 +17,9 @@ ) where +import Paths_BlogLiterately (version)+import Data.Version+ import System.Console.CmdArgs import Text.BlogLiterately.Highlight@@ -104,5 +107,5 @@ , file = def &= argPos 0 &= typ "FILE" } &= program "BlogLiterately"- &= summary ("BlogLierately v0.4, (c) Robert Greayer 2008-2010, Brent Yorgey 2012\n" +++ &= summary ("BlogLierately v" ++ showVersion version ++ ", (c) Robert Greayer 2008-2010, Brent Yorgey 2012\n" ++ "This program comes with ABSOLUTELY NO WARRANTY\n")
src/Text/BlogLiterately/Run.hs view
@@ -15,11 +15,14 @@ -- 'blogLiteratelyWith' or 'blogLiteratelyCustom'. For example: -- -- > module Main where+-- > import Text.BlogLiterately+-- > -- > myCustomXF = Transform ...--- > main = blogLiteratelyWith [myCustomXF]+-- > main = blogLiteratelyWith [myCustomXF, centerImagesXF] ----- See "Text.BlogLiterately.Transform" for examples of transforms and--- help in creating your own.+-- See "Text.BlogLiterately.Transform" for examples of transforms,+-- additional transforms which are not enabled by default, and help in+-- creating your own. -- ----------------------------------------------------------------------------- @@ -44,15 +47,15 @@ blogLiterately :: IO () blogLiterately = blogLiteratelyCustom standardTransforms --- | Like 'blogLiterately', but with the ability to specify custom+-- | Like 'blogLiterately', but with the ability to specify additional -- 'Transform's which will be applied /after/ the standard ones. blogLiteratelyWith :: [Transform] -> IO () blogLiteratelyWith ts = blogLiteratelyCustom (standardTransforms ++ ts) -- | Like 'blogLiterately', but with the ability to /replace/ the--- standard 'Transform's with your own. Use this to implement--- custom interleaving orders of the standard transforms and your--- own, to exclude some or all of the standard transforms, etc.+-- standard 'Transform's. 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 () blogLiteratelyCustom ts = do bl <- cmdArgs blOpts
src/Text/BlogLiterately/Transform.hs view
@@ -18,12 +18,19 @@ Transform(..), runTransform, runTransforms -- * Standard transforms+ -- $standard+ , wptexifyXF , ghciXF , imagesXF , highlightXF , standardTransforms + -- * Other transforms+ -- $other++ , centerImagesXF+ -- * Transforming documents , xformDoc @@ -84,6 +91,14 @@ runTransforms :: [Transform] -> BlogLiterately -> Kleisli IO Pandoc Pandoc runTransforms ts = foldr (>>>) (C.id) . T.traverse runTransform ts +--------------------------------------------------+-- Standard transforms+--------------------------------------------------++-- $standard+-- These transforms are enabled by default in the standard+-- BlogLiterately executable.+ -- | Format embedded LaTeX for WordPress (if the @wplatex@ flag is set). wptexifyXF :: Transform wptexifyXF = Transform (const (arr wpTeXify)) wplatex@@ -107,6 +122,30 @@ -- 'wptexifyXF', 'ghciXF', 'imagesXF', 'highlightXF'. standardTransforms :: [Transform] standardTransforms = [wptexifyXF, ghciXF, imagesXF, highlightXF]++--------------------------------------------------+-- Other transforms+--------------------------------------------------++-- $other+-- These transforms are not enabled by default. To use them, see+-- "Text.BlogLiterately.Run".++-- | Center any images which occur in a paragraph by themselves.+-- Inline images are not affected.+centerImagesXF :: Transform+centerImagesXF = Transform (const . arr $ centerImages) (const True)++centerImages :: Pandoc -> Pandoc+centerImages = bottomUp centerImage+ where+ centerImage :: [Block] -> [Block]+ centerImage (img@(Para [Image altText (imgUrl, imgTitle)]) : bs) =+ RawBlock "html" "<div style=\"text-align: center;\">"+ : img+ : RawBlock "html" "</div>"+ : bs+ centerImage bs = bs -- | Transform a complete input document string to an HTML output -- string, given a list of transformation passes.