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

add an option to processCitations to put the processed references into the metadata under a key to inserted in a template later #7969

Closed
andrewufrank opened this issue Mar 16, 2022 · 8 comments

Comments

@andrewufrank
Copy link

andrewufrank commented Mar 16, 2022

Describe your proposed improvement and the problem it solves.
I use processCitations from Pandoc.Text.Citeproc from a Haskell program to produce HTML code, which is later merged with a template (using renderTemplate).

It seems unfortunate, that the references produced with processCitations are immediately inserted in the text - with limited choice of the header, header style etc. It would be useful if the rendered references were available in the meta data (under a key). This would allow then to insert the references in the template using the key under a heading set in the template.

Describe alternatives you've considered.
It would be possible to achieve this using citeproc, but breaking the processCitations in an option which returns the processed citations separately and the 'full service' solution currently given would allow more flexibility in the inclusion of the processed references.

Thank you for considering!

@jgm
Copy link
Owner

jgm commented Mar 16, 2022

You mean the bibliography, I assume.

See the documentation: you can insert a div with id refs anywhere in your document (even in metadata), and the references will be placed there.

::: {#refs}
:::

@andrewufrank
Copy link
Author

andrewufrank commented Mar 16, 2022

I did not see this in the documentation (despite reading in it often - it is very useful!).
Just to make sure, I understand the solution: I can insert in the template anywhere a div with id refs and the bibliography will be inserted there? I have now in the template:

    <section>   $-- necessary for sidenotes to work
        $content3$  <!--content-from-panrep-blocks which is the content of the index.md -->
        <div id="refs">
            <h2>ReferencesTitle</h2>
            $-- here should be the refs 
        </div>

but I see the bibliography inserted at the end of the text and above the ReferencesTitle. Should I include the div in the original (markdown) text to be processed during processCitations?

I would prefer to deal with the placement when filling the template (among other things to be able to check for an empty bibliography and then avoid the title). Thank you for the help!

@jgm
Copy link
Owner

jgm commented Mar 16, 2022

No, not in the template. In the document itself.
Div is one of the constructors for a pandoc Block element.

@jgm
Copy link
Owner

jgm commented Mar 16, 2022

If you want to do it in the template, you can do that by making sure that the Pandoc document you pass to processCitations contains a metadata field, say refs, whose content is MetaBlocks [Div ("refs",[],[]) []].
processCitations will (I think!) insert the bibliography into this Div element. You can then use $refs$ in your template. (However, I'm not totally sure it will work if this div is in the metadata; I'd have to check the code. If it doesn't, we can probably modify processCitations so that it will work.)

@andrewufrank
Copy link
Author

I will try this and hope I understand the details... Thank you for the help!

@jgm
Copy link
Owner

jgm commented Mar 16, 2022

OK, looked at the code. Currently we only do insertRefs on the body of the document, so what I outlined above won't work. But I think we could change the code easily enough so that it would work.

@jgm jgm closed this as completed in 75ddff2 Mar 16, 2022
@jgm
Copy link
Owner

jgm commented Mar 16, 2022

OK, the code currently in HEAD will allow you to what I described.

@andrewufrank
Copy link
Author

thank you - i will try. sounded a bit complicated. will take a day or two. thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants