Skip to content
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

Preserve file extension of bibliography files #895

Merged
merged 2 commits into from
Oct 16, 2021
Merged

Preserve file extension of bibliography files #895

merged 2 commits into from
Oct 16, 2021

Conversation

benjamineskola
Copy link
Contributor

Pandoc supports bibliographies in CSL YAML and JSON formats. However, because of the way Hakyll loads the bibliographies, only BibTeX works; Pandoc determines the input type based on the file extension, but Hakyll hardcodes .bib.

This PR changes the processing function to preserve the input file’s extension in the file Hakyll passes to Pandoc.

(I don’t have much experience of writing Haskell and I’m a bit uncertain why I had to e.g. add T.pack to pass a string to Pandoc.MetaString; I’m sure there must be a better way of writing this.)

Fixes #894.

Copy link
Collaborator

@Minoru Minoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me! Would it be too much to ask for some tests? We already have one in tests/Hakyll/Web/Pandoc/Biblio/Tests.hs, shouldn't be too hard to add one or two more.

@Minoru
Copy link
Collaborator

Minoru commented Oct 16, 2021

I’m a bit uncertain why I had to e.g. add T.pack to pass a string to Pandoc.MetaString

Haskell has multiple string types. takeExtension returns String, but Pandoc.MetaString takes Text, so you have to convert it with T.pack. The other call to Pandoc.MetaString doesn't have to do this because it uses a string literal, which is converted automatically by the OverloadedStrings extension which we enabled at the beginning of the file.

Strings in Haskell are a bit of mess. You aren't the first one to get tripped over them, and probably not the last :(

I’m sure there must be a better way of writing this.

If there is, I don't see it. Good job 👍

Copy link
Collaborator

@Minoru Minoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving along quite well! I think it'll pass the CI once the hakyll.cabal issue is resolved.

tests/Hakyll/Web/Pandoc/Biblio/Tests.hs Outdated Show resolved Hide resolved
tests/Hakyll/Web/Pandoc/Biblio/Tests.hs Show resolved Hide resolved
Copy link
Collaborator

@Minoru Minoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks excellent! 👍

@Minoru Minoru merged commit 2b7be08 into jaspervdj:master Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

processPandocBiblio doesn’t support all bibliography formats that Pandoc does
2 participants