BlogLiterately 0.6.1 → 0.6.2
raw patch · 5 files changed
+84/−24 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Text.BlogLiterately.Options: _format :: BlogLiterately -> Maybe String
+ Text.BlogLiterately.Options: format :: Lens' BlogLiterately (Maybe String)
+ Text.BlogLiterately.Options: format' :: BlogLiterately -> [Char]
- Text.BlogLiterately.Options: 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
+ Text.BlogLiterately.Options: 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 String -> Maybe Bool -> Maybe Bool -> Maybe Bool -> [String] -> BlogLiterately
Files
- BlogLiterately.cabal +1/−1
- CHANGES.md +6/−0
- doc/BlogLiteratelyDoc.lhs +54/−21
- src/Text/BlogLiterately/Options.hs +10/−0
- src/Text/BlogLiterately/Transform.hs +13/−2
BlogLiterately.cabal view
@@ -1,5 +1,5 @@ Name: BlogLiterately-Version: 0.6.1+Version: 0.6.2 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
CHANGES.md view
@@ -1,3 +1,8 @@+0.6.2 (29 August 2013)+----------------------++ * Enable input in reStructuredText format+ 0.6.1 (27 August 2013) ---------------------- @@ -6,6 +11,7 @@ * Wrap the results of `hscolour` in `pre` and `code` tags with classes, to conform more closely to the style used by `highlighting-kate`+ * Output an entire URL upon a successful post 0.6.0.2 (15 May 2013) ---------------------
doc/BlogLiteratelyDoc.lhs view
@@ -9,14 +9,17 @@ [`BlogLiterately`][] is a tool for uploading blog posts to servers that support the [MetaWeblog API][metaweblog] (such as [WordPress][]-based blogs and many others). Blog posts to be-published via `BlogLiterately` are written in [markdown][] format,-with-[extensions supported](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown)+published via `BlogLiterately` are written in [markdown][] or+[reStructuredText][] format, with [extensions+supported](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown) by [pandoc][]. Posts may be actual "bird-style" literate Haskell-files, with commentary in markdown. Though `BlogLiterately` offers-special support for literate Haskell in particular, it is also useful-for writing posts including code written in other languages, or even-no code at all.+files, with commentary formatted using markdown or reStructuredText.+Though `BlogLiterately` offers special support for literate Haskell in+particular, it is also useful for writing posts including code written+in other languages, or even no code at all. You may also be+interested in the [BlogLiterately-diagrams][] package, a plugin for+`BlogLiterately` which allows embedding images in your posts defined+using the [diagrams][] vector graphics framework. `BlogLiterately` includes support for syntax highlighting, $\LaTeX$ (including special support for WordPress blogs), automatic image@@ -61,19 +64,34 @@ Markdown and pandoc ------------------- -`BlogLiterately` takes as input files written using the [markdown][]-format. See the [markdown website][markdown] for detailed-documentation. `BlogLiterately` uses [pandoc][] for reading markdown,-which also [supports a few-extensions](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown)+`BlogLiterately` can take as input files written using the+[markdown][] format (as well as [reStructuredText][]). See the+[markdown website][markdown] for detailed documentation.+`BlogLiterately` uses [pandoc][] for reading markdown, which also+[supports a few extensions](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown) to the basic format. +Determining input format+------------------------++`BlogLiterately` takes the following steps to determine whether an+input file is in markdown or reStructuredText format:++ 1. If the format is explicitly specified on the command line with+ `--format=markdown` or `--format=rst`, the specified format will be+ used regardless of the file name.++ 2. Otherwise, the filename extension is consulted: if it is `.rst`,+ `.rest`, or `.txt`, reStructuredText will be assumed; otherwise,+ markdown is assumed.+ Code blocks and syntax highlighting ----------------------------------- Code segments (including actual source lines from literate haskell-files, as well as markdown code blocks) may be syntax highlighted.-Two different syntax highlighting libraries are supported:+files, as well as markdown or reStructuredText code blocks) may be+syntax highlighted. Two different syntax highlighting libraries are+supported: * [hscolour][] is specifically for syntax highlighting of Haskell code, and is the standard highlighter used on [Hackage][] and@@ -92,10 +110,18 @@ -- This is a code segment, but what language is it? foo :: String -> String -However, markdown has no way of specifying the language used in a code-block, making support for syntax highlighting problematic. Pandoc-offers [an alternative-syntax](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown)+Similarly, in reStructuredText, a code block is constructed by a double colon+followed by an indented block:++ ::+ + -- This is a code segment, but what language is it?+ foo :: String -> String++However, markdown does not have a way of specifying the language used+in a code block, making support for syntax highlighting problematic.+Pandoc offers+[an alternative syntax](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown) for code segments which does allow specifying the language: ~~~~ { .haskell }@@ -103,9 +129,11 @@ foo :: String -> String ~~~~ -`BlogLiterately` also supports one additional style, consisting of a-normal markdown indented code block with an extra tag at the top,-enclosed in square brackets:+The above syntax works only with markdown. `BlogLiterately` also+supports one additional style which works with both markdown and+reStructuredText, consisting of a normal code block (indented and/or+preceded by a double colon) with an extra tag at the top, enclosed in+square brackets: [haskell] -- This is also a Haskell code segment!@@ -258,6 +286,8 @@  +(or the corresponding reStructuredText syntax).+ The URL determines whether the image will be uploaded. A *remote* URL is any beginning with `http` or a forward slash (interpreted as a URL relative to the server root). In all other cases it is assumed that@@ -439,6 +469,9 @@ [`BlogLiterately`]: http://hackage.haskell.org/package/BlogLiterately [markdown]: http://daringfireball.net/projects/markdown/+[reStructuredText]: http://docutils.sourceforge.net/docs/user/rst/quickref.html+[BlogLiterately-diagrams]: http://hackage.haskell.org/package/BlogLiterately%2Ddiagrams+[diagrams]: http://projects.haskell.org/diagrams/ [pandoc]: http://johnmacfarlane.net/pandoc/ [hscolour]: http://www.cs.york.ac.uk/fp/darcs/hscolour/ [highlighting-kate]: http://johnmacfarlane.net/highlighting-kate/
src/Text/BlogLiterately/Options.hs view
@@ -36,6 +36,7 @@ , password , title , file+ , format , postid , page , publish@@ -59,6 +60,7 @@ , password' , title' , file'+ , format' , postid' , page' , publish'@@ -98,6 +100,9 @@ , _password :: Maybe String -- ^ Blog password (omit to be interactively prompted) , _title :: Maybe String -- ^ Post title , _file :: Maybe String -- ^ File to post+ , _format :: Maybe String -- ^ Format of the file+ -- (currently supported:+ -- markdown, rst) , _postid :: Maybe String -- ^ ID of a post to update , _page :: Maybe Bool -- ^ Create a \"page\" instead of a post , _publish :: Maybe Bool -- ^ Should the post be published?@@ -135,6 +140,7 @@ , _password = Nothing , _title = Nothing , _file = Nothing+ , _format = Nothing , _postid = Nothing , _page = Nothing , _publish = Nothing@@ -160,6 +166,7 @@ , _password = combine _password , _title = combine _title , _file = combine _file+ , _format = combine _format , _postid = combine _postid , _page = combine _page , _publish = combine _publish@@ -190,6 +197,7 @@ password' = fromMaybe "" . view password title' = fromMaybe "" . view title file' = fromMaybe "" . view file+format' = fromMaybe "" . view format postid' = fromMaybe "" . view postid page' = fromMaybe False . view page publish' = fromMaybe False . view publish@@ -268,6 +276,8 @@ &= name "password" &= name "p" &= explicit , _title = def &= typ "TITLE" &= help "post title" &= name "title" &= name "t" &= explicit+ , _format = def &= typ "FORMAT" &= help "input format: markdown or rst"+ &= name "format" &= name "f" &= explicit , _file = def &= argPos 0 &= typ "FILE" } &= program "BlogLiterately"
src/Text/BlogLiterately/Transform.hs view
@@ -58,7 +58,7 @@ import System.Directory (doesFileExist, getAppUserDataDirectory) import System.Exit (exitFailure)-import System.FilePath ((<.>), (</>))+import System.FilePath (takeExtension, (<.>), (</>)) import System.IO (hFlush, stdout) import Text.Blaze.Html.Renderer.String (renderHtml) import Text.Pandoc@@ -322,13 +322,24 @@ xformDoc :: BlogLiterately -> [Transform] -> String -> IO (BlogLiterately, String) xformDoc bl xforms = fixLineEndings- >>> readMarkdown parseOpts+ >>> parseFile bl parseOpts >>> runTransforms xforms bl >=> _2 (return . writeHtml writeOpts) >=> _2 (return . renderHtml) where+ parseFile bl opts =+ case bl^.format of+ Just "rst" -> readRST opts+ Just _ -> readMarkdown opts+ Nothing ->+ case takeExtension (file' bl) of+ ".rst" -> readRST opts+ ".rest" -> readRST opts+ ".txt" -> readRST opts+ _ -> readMarkdown opts+ parseOpts = def { readerExtensions = Ext_literate_haskell `S.insert` readerExtensions def