Skip to content

Commit

Permalink
Allow pandoc 3 (jaspervdj#965)
Browse files Browse the repository at this point in the history
* Allow pandoc 3

* Updated golden tests with respect to pandoc 3

* Use CPP to check whether pandoc 2 or 3 is being used

* More specific pandoc version bounds

* Added stub in changelog

---------

Co-authored-by: Laurent René de Cotret <l.rdc@socivolta.com>
  • Loading branch information
LaurentRDC and LaurentRDC authored Jan 31, 2023
1 parent cd74877 commit 2ea5d68
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ title: Releases

# Releases

## Hakyll 4.15.2.0 (2022-01-20)

- Added support for pandoc 3 (#965). Note that the behavior of Hakyll's
`readPandocBiblios` and `readPandocBiblio` is different whether pandoc
2 or 3 is installed.

## Hakyll 4.15.1.1 (2022-01-20)

- Extend the documentation for `Hakyll.Core.Identifier` (contribution by
Expand Down
15 changes: 10 additions & 5 deletions hakyll.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ Data-files:
Extra-source-files:
CHANGELOG.md
tests/data/biblio/chicago.csl
tests/data/biblio/cites-meijer.golden
tests/data/biblio/cites-multiple.golden
tests/data/biblio/cites-meijer-pandoc2.golden
tests/data/biblio/cites-meijer-pandoc3.golden
tests/data/biblio/cites-multiple-pandoc2.golden
tests/data/biblio/cites-multiple-pandoc3.golden
tests/data/biblio/cites-multiple.markdown
tests/data/biblio/default.html
tests/data/biblio/page.markdown
Expand Down Expand Up @@ -208,13 +210,13 @@ Library
time-locale-compat >= 0.1 && < 0.2,
unordered-containers >= 0.2 && < 0.3,
vector >= 0.11 && < 0.14,
wai-app-static >= 3.1 && < 3.2,
yaml >= 0.8.11 && < 0.12

If flag(previewServer)
Build-depends:
wai >= 3.2 && < 3.3,
warp >= 3.2 && < 3.4,
wai-app-static >= 3.1 && < 3.2,
http-types >= 0.9 && < 0.13,
fsnotify >= 0.2 && < 0.5
Cpp-options:
Expand Down Expand Up @@ -246,7 +248,7 @@ Library
Other-Modules:
Hakyll.Web.Pandoc.Binary
Build-Depends:
pandoc >= 2.11 && < 2.20
pandoc >= 2.11 && < 2.19.2 || >= 3.0 && < 3.1
Cpp-options:
-DUSE_PANDOC

Expand Down Expand Up @@ -312,6 +314,9 @@ Test-suite hakyll-tests
Hakyll.Web.Pandoc.FileType.Tests
Cpp-options:
-DUSE_PANDOC
Build-Depends:
pandoc >= 2.11 && < 2.19.2 || >= 3.0 && < 3.1


Executable hakyll-init
Main-is: Init.hs
Expand Down Expand Up @@ -344,4 +349,4 @@ Executable hakyll-website
base >= 4.12 && < 5,
directory >= 1.0 && < 1.4,
filepath >= 1.0 && < 1.5,
pandoc >= 2.11 && < 2.20
pandoc >= 2.11 && < 2.19.2 || >= 3.0 && < 3.1
32 changes: 29 additions & 3 deletions tests/Hakyll/Web/Pandoc/Biblio/Tests.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
module Hakyll.Web.Pandoc.Biblio.Tests
( tests
) where
Expand Down Expand Up @@ -37,7 +38,7 @@ goldenTest01 :: TestTree
goldenTest01 =
goldenVsString
"biblio01"
(goldenTestsDataDir </> "cites-meijer.golden")
(goldenTestsDataDir </> goldenTest)
(do
-- Code lifted from https://github.com/jaspervdj/hakyll-citeproc-example.
logger <- Logger.new Logger.Error
Expand Down Expand Up @@ -65,12 +66,19 @@ goldenTest01 =
cleanTestEnv

return output)

where
goldenTest =
if pandocMajorVersion == 2
then "cites-meijer-pandoc2.golden"
else "cites-meijer-pandoc3.golden"


goldenTest02 :: TestTree
goldenTest02 =
goldenVsString
"biblio02"
(goldenTestsDataDir </> "cites-meijer.golden")
(goldenTestsDataDir </> goldenTest)
(do
-- Code lifted from https://github.com/jaspervdj/hakyll-citeproc-example.
logger <- Logger.new Logger.Error
Expand Down Expand Up @@ -98,12 +106,17 @@ goldenTest02 =
cleanTestEnv

return output)
where
goldenTest =
if pandocMajorVersion == 2
then "cites-meijer-pandoc2.golden"
else "cites-meijer-pandoc3.golden"

goldenTest03 :: TestTree
goldenTest03 =
goldenVsString
"biblio03"
(goldenTestsDataDir </> "cites-multiple.golden")
(goldenTestsDataDir </> goldenTest)
(do
-- Code lifted from https://github.com/jaspervdj/hakyll-citeproc-example.
logger <- Logger.new Logger.Error
Expand Down Expand Up @@ -133,3 +146,16 @@ goldenTest03 =
cleanTestEnv

return output)
where
goldenTest =
if pandocMajorVersion == 2
then "cites-multiple-pandoc2.golden"
else "cites-multiple-pandoc3.golden"

--------------------------------------------------------------------------------
pandocMajorVersion :: Int
#if MIN_VERSION_pandoc(3,0,0)
pandocMajorVersion = 3
#else
pandocMajorVersion = 2
#endif
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/data/biblio/cites-meijer-pandoc3.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>This page cites a paper.</title>
</head>
<body>
<h1>This page cites a paper.</h1>
<p>I would like to cite one of my favourite papers <span class="citation" data-cites="meijer1991functional">(Meijer, Fokkinga, and Paterson 1991)</span> here.</p>
<div id="refs" class="references csl-bib-body hanging-indent" role="list">
<div id="ref-meijer1991functional" class="csl-entry" role="listitem">
Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. <span>“Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.”</span> In <em>Conference on Functional Programming Languages and Computer Architecture</em>, 124–44. Springer.
</div>
</div>
</body>
</html>
File renamed without changes.
20 changes: 20 additions & 0 deletions tests/data/biblio/cites-multiple-pandoc3.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>This page cites a paper and a book.</title>
</head>
<body>
<h1>This page cites a paper and a book.</h1>
<p>I would like to cite one of my favourite papers <span class="citation" data-cites="meijer1991functional">(Meijer, Fokkinga, and Paterson 1991)</span> here.</p>
<p>And also a book <span class="citation" data-cites="lipovaca2012">(Lipovača 2012)</span>.</p>
<div id="refs" class="references csl-bib-body hanging-indent" role="list">
<div id="ref-lipovaca2012" class="csl-entry" role="listitem">
Lipovača, Miran. 2012. <em>Learn You a Haskell for Great Good! A Beginner’s Guide</em>. San Francisco, CA: No Starch Press.
</div>
<div id="ref-meijer1991functional" class="csl-entry" role="listitem">
Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. <span>“Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.”</span> In <em>Conference on Functional Programming Languages and Computer Architecture</em>, 124–44. Springer.
</div>
</div>
</body>
</html>

0 comments on commit 2ea5d68

Please sign in to comment.