Problems with exporting org-ref citations #561
-
Actual Behaviororg-ref syntax is not correctly exported to markdown. For example
is exported to
Expected BehaviorExporting an
How to Reproduce the IssueLoad org-ref
Create a file
Put the file in the same folder as the org-mode file. Also put the apa.csl file in there. Export to hugo. |
Beta Was this translation helpful? Give feedback.
Replies: 21 comments 1 reply
-
The pandoc citations are enabled, so the ox-hugo exported Markdown is made a second pass through Pandoc's Markdown exporter (essentially a md-to-md pandoc conversion happens). I don't use org-ref or pandoc frequently. So I have a few questions:
Thanks! |
Beta Was this translation helpful? Give feedback.
-
I just added this documention (it may or may not help in your case; it is using the inbuilt |
Beta Was this translation helpful? Give feedback.
-
Thank for your fast response! I have just looked into the issue and know why exporting out of the box does not work with org-ref. To answer your questions first: Yes, 1). citeproc-org is deprecated and should not be used anymore. This is how an example
At first glance, it looks like only the heading I think the first make-shift solution would be a function which automates 2). You could then put that function in the .dir-locals.el file. I don't know much elisp, so if you could write that function (which will probably only be a few lines lol), that would be great. If the references heading problem is fixed and you like, then, I would write a neat article on how to set everything up, with explanations, example files and all that. If you need any more info, just reach out to me :) |
Beta Was this translation helpful? Give feedback.
-
Right, that's why I just updated this page: https://ox-hugo.scripter.co/doc/org-ref-citations/
If you are using
As far as I know, you need to pick one of the three. May be @jkitchin can correct me here.
Correct. org-ref is a really popular package and I believe that manual work shouldn't be needed. Does org-ref based citations export correctly when using @jkitchin Can you please help out here? Is there something that needs to be added to |
Beta Was this translation helpful? Give feedback.
-
@Perangelot Can you please update the main post in this issue by removing references to With just the org-ref setup (and citeproc-org setup removed), how does your minimal Org file with org-ref citations export to Markdown? And what would you expect it to export to instead? |
Beta Was this translation helpful? Give feedback.
-
@kaushalmodi Thanks for the clarifications! I have updated my question; hope it is more clear now. I have by the way found out that the solution I propose seems to have one minor problem: All citations are put in parentheses, even years. For example, |
Beta Was this translation helpful? Give feedback.
-
I believe the solution here is to use one of the pre-processing hooks in org-ref with a csl file for styling. The cite links really only export to LaTeX, and org-ref doesn't really have a "markdown" export like it used to have. Instead, there is a pre-processing function (
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick response, @jkitchin! Using the code you've send comes near to the desired result, but not quite. I've run this code:
I see three problems here:
|
Beta Was this translation helpful? Give feedback.
-
On 1. citeproc doesn't support a markdown output. There is plain (which is used in org-ref) or org format (which is what happens when you use The problem is you need a mixed backend export to achieve what you want. You can get this in the following way probably:
On 2, I guess that parenthetical is the default style with apa, and to get a cite without parens you can use a citet link. The parentheses are only suppressed on citet, citet*, citenum at the moment. I pushed citetitle as a non-parenthetical type. I am less sure it is the right thing to make cite non-parenthetical as a default. On 3, if the CSL does not provide the name of the reference section, you should just manually add a References heading in your org file where the bibliography link is. |
Beta Was this translation helpful? Give feedback.
-
Regarding exporting to Markdown Hugo allows HTML embedded in Markdown. When I export For example,
See Nim Manual <a href="#citeproc_bib_item_2">2022</a> _Generics_.
..
<a href="#citeproc_bib_item_1">2018, sec. 8.25</a>
<style>.csl-entry{text-indent: -1.5em; margin-left: 1.5em;}</style><div class="csl-bib-body">
<div class="csl-entry"><a id="citeproc_bib_item_1"></a>“IEEE Standard for Systemverilog–Unified Hardware Design, Specification, and Verification Language.” 2018. <i>IEEE Std 1800-2017 (Revision of IEEE Std 1800-2012)</i>, 1–1315. <a href="https://doi.org/10.1109/IEEESTD.2018.8299595">https://doi.org/10.1109/IEEESTD.2018.8299595</a>.</div>
<div class="csl-entry"><a id="citeproc_bib_item_2"></a>Nim contributors. 2022. “Nim Manual.” Website. <i>Nim</i>. <a href="https://nim-lang.org/docs/manual.html">https://nim-lang.org/docs/manual.html</a>.</div>
</div> Regarding the parentheses Reading https://blog.tecosaur.com/tmio/2021-07-31-citations.html#cite-styles, I don't know if it's So this:
exports to:
|
Beta Was this translation helpful? Give feedback.
-
@jkitchin I see that citations.el wraps the bibliography section in <div class="csl-bib-body">
..
</div> Would org-ref also do that, or something similar? If we can document a way to have org-ref export citations and bibliography export in HTML with div blocks with specific classes like above, I can have ox-hugo inject "References" or "Bibliography" (will make it a defcustom) heading just above those div blocks. |
Beta Was this translation helpful? Give feedback.
-
@Perangelot @jkitchin I have moved the "References" heading auto-injection discussion to #558 |
Beta Was this translation helpful? Give feedback.
-
citeproc supports html output, and if you use an html backend you get different behavior than markdown. The html would support links/markup. the plain output doesn't, and the org output does. It looks like oc-csl treats a bare citation as one that should suppress the affixes (parentheses). I have made a defcustom where you can add cite to it if you want. The default in If you use an html backend for pre-processing, you would get that wrapping. org-ref only uses what citeproc outputs, it does not auto-inject anything. I think if you do this, you will get that.
|
Beta Was this translation helpful? Give feedback.
-
@Perangelot I just tried this out and it works! Add this to the bottom of your Org file, save it and export using
Make sure you update |
Beta Was this translation helpful? Give feedback.
-
I've just tried it out and everything is working smoothly! Thanks for all the effort you put in, @kaushalmodi @jkitchin! I really appreciate it. I would have loved to help you with the org-file but just came to read the posts. Instead of cluttering the org-file with more content than needed, I have decided to set the hook in the
I have also adjusted the list of non-parenthetical citations, which now works perfectly for the popular apa 7th style:
One feature request I have, @kaushalmodi, is to define a variable which allows toggling automatic bibliography insertion on and off. The advantage of this is that if you use one single |
Beta Was this translation helpful? Give feedback.
-
Note that while you add that, you are modifying that hook for any future Org export using any other backend as well; not just ox-hugo. A better approach would be to selectively update that hook by using the backend arg of that lambda instead of discarding it using Or, you may do an .. Or set that hook in a .dir-locals in your Hugo site directory :)
The bibliography insertion is not done by Check if org-ref has such a global variable. If not, you may open an issue on the org-ref repo requesting this. Suggestion: (use-package org-ref
:ensure t
:init
(with-eval-after-load 'ox
(add-to-list 'org-export-before-parsing-hook
(lambda (backend)
;; ox-hugo <- ox-blackfriday <- ox-md <- ox-html
(when (org-export-derived-backend-p backend 'html)
(org-ref-process-buffer 'html)))))) |
Beta Was this translation helpful? Give feedback.
-
@Perangelot I've converted this to a discussion as this didn't need fixes in ox-hugo and also so that it gets more visibility for future org-ref users who might have same question as yours. |
Beta Was this translation helpful? Give feedback.
-
@Perangelot The ox-hugo doc page for org-ref is updated at https://ox-hugo.scripter.co/doc/org-ref-citations/ . |
Beta Was this translation helpful? Give feedback.
-
I am glad to see this is working out! |
Beta Was this translation helpful? Give feedback.
-
Not sure who the question was for, but ox-hugo doesn't control that. @jkitchin? |
Beta Was this translation helpful? Give feedback.
-
I don't think you can support all the cite links with csl. They are based on LaTeX/bib(la)tex citation types and are only fully supported in that environment. I am not sure, but I don't think that csl supports something like citetitle, although it does support something like citeyear and citeauthor. To get that, I think there would have to be a new mode defined for https://github.com/andras-simonyi/citeproc-el#citeproc-citation-create-key-cites-note-index-mode-suppress-affixes-capitalize-first-ignore-et-al- that was |
Beta Was this translation helpful? Give feedback.
@Perangelot The ox-hugo doc page for org-ref is updated at https://ox-hugo.scripter.co/doc/org-ref-citations/ .