packages feed

pandoc-unlit (empty) → 0.1.0

raw patch · 4 files changed

+80/−0 lines, 4 filesdep +basedep +pandocsetup-changed

Dependencies added: base, pandoc

Files

+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2012 Simon Hengel <sol@typeful.net>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ pandoc-unlit.cabal view
@@ -0,0 +1,27 @@+name:             pandoc-unlit+version:          0.1.0+synopsis:         Literate Haskell support for GitHub's Markdown flavor+category:         Development+license:          MIT+license-file:     LICENSE+copyright:        (c) 2012 Simon Hengel+author:           Simon Hengel <sol@typeful.net>+maintainer:       Simon Hengel <sol@typeful.net>+build-type:       Simple+cabal-version:    >= 1.6+description:      Documentation is here: <https://github.com/sol/pandoc-unlit#readme>++source-repository head+  type: git+  location: https://github.com/sol/pandoc-unlit++executable pandoc-unlit+  ghc-options:+      -Wall+  hs-source-dirs:+      src+  build-depends:+      base    < 5+    , pandoc+  main-is:+      Main.hs
+ src/Main.hs view
@@ -0,0 +1,31 @@+module Main (main) where++import System.Environment (getArgs, getProgName)+import System.IO (hPutStrLn, stderr)+import System.Exit (exitFailure)+import Text.Pandoc (Pandoc(..), Block(..), readMarkdown, defaultParserState)++main :: IO ()+main = getArgs >>= \args -> case args of+  -- GHC calls unlit like so:+  --+  -- > unlit -h label Foo.lhs /tmp/somefile+  --+  -- The label is meant to be used in line pragmas, like so:+  --+  -- #line 1 "label"+  --+  -- But as Pandoc does not provide location information, we have no use for+  -- it, yet.+  ["-h", _, infile, outfile] ->+    fmap unlit (readFile infile) >>= writeFile outfile+  _ -> do+    name <- getProgName+    hPutStrLn stderr ("usage: " ++ name ++ " -h label infile outfile")+    exitFailure++unlit :: String -> String+unlit input = unlines [x | CodeBlock (_, c, _) x <- nodes, isLiterate c]+  where+    isLiterate c = "literate" `elem` c && "haskell" `elem` c+    Pandoc _ nodes = readMarkdown defaultParserState input