pandoc-lens (empty) → 0.1.0.0
raw patch · 4 files changed
+133/−0 lines, 4 filesdep +basedep +containersdep +lenssetup-changed
Dependencies added: base, containers, lens, pandoc-types
Files
- LICENSE +30/−0
- Setup.hs +2/−0
- Text/Pandoc/Lens.hs +79/−0
- pandoc-lens.cabal +22/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2014, Ben Gamari++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Ben Gamari nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Text/Pandoc/Lens.hs view
@@ -0,0 +1,79 @@+{-# LANGUAGE RankNTypes #-}++module Text.Pandoc.Lens where+ +import Control.Applicative+import Control.Lens+import Text.Pandoc.Definition+import Data.Map (Map)++body :: Lens' Pandoc [Block]+body = lens (\(Pandoc _ b)->b) (\(Pandoc m _) b->Pandoc m b)++_Plain :: Prism' Block [Inline]+_Plain = prism' Plain f+ where+ f (Plain x) = Just x+ f _ = Nothing++_Para :: Prism' Block [Inline]+_Para = prism' Para f+ where+ f (Para x) = Just x+ f _ = Nothing++_CodeBlock :: Prism' Block String+_CodeBlock = prism' (CodeBlock nullAttr) f+ where+ f (CodeBlock _ x) = Just x+ f _ = Nothing++_BlockQuote :: Prism' Block [Block]+_BlockQuote = prism' BlockQuote f+ where+ f (BlockQuote x) = Just x+ f _ = Nothing++_BulletList :: Prism' Block [[Block]]+_BulletList = prism' BulletList f+ where+ f (BulletList x) = Just x+ f _ = Nothing+ +_DefinitionList :: Prism' Block [([Inline], [[Block]])]+_DefinitionList = prism' DefinitionList f+ where+ f (DefinitionList x) = Just x+ f _ = Nothing++_HorizontalRule :: Prism' Block ()+_HorizontalRule = prism' (const HorizontalRule) f+ where+ f HorizontalRule = Just ()+ f _ = Nothing++_Null :: Prism' Block ()+_Null = prism' (const Null) f+ where+ f Null = Just ()+ f _ = Nothing++--makePrisms ''Inline+--makePrisms ''MetaValue++--meta :: String -> Prism' Pandoc MetaValue+meta m = metaL . unwrap . ix m+ where+ unwrap :: Iso' Meta (Map String MetaValue)+ unwrap = iso unMeta Meta+ metaL :: Lens' Pandoc Meta+ metaL = lens (\(Pandoc m _)->m) (\(Pandoc _ a) m->Pandoc m a)+ +class HasAttr a where+ attributes :: Traversal' a Attr+ +instance HasAttr Block where+ attributes f (CodeBlock a s) = fmap (\a'->CodeBlock a' s) (f a)+ attributes f (Header n a s) = fmap (\a'->Header n a' s) (f a)+ attributes f (Div a s) = fmap (\a'->Div a' s) (f a)+ attributes _ x = pure x
+ pandoc-lens.cabal view
@@ -0,0 +1,22 @@+name: pandoc-lens+version: 0.1.0.0+synopsis: Lenses for Pandoc documents+description: Lenses for Pandoc documents+homepage: http://github.com/bgamari/pandoc-lens+license: BSD3+license-file: LICENSE+author: Ben Gamari+maintainer: bgamari.foss@gmail.com+copyright: (c) 2014 Ben Gamari+category: Text+build-type: Simple+cabal-version: >=1.10++source-repository head+ type: git+ location: git://github.com/bgamari/pandoc-lenses++library+ exposed-modules: Text.Pandoc.Lens+ build-depends: base >=4.7 && <4.8, pandoc-types >=1.12 && <1.13, lens >=4.2 && <4.3, containers+ default-language: Haskell2010