on master help sign in
Make Pandoc dependency optional
commitc28428fd8c61cfd21adba5b5fbefc0f8a1784da8 authorBergi <a.d.bergi@web.de> dateTue 20 Mar 2018, 12:57 (9 years ago) parent9a23bfb
9 files changed+53−53
hakyll.cabal+25−46 lib/Hakyll.hs+5−1 lib/Hakyll/Core/Util/Parser.hs−1 stack.yaml+1 tests/Hakyll/Core/Rules/Tests.hs+1−2 tests/Hakyll/Core/Runtime/Tests.hs+1−1 tests/Hakyll/Web/Template/Tests.hs+3−2 tests/TestSuite.hs+5 tests/TestSuite/Util.hs+12
hakyll.cabal+25−46
@@ -99,6 +99,11 @@ Flag buildWebsite
9999 Default: False
100100 Manual: True
101101
102+Flag usePandoc
103+ Description: Include Pandoc support
104+ Default: True
105+ Manual: True
106+
102107Library
103108 Ghc-Options: -Wall
104109 Hs-Source-Dirs: lib
@@ -134,9 +139,6 @@ Library
134139 Hakyll.Web.Html
135140 Hakyll.Web.Html.RelativizeUrls
136141 Hakyll.Web.Paginate
137− Hakyll.Web.Pandoc
138− Hakyll.Web.Pandoc.Biblio
139− Hakyll.Web.Pandoc.FileType
140142 Hakyll.Web.Redirect
141143 Hakyll.Web.Tags
142144 Hakyll.Web.Template
@@ -156,7 +158,6 @@ Library
156158 Hakyll.Core.Provider.Internal
157159 Hakyll.Core.Provider.MetadataCache
158160 Hakyll.Core.Util.Parser
159− Hakyll.Web.Pandoc.Binary
160161 Paths_hakyll
161162
162163 Build-Depends:
@@ -173,14 +174,10 @@ Library
173174 filepath >= 1.0 && < 1.5,
174175 lrucache >= 1.1.1 && < 1.3,
175176 mtl >= 1 && < 2.3,
176− network >= 2.6 && < 2.7,
177177 network-uri >= 2.6 && < 2.7,
178− pandoc >= 2.0.5 && < 2.2,
179− pandoc-citeproc >= 0.14 && < 0.15,
180178 parsec >= 3.0 && < 3.2,
181179 process >= 1.6 && < 1.7,
182180 random >= 1.0 && < 1.2,
183− regex-base >= 0.93 && < 0.94,
184181 regex-tdfa >= 1.1 && < 1.3,
185182 resourcet >= 1.1 && < 1.3,
186183 scientific >= 0.3.4 && < 0.4,
@@ -222,6 +219,19 @@ Library
222219 Cpp-options:
223220 -DCHECK_EXTERNAL
224221
222+ If flag(usePandoc)
223+ Exposed-Modules:
224+ Hakyll.Web.Pandoc
225+ Hakyll.Web.Pandoc.Biblio
226+ Hakyll.Web.Pandoc.FileType
227+ Other-Modules:
228+ Hakyll.Web.Pandoc.Binary
229+ Build-Depends:
230+ pandoc >= 2.0.5 && < 2.2,
231+ pandoc-citeproc >= 0.14 && < 0.15
232+ Cpp-options:
233+ -DUSE_PANDOC
234+
225235Test-suite hakyll-tests
226236 Type: exitcode-stdio-1.0
227237 Hs-source-dirs: tests
@@ -243,7 +253,6 @@ Test-suite hakyll-tests
243253 Hakyll.Web.CompressCss.Tests
244254 Hakyll.Web.Html.RelativizeUrls.Tests
245255 Hakyll.Web.Html.Tests
246− Hakyll.Web.Pandoc.FileType.Tests
247256 Hakyll.Web.Template.Context.Tests
248257 Hakyll.Web.Template.Tests
249258 TestSuite.Util
@@ -256,61 +265,31 @@ Test-suite hakyll-tests
256265 tasty-quickcheck >= 0.8 && < 0.11,
257266 -- Copy pasted from hakyll dependencies:
258267 base >= 4.8 && < 5,
259− binary >= 0.5 && < 0.10,
260− blaze-html >= 0.5 && < 0.10,
261− blaze-markup >= 0.5.1 && < 0.9,
262268 bytestring >= 0.9 && < 0.11,
263269 containers >= 0.3 && < 0.6,
264− cryptohash >= 0.7 && < 0.12,
265− data-default >= 0.4 && < 0.8,
266− deepseq >= 1.3 && < 1.5,
267− directory >= 1.0 && < 1.4,
268270 filepath >= 1.0 && < 1.5,
269− lrucache >= 1.1.1 && < 1.3,
270− mtl >= 1 && < 2.3,
271− network >= 2.6 && < 2.7,
272− network-uri >= 2.6 && < 2.7,
273− pandoc >= 2.0.5 && < 2.2,
274− pandoc-citeproc >= 0.14 && < 0.15,
275− parsec >= 3.0 && < 3.2,
276− process >= 1.6 && < 1.7,
277− random >= 1.0 && < 1.2,
278− regex-base >= 0.93 && < 0.94,
279− regex-tdfa >= 1.1 && < 1.3,
280− resourcet >= 1.1 && < 1.3,
281− scientific >= 0.3.4 && < 0.4,
282− tagsoup >= 0.13.1 && < 0.15,
283271 text >= 0.11 && < 1.3,
284− time >= 1.8 && < 1.10,
285− time-locale-compat >= 0.1 && < 0.2,
286272 unordered-containers >= 0.2 && < 0.3,
287− vector >= 0.11 && < 0.13,
288− yaml >= 0.8.11 && < 0.9,
289− optparse-applicative >= 0.12 && < 0.15
273+ yaml >= 0.8.11 && < 0.9
290274
291275 If flag(previewServer)
292− Build-depends:
293− wai >= 3.2 && < 3.3,
294− warp >= 3.2 && < 3.3,
295− wai-app-static >= 3.1 && < 3.2,
296− http-types >= 0.9 && < 0.13,
297− fsnotify >= 0.2 && < 0.3
298276 Cpp-options:
299277 -DPREVIEW_SERVER
300278
301279 If flag(watchServer)
302− Build-depends:
303− fsnotify >= 0.2 && < 0.3
304280 Cpp-options:
305281 -DWATCH_SERVER
306282
307283 If flag(checkExternal)
308− Build-depends:
309− http-conduit >= 2.2 && < 2.4,
310− http-types >= 0.7 && < 0.13
311284 Cpp-options:
312285 -DCHECK_EXTERNAL
313286
287+ If flag(usePandoc)
288+ Other-modules:
289+ Hakyll.Web.Pandoc.FileType.Tests
290+ Cpp-options:
291+ -DUSE_PANDOC
292+
314293Executable hakyll-init
315294 Main-is: Init.hs
316295 Ghc-options: -Wall -threaded
lib/Hakyll.hs+5−1
@@ -20,10 +20,12 @@ module Hakyll
2020 , module Hakyll.Web.Feed
2121 , module Hakyll.Web.Html
2222 , module Hakyll.Web.Html.RelativizeUrls
23− , module Hakyll.Web.Pandoc
2423 , module Hakyll.Web.Paginate
24+#ifdef USE_PANDOC
25+ , module Hakyll.Web.Pandoc
2526 , module Hakyll.Web.Pandoc.Biblio
2627 , module Hakyll.Web.Pandoc.FileType
28+#endif
2729 , module Hakyll.Web.Redirect
2830 , module Hakyll.Web.Tags
2931 , module Hakyll.Web.Template
@@ -52,9 +54,11 @@ import Hakyll.Web.Feed
5254import Hakyll.Web.Html
5355import Hakyll.Web.Html.RelativizeUrls
5456import Hakyll.Web.Paginate
57+#ifdef USE_PANDOC
5558import Hakyll.Web.Pandoc
5659import Hakyll.Web.Pandoc.Biblio
5760import Hakyll.Web.Pandoc.FileType
61+#endif
5862import Hakyll.Web.Redirect
5963import Hakyll.Web.Tags
6064import Hakyll.Web.Template
lib/Hakyll/Core/Util/Parser.hs−1
@@ -2,7 +2,6 @@
22-- | Parser utilities
33module Hakyll.Core.Util.Parser
44 ( metadataKey
5− , reservedKeys
65 ) where
76
87
stack.yaml+1
@@ -6,6 +6,7 @@ flags:
66 previewServer: True
77 watchServer: True
88 checkExternal: True
9+ usePandoc: True
910 buildWebsite: True
1011
1112packages:
tests/Hakyll/Core/Rules/Tests.hs+1−2
@@ -17,7 +17,6 @@ import Hakyll.Core.Metadata
1717import Hakyll.Core.Routes
1818import Hakyll.Core.Rules
1919import Hakyll.Core.Rules.Internal
20−import Hakyll.Web.Pandoc
2120import System.FilePath ((</>))
2221import Test.Tasty (TestTree, testGroup)
2322import Test.Tasty.HUnit (Assertion, (@=?))
@@ -75,7 +74,7 @@ rules01 ioref = do
7574 -- Compile some posts
7675 match "*.md" $ do
7776 route $ setExtension "html"
78− compile pandocCompiler
77+ compile copyFileCompiler
7978
8079 -- Yeah. I don't know how else to test this stuff?
8180 preprocess $ writeIORef ioref True
tests/Hakyll/Core/Runtime/Tests.hs+1−1
@@ -39,7 +39,7 @@ case01 = do
3939 compile $ do
4040 getResourceBody
4141 >>= saveSnapshot "raw"
42− >>= renderPandoc
42+ >>= renderParagraphs
4343
4444 match (fromList ["partial.html", "partial-helper.html"]) $
4545 compile templateCompiler
tests/Hakyll/Web/Template/Tests.hs+3−2
@@ -16,7 +16,6 @@ import Hakyll.Core.Compiler
1616import Hakyll.Core.Identifier
1717import Hakyll.Core.Item
1818import Hakyll.Core.Provider
19−import Hakyll.Web.Pandoc
2019import Hakyll.Web.Template
2120import Hakyll.Web.Template.Context
2221import Hakyll.Web.Template.Internal
@@ -89,7 +88,9 @@ test (outf, tplf, itemf) = do
8988 out <- resourceString provider outf
9089 tpl <- testCompilerDone store provider tplf templateBodyCompiler
9190 item <- testCompilerDone store provider itemf $
92− pandocCompiler >>= applyTemplate (itemBody tpl) testContext
91+ getResourceBody
92+ >>= renderParagraphs
93+ >>= applyTemplate (itemBody tpl) testContext
9394
9495 out @=? itemBody item
9596 cleanTestEnv
tests/TestSuite.hs+5
@@ -1,4 +1,5 @@
11--------------------------------------------------------------------------------
2+{-# LANGUAGE CPP #-}
23module Main
34 ( main
45 ) where
@@ -22,7 +23,9 @@ import qualified Hakyll.Core.Util.String.Tests
2223import qualified Hakyll.Web.CompressCss.Tests
2324import qualified Hakyll.Web.Html.RelativizeUrls.Tests
2425import qualified Hakyll.Web.Html.Tests
26+#ifdef USE_PANDOC
2527import qualified Hakyll.Web.Pandoc.FileType.Tests
28+#endif
2629import qualified Hakyll.Web.Template.Context.Tests
2730import qualified Hakyll.Web.Template.Tests
2831
@@ -43,7 +46,9 @@ main = defaultMain $ testGroup "Hakyll"
4346 , Hakyll.Web.CompressCss.Tests.tests
4447 , Hakyll.Web.Html.RelativizeUrls.Tests.tests
4548 , Hakyll.Web.Html.Tests.tests
49+#ifdef USE_PANDOC
4650 , Hakyll.Web.Pandoc.FileType.Tests.tests
51+#endif
4752 , Hakyll.Web.Template.Context.Tests.tests
4853 , Hakyll.Web.Template.Tests.tests
4954 ]
tests/TestSuite/Util.hs+12
@@ -8,6 +8,7 @@ module TestSuite.Util
88 , testCompilerDone
99 , testConfiguration
1010 , cleanTestEnv
11+ , renderParagraphs
1112 ) where
1213
1314
@@ -29,6 +30,7 @@ import Hakyll.Core.Provider
2930import Hakyll.Core.Store (Store)
3031import qualified Hakyll.Core.Store as Store
3132import Hakyll.Core.Util.File
33+import Hakyll.Core.Item
3234
3335
3436--------------------------------------------------------------------------------
@@ -102,3 +104,13 @@ cleanTestEnv = do
102104 removeDirectory $ destinationDirectory testConfiguration
103105 removeDirectory $ storeDirectory testConfiguration
104106 removeDirectory $ tmpDirectory testConfiguration
107+
108+
109+--------------------------------------------------------------------------------
110+-- | like 'Hakyll.Web.Pandoc.renderPandoc'
111+-- | but allowing to test without the @usePandoc@ flag
112+renderParagraphs :: Item String -> Compiler (Item String)
113+renderParagraphs = withItemBody (return
114+ . intercalate "\n" -- no trailing line
115+ . map (("<p>"++) . (++"</p>"))
116+ . lines)