-
Notifications
You must be signed in to change notification settings - Fork 409
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
Add variants of pandoc renderer and compiler for items #1020
Conversation
Out of curiosity, what would the code look like if you used Would it be simpler than implementing a articleCompiler :: Compiler (Item String)
articleCompiler = do
let readerOptions = mathReaderWith defaultHakyllReaderOptions
writerOptions <- getTocOptionsWith $ mathWriterWith defaultHakyllWriterOptions
bibFile <- load "article/bibliography/references.bib"
cslFile <- load "article/bibliography/acm.csl"
getResourceBody
>>= readPandocWith readerOptions
>>= pure . fmap (setMeta "link-citations" True)
>>= processPandocBiblio cslFile bibFile
>>= pure . writePandocWith writerOptions |
The basic setup wouldn't be much more difficult, if a bit uglier in my opinion: myPandocCompiler :: Compiler (Item String)
myPandocCompiler = do
csl <- load @CSL "bib/style.csl"
bib <- load @Biblio "bib/bibliography.bib"
getResourceBody
>>= readPandocWith defaultHakyllReaderOptions
>>= traverse ( pure . usingSideNotesHTML myWriter
<=< pygmentsHighlight
. addSectionLinks
. smallCaps
. setMeta "link-citations" True
)
>>= ((fmap . fmap) (tableiseBib . insertRefHeading) . processPandocBiblio csl bib)
<&> writePandocWith myWriter The bigger problem is that this doesn't work with my setup, as I also have a dedicated RSS compiler that skips many of these steps, as e.g. sidenotes do not make sense without CSS. Since now the main compiler has bibliographic information baked into it, I would have to rewrite this in some clever way, and make the big |
@Minoru friendly ping :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good on the whole -- my only comments are for a brief description of the 'why' these functions exist.
Add renderPandocItemWithTransformM and pandocItemCompilerWithTransformM, which work like the respective functions without the `item' infix, but the transformation function is an Item Pandoc -> Item Pandoc instead of just a Pandoc -> Pandoc. This allows one to more seamlessly compose functions that do require the extra information that an item provides, like bibliographic transformations.
Great, thank you! |
Thanks @LaurentRDC! |
Add
renderPandocItemWithTransformM
andpandocItemCompilerWithTransformM
, which work like the respective functions without the "item" infix, but the transformation function is a monadic "Item Pandoc -> Item Pandoc" instead of just a "Pandoc -> Pandoc". This allows one to more seamlessly compose functions that do require the extra information that an item provides, like bibliographic transformations.My specific use-case for this is exactly adding a nicely formatted bibliography at the end of certain pages.
Here is a real world example with entirely too much code: