-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pandocBiblioCompiler
loads multiple bib files by glob
#943
Conversation
Thanks! Can you please update the doc as well? Right now, nothing even hints at the fact that |
Done! |
Sorry, it just occurred to me that nix-like OSes allow asterisk and question mark in filenames, so this won't be backwards-compatible. How about adding |
How does the existing |
Should work fine, because it doesn't attempt to interpret the filename as a glob. I'm going AFK now, but will try to test this later today.
Perhaps it's just a typo, but in case it's not: the problem I'm describing is not about CSL files, it's about biblio files. Imagine an existing user who has a call like this: pandocBiblioCompiller "style.csl" "refs*.bib" Assume also that they have files "style.csl", "refs*.bib", and "refs1.bib" on the filesystem, and With the current version of This is all very contrived, and in need of testing, but even if there is no problem I'd still prefer a separate function because we already have duplicates for |
I managed to demonstrate the problem I describe above. Here's a patch to current master (8ce2973): diff --git a/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs
index ab78d5b..30f988a 100644
--- a/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs
+++ b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs
@@ -27,6 +27,7 @@ tests = testGroup "Hakyll.Web.Pandoc.Biblio.Tests" $
[ goldenTest01
, goldenTest02
, goldenTest03
+ , goldenTest04
]
--------------------------------------------------------------------------------
@@ -134,3 +135,30 @@ goldenTest03 =
cleanTestEnv
return output)
+
+goldenTest04 :: TestTree
+goldenTest04 =
+ goldenVsString
+ "biblio01"
+ (goldenTestsDataDir </> "cites-meijer.golden")
+ (do
+ -- Code lifted from https://github.com/jaspervdj/hakyll-citeproc-example.
+ logger <- Logger.new Logger.Error
+ let config = testConfiguration { providerDirectory = goldenTestsDataDir }
+ _ <- run RunModeNormal config logger $ do
+ match "default.html" $ compile templateCompiler
+ match "chicago.csl" $ compile cslCompiler
+ -- Note: this compiles *both* refs1.bib and refs*.bib
+ match "refs*.bib" $ compile biblioCompiler
+ match "page.markdown" $ do
+ route $ setExtension "html"
+ compile $
+ pandocBiblioCompiler "chicago.csl" "refs*.bib" >>=
+ loadAndApplyTemplate "default.html" defaultContext
+
+ output <- fmap LBS.fromStrict $ B.readFile $
+ destinationDirectory testConfiguration </> "page.html"
+
+ cleanTestEnv
+
+ return output)
diff --git a/tests/data/biblio/refs*.bib b/tests/data/biblio/refs*.bib
new file mode 100644
index 0000000..e4cd89f
--- /dev/null
+++ b/tests/data/biblio/refs*.bib
@@ -0,0 +1,8 @@
+@inproceedings{meijer1991functional,
+ title={Functional programming with bananas, lenses, envelopes and barbed wire},
+ author={Meijer, Erik and Fokkinga, Maarten and Paterson, Ross},
+ booktitle={Conference on Functional Programming Languages and Computer Architecture},
+ pages={124--144},
+ year={1991},
+ organization={Springer}
+}
diff --git a/tests/data/biblio/refs1.bib b/tests/data/biblio/refs1.bib
new file mode 100644
index 0000000..d7085b5
--- /dev/null
+++ b/tests/data/biblio/refs1.bib
@@ -0,0 +1,8 @@
+@inproceedings{meijer1991functional,
+ title={One},
+ author={Meijer, Erik and Fokkinga, Maarten and Paterson, Ross},
+ booktitle={Conference on Functional Programming Languages and Computer Architecture},
+ pages={124--144},
+ year={1991},
+ organization={Springer}
+} This new test passes on Linux. When I add the patch from this PR, the test fails:
This happens because it picks a reference from "refs1.bib" rather than the intended "refs*.bib".
|
Right, thanks for your feedback. I have defined another |
Great, thank you very much! |
pandocBiblioCompiler
is allowed to take multiple bib files by glob. It should be backwards-compatible.