andras-simonyi / citeproc-org

Renders Org-mode citations in CSL styles using citeproc-el.
GNU General Public License v3.0
69 stars 2 forks source link

citeproc-org won't find org-ref bibliography file when using hugo/ox-hugo with a main file and trying to export subtrees to markdown: `citeproc-org--get-link-bib-info: No bibliography file was specified` #10

Closed lailamor closed 4 years ago

lailamor commented 4 years ago

Description

When using hugo/ox-hugo, subtrees of single main org file that have org-ref citation(s) won't be exported to markdown files. Directory blog/content/subtree is created, but file won't be exported because citeproc-org won't find bibliography file.

Replication

  1. Create hugo blog.

    hugo new site blog
  2. Install theme.

    git init \
        && git submodule add --depth 1 \
               https://github.com/reuixiy/hugo-theme-meme.git themes/meme \
        && rm config.toml \
        && cp themes/meme/config-examples/en/config.toml config.toml
  3. Create main org file blog/blog.org. Add below to blog.org

    blog.org ``` #+AUTHOR: Me #+STARTUP: content #+HUGO_BASE_DIR: . #+HUGO_AUTO_SET_LASTMOD: t * Posts :post: :PROPERTIES: :EXPORT_HUGO_SECTION: posts :END: ** Issue :@issue: *** DONE citeproc-org Won't Export org-ref in Single Main Org File :citeproc:org: CLOSED: [2020-09-14 Mon 02:08] :PROPERTIES: :EXPORT_DATE: 2020-09-14 :EXPORT_FILE_NAME: citeproc-wont-reference-single-main-org-file :END: Lorem ipsum dolor sit amet, consectetuer adipiscing elit.cite:dominik-2010-tom7rm Donec hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam nisl,[[cite:dominik-2010-tom7rm]] tincidunt et, mattis eget, convallis cite:dominik-2010-tom7rm nec, purus. Cum sociis natoque penatibus et magnis dis [[cite:dominik-2010-tom7rm]] parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam vestibulum accumsan nisl. * References <> bibliography:static/references.bib ```
  4. Create bibtex file in blog/static/references.bib. Add below do references.bib.

    references.bib ``` @comment{x-kbibtex-encoding=utf-8} @book{dominik-2010-tom7rm, author = "Dominik, Carsten", date = "2010-12", month = "12", pagetotal = "282", publisher = "Network Theory Ltd", subtitle = "Organize Your Life With GNU Emacs", title = "{The Org Mode 7 Reference Manual}", url = "https://web.archive.org/web/20160426062148/http://www.network-theory.co.uk/org/manual", year = "2010" } ```
  5. Open blog.org and run export to hugo markdown compatible file (e.g. C-c C-e H A). See Emacs messages buffer.

  6. Run server hugo sever -D.

  7. Open server address: no posts.

Expected behavior (solution)

Find bibliography file in main org file, so that it's possible to export org subtrees to markdown files that have org-ref citations.

Error stack

Other comments

This issue won't happen when using hugo/ox-hugo with separate/dedicated org files.

andras-simonyi commented 4 years ago

Hi, thanks for the detailed report! I intend to investigate this in depth and find the optimal solution, but perhaps it's useful to record here a possible quick workaround: you can also specify the bibliography to be used by setting the variable org-ref-default-bibliography along the lines of

(setq org-ref-default-bibliography '("/path/to/references.bib"))

I think this should work for single org-file ox-hugo setups as well.

lailamor commented 4 years ago

specify the bibliography to be used by setting the variable org-ref-default-bibliography

Setting the variable works indeed. Thank you!

Seems like another issue: setting a CSL style (in this case the unique ISO-690 (numeric, English)) with #+CSL_STYLE: /path/to/csl_style_file won't work.

andras-simonyi commented 4 years ago

Well, in a similar manner you can try to set the variable citeproc-org-default-style-file to the path of the desired CSL style as a workaround, but I'll try to address this issue in a more general way shortly.

andras-simonyi commented 4 years ago

I've committed now a small change (8b93118), which should fix this issue -- hopefully it will appear as an update in MELPA soon.

lailamor commented 4 years ago

I've updated to the commit

citeproc-el                0.1.2-2-g0ad1f97           0   0 ~/.emacs.d/straight/repos/citeproc-el/
citeproc-org               0.2.4-24-g8b93118          0   0 ~/.emacs.d/straight/repos/citeproc-org/

but the issue persists. Although now i only get this in the Messages buffer

[ox-hugo] 1/ Exporting ‘citeproc-org Won't Export org-ref in Single Main Org File’ ..
if: No bibliography file was specified

If it's of relevance, I'm using Emacs 28 (commit 9d011397).

andras-simonyi commented 4 years ago

Thanks, I've made another small update (22a759c) could you check again?

lailamor commented 4 years ago

Perfect! Now it's finding the bibliography file as well setting the csl file with #+csl_style. Thanks!


Not sure if it's a citeproc-org issue or ox-hugo, but now, with org-ref references being used, headings are being exported as unordered lists to markdown, and being rendered as such on html.

blog.org ``` #+author: Me #+startup: content #+hugo_base_dir: . #+hugo_auto_set_lastmod: t * Posts :post: :PROPERTIES: :EXPORT_HUGO_SECTION: posts :END: ** Issue :@issue: *** DONE citeproc-org Won't Export org-ref in Single Main Org File :citeproc:org: CLOSED: [2020-09-14 Mon 02:08] :PROPERTIES: :EXPORT_DATE: 2020-09-14 :EXPORT_FILE_NAME: citeproc-wont-reference-single-main-org-file :END: **** Here should be a heading Lorem cite:dominik-2010-tom7rm,dominik-2010-tom7rm ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam vestibulum accumsan nisl. **** This here should be a heading as well You see, the above should be a heading, but it's being exported as unordered list in markdown when there's org-ref citations. ***** This should be a subheading A the above should be a subheading. * References <> bibliography:static/references.bib ```
blog/content/posts/citeproc-wont-reference-single-main-org-file.md ``` +++ title = "citeproc-org Won't Export org-ref in Single Main Org File" author = ["Me"] date = 2020-09-14T02:08:00-03:00 lastmod = 2020-09-15T18:00:02-03:00 tags = ["post", "citeproc", "org"] categories = ["issue"] draft = false +++ - Here should be a heading Lorem ([Dominik 2010](#org3e83bb9), [2010](#org3e83bb9)) ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam vestibulum accumsan nisl. - This here should be a heading as well You see, the above should be a heading, but it's being exported as unordered list in markdown when there's org-ref citations. - This should be a subheading A the above should be a subheading. ## Bibliography {#bibliography} Dominik, Carsten. 2010. _The Org Mode 7 Reference Manual: Organize Your Life with GNU Emacs_. Network Theory Ltd. . ```

issue

andras-simonyi commented 4 years ago

Thanks for the feedback! As for the probIem with headlines, this is probably caused by the default value of the customizable variable citeproc-org-org-bib-header, which is "* Bibliography\n", i.e., a first-level heading. Setting it to "**** Bibliography\n" seems to solve the problem.

lailamor commented 4 years ago

citeproc-org-org-bib-header "**** Bibliography\n"

This solves the problem indeed. It works for making the correct headings both when using org-ref references and when not using them, at least when exporting to markdown with ox-hugo. Thanks again!

dschaehi commented 3 years ago

As a follow-up question: would it be possible to remove the heading number in front of the Bibliography heading when heading numbers are used? I have the following options in the org file: #+OPTIONS: h:3 toc:nil num:2 tags:nil todo:nil ':t ^:{} tasks:nil stat:nil I tried to add the unnumbered property (cf. https://orgmode.org/manual/Export-Settings.html) by adding (setq citeproc-org-org-bib-header "*** References\n:PROPERTIES:\n:UNNUMBERED: t\n:END:") before calling (citeproc-org-setup) but was not successful. Removing the number from an arbitrary heading however works with ox-hugo:

* test
:PROPERTIES:
:UNNUMBERED: t
:END:

Thank you by the way for the useful package!

andras-simonyi commented 3 years ago

Hello, thanks for the question and sorry for reacting only now. I tried to reproduce the problem but could not -- in theory, there should not be any difference between a manually inserted heading and the same heading inserted by citeproc-org on the basis of the citeproc-org-org-bib-header variable's content. In fact, I didn't see any difference with the backends I tried. Could you perhaps describe in detail what you experienced precisely when you were "not successful"? BTW, this might be just an insignificant typo, but your line

(setq citeproc-org-org-bib-header "*** References\n:PROPERTIES:\n:UNNUMBERED: t\n:END:")

is not entirely correct because an ending "\n" is missing from the string after "END:".

dschaehi commented 3 years ago

Oh you are right. It was the missing "\n" that caused the problem. Thanks for the hint!