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

org-ref support discussion #193

Open
kaushalmodi opened this Issue Aug 20, 2018 · 7 comments

Comments

Projects
None yet
2 participants
@kaushalmodi
Copy link
Owner

kaushalmodi commented Aug 20, 2018

Continuing the conversation about org-ref support from #191 (comment):

I wonder if we can get org-ref running through pandoc too as it seems to be supported (below a quote from the manual:

"The org-ref package is in wide use to handle citations and has excellent tooling support in Emacs. Its citation syntax is geared towards users in the natural sciences but still very flexible regardless."

@Cumol I looked at that doc. It's about Pandoc supporting org-ref syntax when using Pandoc to convert from Org file directly. We don't do that.

  • ox-hugo is what first converts from Org to Markdown.
  • Pandoc is then run with hopes of converting only the @ Pandoc citation references that Org kept as-is.

Org-ref should have done the org-ref link conversion correctly when the Org to Markdown conversion happened using ox-hugo. As long as org-ref supports ox-md, this should work fine.

So, to understand this better,

  1. Please post an example Org file with all the org-ref syntax you normally use.
  2. Markdown file that ox-hugo actually creates.
  3. Markdown file that should have been created.

(To help understand this problem, don't enable Pandoc Citations for this.)

@kaushalmodi

This comment has been minimized.

Copy link
Owner Author

kaushalmodi commented Sep 25, 2018

@Cumol Is this still an issue? In case you missed it, can you please reply back to the points after "So, to understand this better,"?

@kaushalmodi

This comment has been minimized.

Copy link
Owner Author

kaushalmodi commented Oct 2, 2018

@Cumol Closing this issue for lack of activity. Feel free to add more information in this thread when you have a chance, and I'll re-open this issue then.

@kaushalmodi kaushalmodi closed this Oct 2, 2018

@jethrokuan

This comment has been minimized.

Copy link
Contributor

jethrokuan commented Jan 6, 2019

fwiw, I wanted ox-hugo to support org-ref too. By default, org-ref supports markdown export, but does exports the links in pandoc-style format. To change it to a normal format, I overrode the export function so it does what I want it to do:

(require 'org-ref)

(defun org-ref-get-bibtex-entry-md (key)
  "Return a md string for the bibliography entry corresponding to KEY."
  ;; We create an anchor to the key that we can jump to, and provide a jump back
  ;; link with the md5 of the key.
  (let ((org-ref-formatted-citation-backend "md"))
    (format "<a id=\"%s\"></a>%s [↩](#%s)"
	    key
	    (org-ref-format-entry key)
	    (md5 key))))

(add-to-list 'org-ref-formatted-citation-formats
	     '("md"
	 ("article" . "${author}, *${title}*, ${journal}, *${volume}(${number})*, ${pages} (${year}). ${doi}")
	 ("inproceedings" . "${author}, *${title}*, In ${editor}, ${booktitle} (pp. ${pages}) (${year}). ${address}: ${publisher}.")
	 ("book" . "${author}, *${title}* (${year}), ${address}: ${publisher}.")
	 ("phdthesis" . "${author}, *${title}* (Doctoral dissertation) (${year}). ${school}, ${address}.")
	 ("inbook" . "${author}, *${title}*, In ${editor} (Eds.), ${booktitle} (pp. ${pages}) (${year}). ${address}: ${publisher}.")
	 ("incollection" . "${author}, *${title}*, In ${editor} (Eds.), ${booktitle} (pp. ${pages}) (${year}). ${address}: ${publisher}.")
	 ("proceedings" . "${editor} (Eds.), _${booktitle}_ (${year}). ${address}: ${publisher}.")
	 ("unpublished" . "${author}, *${title}* (${year}). Unpublished manuscript.")
	 (nil . "${author}, *${title}* (${year}).")))

Happy to explain more later if you have any queries. Would be great if this configuration could be package-local to ox-hugo.

@kaushalmodi

This comment has been minimized.

Copy link
Owner Author

kaushalmodi commented Jan 6, 2019

Would be great if this configuration could be package-local to ox-hugo.

I don't use org-ref so forgive me for the ignorance.

From what I see, the snippet you added doesn't deal with with ox-hugo or even with Org exporter system in general. It more seems to be a formatting choice for org-ref generated citation, and that choice could probably vary with person.

Instead of baking this into the package, it would be nice to add it to the ox-hugo-manual.org in the Enhancement section (which gets published to the ox-hugo doc site).

Do you have your copyright assigned to FSF?

@kaushalmodi kaushalmodi reopened this Jan 6, 2019

@jethrokuan

This comment has been minimized.

Copy link
Contributor

jethrokuan commented Jan 6, 2019

From what I see, the snippet you added doesn't deal with with ox-hugo or even with Org exporter system in general. It more seems to be a formatting choice for org-ref generated citation, and that choice could probably vary with person.

That's correct. However, that snippet overrides how org-ref exports to markdown completely, probably breaking org-ref elsewhere in parts I don't use. I was thinking that if ox-hugo is the one triggering the ox-md export, then it could perhaps use an advice to redefine the function temporarily.

Instead of baking this into the package, it would be nice to add it to the ox-hugo-manual.org in the Enhancement section (which gets published to the ox-hugo doc site).

This approach makes sense as well, but I think my snippet could probably be improved.

Do you have your copyright assigned to FSF?

No. Do you require it?

@kaushalmodi

This comment has been minimized.

Copy link
Owner Author

kaushalmodi commented Jan 6, 2019

No. Do you require it?

Yes. Some Day (TM), I plan to put this on GNU Elpa too.

I was thinking that if ox-hugo is the one triggering the ox-md export, then it could perhaps use an advice to redefine the function temporarily.

Yes, that's correct, because ox-hugo extends from ox-md. As I haven't used org-ref, I don't understand entirely what that snippet does. Does org-ref not work with ox-hugo/ox-md exports by default? If so, should this be fixed in org-ref?

Or is it just that the styling is different from your preference?

This approach makes sense as well, but I think my snippet could probably be improved.

If the combination of org-ref out-of-box and ox-hugo out-of-box is broken, then the fix needs to go in org-ref.el or ox-hugo.el. But I don't know where yet.

But you will need to drive this further (as you know org-ref better) and provide minimal working examples showing the problem and the fix.


Also, I do not know if this issue I opened related to org-ref/ox-md is already fixed: jkitchin/org-ref#558. The problem is that the org-ref user(s) so far didn't drive the resolving of this problem. At the time of posting that issue, org-ref + ox-md did not work because org-ref for that backend was not compatible with Org 9.0.

@jethrokuan

This comment has been minimized.

Copy link
Contributor

jethrokuan commented Jan 6, 2019

Yes. Some Day (TM), I plan to put this on GNU Elpa too.

I'll get them signed if you need it.

Yes, that's correct, because ox-hugo extends from ox-md. As I haven't used org-ref, I don't understand entirely what that snippet does. Does org-ref not work with ox-hugo/ox-md exports by default? If so, should this be fixed in org-ref?

Here's a small example to illustrate the problem.

org-file contains (excluding hugo headers)

bibliography:ml.bib

bib file contains:

@misc{dan_reprod,
  author =       {Dan Frank},
  howpublished = {https://stripe.com/blog/reproducible-research},
  note =         {Online; accessed 06 January 2019},
  title =        {Reproducible research: Stripe's approach to data
                  science},
  year =         {2016},
}

@misc{home_cookiec_data_scien,
  author =       {DrivenData},
  howpublished =
                  {https://drivendata.github.io/cookiecutter-data-science/},
  note =         {Online; accessed 06 January 2019},
  title =        {Home - Cookiecutter Data Science},
  year =         {2019},
}

Org-ref exports the links to markdown in a format more suitable for pandoc. Here's a snippet of the original export:

# Bibliography
<a id="home_cookiec_data_scien"></a>[home_cookiec_data_scien] @mischome_cookiec_data_scien,
  author =       DrivenData,
  howpublished =
                  https://drivendata.github.io/cookiecutter-data-science/,
  note =         Online; accessed 06 January 2019,
  title =        Home - Cookiecutter Data Science,
  year =         2019,
 [↩](#e0ca383893600291ac5eca0f379984fb)

<a id="dan_reprod"></a>[dan_reprod] @miscdan_reprod,
  author =       Dan Frank,
  howpublished = https://stripe.com/blog/reproducible-research,
  note =         Online; accessed 06 January 2019,
  title =        Reproducible research: Stripe's approach to data
                  science,
  year =         2016,
 [↩](#77ac83a13ddf56f053f1ba225873677d)

Since ox-hugo doesn't do pandoc link-processing, this doesn't turn out nice.

image

This text is determined by the function org-ref-get-bibtex-entry-md, which I overwrite to produce a nicer result:

# Bibliography
<a id="home_cookiec_data_scien"></a>DrivenData,  (2019). *Home - cookiecutter data science*. Retrieved from [https://drivendata.github.io/cookiecutter-data-science/](https://drivendata.github.io/cookiecutter-data-science/). Online; accessed 06 January 2019. [↩](#e0ca383893600291ac5eca0f379984fb)

<a id="dan_reprod"></a>Frank, D. (2016). *Reproducible research: stripe's approach to data science*. Retrieved from [https://stripe.com/blog/reproducible-research](https://stripe.com/blog/reproducible-research). Online; accessed 06 January 2019. [↩](#77ac83a13ddf56f053f1ba225873677d)

image

It's just a matter of producing the correct textual output for hugo, which doesn't further use pandoc for link processing.

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