on master help sign in
Move to Pandoc 2
commitf09cfe477ec4b7d51d4c1beb8eb5710705f93f1c authorVaibhav Sagar <vaibhavsagar@gmail.com> dateTue 21 Nov 2017, 05:35 (9 years ago) parentddf077e
3 files changed+23−22
hakyll.cabal+8−8 lib/Hakyll/Web/Pandoc.hs+13−8 stack.yaml+2−6
hakyll.cabal+8−8
@@ -168,10 +168,10 @@ Library
168168 mtl >= 1 && < 2.3,
169169 network >= 2.6 && < 2.7,
170170 network-uri >= 2.6 && < 2.7,
171− pandoc >= 1.14 && < 1.20,
172− pandoc-citeproc >= 0.10.5 && < 0.11,
171+ pandoc >= 2.0 && < 2.1,
172+ pandoc-citeproc >= 0.12 && < 0.13,
173173 parsec >= 3.0 && < 3.2,
174− process >= 1.0 && < 1.6,
174+ process >= 1.6 && < 1.7,
175175 random >= 1.0 && < 1.2,
176176 regex-base >= 0.93 && < 0.94,
177177 regex-tdfa >= 1.1 && < 1.3,
@@ -179,7 +179,7 @@ Library
179179 scientific >= 0.3.4 && < 0.4,
180180 tagsoup >= 0.13.1 && < 0.15,
181181 text >= 0.11 && < 1.3,
182− time >= 1.4 && < 1.8,
182+ time >= 1.8 && < 1.9,
183183 time-locale-compat >= 0.1 && < 0.2,
184184 unordered-containers >= 0.2 && < 0.3,
185185 vector >= 0.11 && < 0.13,
@@ -263,10 +263,10 @@ Test-suite hakyll-tests
263263 mtl >= 1 && < 2.3,
264264 network >= 2.6 && < 2.7,
265265 network-uri >= 2.6 && < 2.7,
266− pandoc >= 1.14 && < 1.20,
267− pandoc-citeproc >= 0.10.5 && < 0.11,
266+ pandoc >= 2.0 && < 2.1,
267+ pandoc-citeproc >= 0.12 && < 0.13,
268268 parsec >= 3.0 && < 3.2,
269− process >= 1.0 && < 1.6,
269+ process >= 1.6 && < 1.7,
270270 random >= 1.0 && < 1.2,
271271 regex-base >= 0.93 && < 0.94,
272272 regex-tdfa >= 1.1 && < 1.3,
@@ -274,7 +274,7 @@ Test-suite hakyll-tests
274274 scientific >= 0.3.4 && < 0.4,
275275 tagsoup >= 0.13.1 && < 0.15,
276276 text >= 0.11 && < 1.3,
277− time >= 1.4 && < 1.8,
277+ time >= 1.8 && < 1.9,
278278 time-locale-compat >= 0.1 && < 0.2,
279279 unordered-containers >= 0.2 && < 0.3,
280280 vector >= 0.11 && < 0.13,
lib/Hakyll/Web/Pandoc.hs+13−8
@@ -25,6 +25,8 @@ module Hakyll.Web.Pandoc
2525import qualified Data.Set as S
2626import Text.Pandoc
2727import Text.Pandoc.Error (PandocError (..))
28+import Text.Pandoc.Highlighting (pygments)
29+import qualified Data.Text as T
2830
2931
3032--------------------------------------------------------------------------------
@@ -48,10 +50,10 @@ readPandocWith
4850 -> Item String -- ^ String to read
4951 -> Compiler (Item Pandoc) -- ^ Resulting document
5052readPandocWith ropt item =
51− case traverse (reader ropt (itemFileType item)) item of
52− Left (ParseFailure err) -> fail $
53+ case runPure $ traverse (reader ropt (itemFileType item)) (fmap T.pack item) of
54+ Left (PandocParseError err) -> fail $
5355 "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ err
54− Left (ParsecError _ err) -> fail $
56+ Left (PandocParsecError _ err) -> fail $
5557 "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ show err
5658 Right item' -> return item'
5759 where
@@ -69,7 +71,7 @@ readPandocWith ropt item =
6971 "Hakyll.Web.readPandocWith: I don't know how to read a file of " ++
7072 "the type " ++ show t ++ " for: " ++ show (itemIdentifier item)
7173
72− addExt ro e = ro {readerExtensions = S.insert e $ readerExtensions ro}
74+ addExt ro e = ro {readerExtensions = enableExtension e $ readerExtensions ro}
7375
7476
7577--------------------------------------------------------------------------------
@@ -84,7 +86,10 @@ writePandoc = writePandocWith defaultHakyllWriterOptions
8486writePandocWith :: WriterOptions -- ^ Writer options for pandoc
8587 -> Item Pandoc -- ^ Document to write
8688 -> Item String -- ^ Resulting HTML
87−writePandocWith wopt = fmap $ writeHtmlString wopt
89+writePandocWith wopt (Item itemi doc) =
90+ case runPure $ writeHtml5String wopt doc of
91+ Left (PandocSomeError err) -> error $ "Hakyll.Web.Pandoc.writePandocWith: unknown error: " ++ err
92+ Right item' -> Item itemi $ T.unpack item'
8893
8994
9095--------------------------------------------------------------------------------
@@ -147,7 +152,7 @@ defaultHakyllReaderOptions :: ReaderOptions
147152defaultHakyllReaderOptions = def
148153 { -- The following option causes pandoc to read smart typography, a nice
149154 -- and free bonus.
150− readerSmart = True
155+ readerExtensions = enableExtension Ext_smart pandocExtensions
151156 }
152157
153158
@@ -157,8 +162,8 @@ defaultHakyllWriterOptions :: WriterOptions
157162defaultHakyllWriterOptions = def
158163 { -- This option causes literate haskell to be written using '>' marks in
159164 -- html, which I think is a good default.
160− writerExtensions = S.insert Ext_literate_haskell (writerExtensions def)
165+ writerExtensions = enableExtension Ext_smart pandocExtensions
161166 , -- We want to have hightlighting by default, to be compatible with earlier
162167 -- Hakyll releases
163− writerHighlight = True
168+ writerHighlightStyle = Just pygments
164169 }
stack.yaml+2−6
@@ -1,10 +1,6 @@
1−resolver: nightly-2017-06-19
1+resolver: nightly-2017-11-20
22extra-package-dbs: []
3−extra-deps:
4−- 'optparse-applicative-0.14.0.0'
5−- 'pandoc-citeproc-0.10.5.1'
6−- 'QuickCheck-2.10.0.1'
7−- 'tasty-quickcheck-0.9'
3+extra-deps: []
84
95flags:
106 hakyll: