Skip to content

Commit c28428f

Browse files
bergusjaspervdj
authored andcommitted
Make Pandoc dependency optional
1 parent 9a23bfb commit c28428f

File tree

9 files changed

+53
-53
lines changed

9 files changed

+53
-53
lines changed

hakyll.cabal

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
102107
Library
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+
225235
Test-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+
314293
Executable hakyll-init
315294
Main-is: Init.hs
316295
Ghc-options: -Wall -threaded

lib/Hakyll.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
5254
import Hakyll.Web.Html
5355
import Hakyll.Web.Html.RelativizeUrls
5456
import Hakyll.Web.Paginate
57+
#ifdef USE_PANDOC
5558
import Hakyll.Web.Pandoc
5659
import Hakyll.Web.Pandoc.Biblio
5760
import Hakyll.Web.Pandoc.FileType
61+
#endif
5862
import Hakyll.Web.Redirect
5963
import Hakyll.Web.Tags
6064
import Hakyll.Web.Template

lib/Hakyll/Core/Util/Parser.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
-- | Parser utilities
33
module Hakyll.Core.Util.Parser
44
( metadataKey
5-
, reservedKeys
65
) where
76

87

stack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ flags:
66
previewServer: True
77
watchServer: True
88
checkExternal: True
9+
usePandoc: True
910
buildWebsite: True
1011

1112
packages:

tests/Hakyll/Core/Rules/Tests.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import Hakyll.Core.Metadata
1717
import Hakyll.Core.Routes
1818
import Hakyll.Core.Rules
1919
import Hakyll.Core.Rules.Internal
20-
import Hakyll.Web.Pandoc
2120
import System.FilePath ((</>))
2221
import Test.Tasty (TestTree, testGroup)
2322
import 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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Hakyll.Core.Compiler
1616
import Hakyll.Core.Identifier
1717
import Hakyll.Core.Item
1818
import Hakyll.Core.Provider
19-
import Hakyll.Web.Pandoc
2019
import Hakyll.Web.Template
2120
import Hakyll.Web.Template.Context
2221
import 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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
--------------------------------------------------------------------------------
2+
{-# LANGUAGE CPP #-}
23
module Main
34
( main
45
) where
@@ -22,7 +23,9 @@ import qualified Hakyll.Core.Util.String.Tests
2223
import qualified Hakyll.Web.CompressCss.Tests
2324
import qualified Hakyll.Web.Html.RelativizeUrls.Tests
2425
import qualified Hakyll.Web.Html.Tests
26+
#ifdef USE_PANDOC
2527
import qualified Hakyll.Web.Pandoc.FileType.Tests
28+
#endif
2629
import qualified Hakyll.Web.Template.Context.Tests
2730
import 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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
2930
import Hakyll.Core.Store (Store)
3031
import qualified Hakyll.Core.Store as Store
3132
import 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)

0 commit comments

Comments
 (0)