gitit icon indicating copy to clipboard operation
gitit copied to clipboard

Feature: BibTeX support

Open jgm opened this issue 14 years ago • 20 comments

I suggest that some pages, or delimited parts of pages, could be written in
BibTeX. Gitit could then run BibTeX over the references in order to convert
them to HTML.

This would have a couple of benefits:

* A wide variety of bibliography management software (Zotero, CiteULike,
etc.) can export to BibTeX.

* The display style of academic references could be customised and made
uniform (per reference type) across the wiki, using existing BibTeX styles
and BibTeX style generation software.

Google Code Info:
Issue #: 23
Author: [email protected]
Created On: 2009-02-05T10:02:01.000Z
Closed On: 

jgm avatar Jul 09 '11 04:07 jgm

The best way to do this would be to use the experimental pandoc support for Andrea Rossato's hs-citeproc. This would allow citations to be written in a markdownish format and exported not just to HTML but to all of pandoc's output formats. hs-citeproc also has bindings to bibutils, which allows it to read bibliographies in many different formats. For details, see http://code.haskell.org/citeproc-hs/.

Google Code Info: Author: [email protected] Created On: 2009-02-05T19:14:39.000Z

jgm avatar Jul 09 '11 04:07 jgm

So, John, what would adding support for hs-citeproc mean from the standpoint of gitit? I presume you'd need to make a few tweaks to enable this?

Google Code Info: Author: [email protected] Created On: 2009-02-12T03:09:36.000Z

jgm avatar Jul 09 '11 04:07 jgm

The main bit of work is figuring out how to specify a bibliography file. If the file is xml or bibtex, it could just live in the repository as an uploaded file (though this would make it visible in the wiki - perhaps that's not always desirable). But there would still need to be some convention for specifying which bibliography to use for a given page. Ideas welcome.

Google Code Info: Author: [email protected] Created On: 2009-02-12T03:23:36.000Z

jgm avatar Jul 09 '11 04:07 jgm

I guess the best balance of ease of implementation and use and generality is to have a single global bibliography file, which could optionally be marked private? I could imagine some useful UI stuff could later be built on top of that using Javascript.

BTW, might be nice if Andrea can at some point add optional RDFa support, so that the HTML content can be tagged for easy extraction.

Google Code Info: Author: [email protected] Created On: 2009-02-12T16:49:11.000Z

jgm avatar Jul 09 '11 04:07 jgm

pandoc accepts a 'bibliography' parameter, which can be a bibtex file or one of many other bibliography-related files. It is not possible to just use this feature from pandoc?

One could have this file stored as a wiki page, or as a standalone file. Such file could be be added to gitit's configuration options.

Please let me know if this is likely to work. If so, I might try implementing it.

Thanks

rafalotufo avatar Mar 12 '12 18:03 rafalotufo

+++ rafalotufo [Mar 12 12 11:35 ]:

pandoc accepts a 'bibliography' parameter, which can be a bibtex file or one of many other bibliography-related files. It is not possible to just use this feature from pandoc?

It should be possible in principle. See src/pandoc.hs and look it how it calls processBiblio from Text.Pandoc.Biblio.

I'd suggest letting the bibliography file be listed in the page's metadata, so that different pages can use different bibliographies.

One could have this file stored as a wiki page, or as a standalone file. Such file could be be added to gitit's configuration options.

Please let me know if this is likely to work. If so, I might try implementing it.

Thanks


Reply to this email directly or view it on GitHub: https://github.com/jgm/gitit/issues/166#issuecomment-4458561

jgm avatar Mar 12 '12 19:03 jgm

It would be realy great to have this feature. I'd prefer setting a path to bibtex file in the page's metadata.

Alternatively, an integration with refbase would be the best.

tolot27 avatar Aug 10 '12 21:08 tolot27

Have there been any updates on this? I know this is quite old but I am wondering the exact same thing. I only have one bibtex bibliography and am only using the wiki personally so for me it doesn't matter which approach works but I am having trouble finding if one of them does.

I have tried adding:

---
bibliography: test.bib
...

but @citation1 still shows as plain text. \cite{citation1} disappears but doesn't show anything. The bibliography file itself works in pandoc.

I am not sure how to set gitit up to use a bibliiography file in the config (or if this exists). Unfortunately I am not very familiar with Haskell itself. If the config file reads the same parameters that pandoc does, then I should be able to just set bibliiography: test.bib in the config file?

I have found a discussion and plugin that has some documentation but I don't want to store my bibtex inline with my document and the plugin doesn't actually replace the citations @xxx or \cite{xxx} with anything. I have multiple pages that will use the same citations, I would like to "write once read everywhere," because when I make a mistake I will have to change it everywhere.

blueblob avatar May 29 '14 17:05 blueblob

+++ blueblob [May 29 14 10:22 ]:

I am not sure how to set gitit up to use a bibliiography file in the config (or if this exists). Unfortunately I am not very familiar with Haskell itself. If the config file reads the same parameters that pandoc does, then I should be able to just set bibliiography: test.bib in the config file?

It's not that simple, for two reasons. (1) gitit predates pandoc's YAML metadata and uses its own, slightly different system. (2) the code to produce the wiki page doesn't run the pandoc-citeproc filter, which would be needed to resolve references.

jgm avatar May 29 '14 17:05 jgm

I was excited when I read this pandoc related article recently for it's ability to use BibTeX. But as I understand from this issue, sadly gitit can't do it yet. I wish I knew Haskell, so I could be helpful. Hopefully this will be implemented soon?

memming avatar Sep 09 '14 20:09 memming

I just made a plugin that implements it. It reads citations from bib blocks as used by Caleb McDaniel, or from a file specified in the metadata like above, or from a default specified in default.conf. There's also a default.conf field for the style file, and it uses APA if nothing is given.

It's working for me, but before I do a pull request it might need a few touch-ups. I put the config files in pandoc-user-data/yourbibname.bib and pandoc-user-data/styles/yourstyle, which is fine except maybe the bib file should be version controlled? And I'm not sure what to do about a plugin that requires changes to the core gitit code. It's currently compiled in as Network/Gitit/Plugin/CiteProcBlock.hs since that's how I install all my plugins. I also haven't tested it any further than adding some bibtex by each method and checking that citations work, and I haven't checked on the legality of including zotero styles.

Here's a diff of the changes relative to my master branch.

EDIT: master has moved on; switching to permalink

jefdaj avatar May 07 '15 07:05 jefdaj

I'd love to use that plugin but can't get it to work... it seems to require the config file variables, but I'm not sure how to include them.

plugins/CiteProcBlock.hs:50:8: Not in scope: ‘defaultCitationStyle’

plugins/CiteProcBlock.hs:68:27: Not in scope: ‘defaultBibliography’ Perhaps you meant one of these: ‘separateBibliography’ (line 35), ‘readBibliography’ (line 62)

brp4h avatar Nov 20 '15 01:11 brp4h

It's not quite ready for installation as a plugin because it required some (minor) changes to the rest of the gitit code to support new config file options. Those not-in-scope functions are things I added to Network.Gitit.Interface. You can see them in the diff I linked to above, but I'm not sure if applying that would still work because it's been a few months and gitit may have changed. I suppose the easiest thing would be if I go ahead and finish it and do a pull request! In the meantime I'll also make a version that hard-codes the filenames in the plugin code and post that here.

jefdaj avatar Nov 20 '15 19:11 jefdaj

That would be awesome! I tried to fix it myself but couldn't figure it out.

On Fri, Nov 20, 2015 at 1:18 PM Jeff Johnson [email protected] wrote:

It's not quite ready for installation as a plugin because it required some (minor) changes to the rest of the gitit code to support new config file options. Those not-in-scope functions are things I added to Network.Gitit.Interface. You can see them in the diff I linked to above, but I'm not sure if applying that would still work because it's been a few months and gitit may have changed. I suppose the easiest thing would be if I go ahead and finish it and do a pull request! In the meantime I'll also make a version that hard-codes the filenames in the plugin code and post that here.

— Reply to this email directly or view it on GitHub https://github.com/jgm/gitit/issues/166#issuecomment-158499293.

brp4h avatar Nov 20 '15 21:11 brp4h

OK, made the hardcoded version. Does this work for you? Just replace defaultBibliography with a BibTex file and defaultStyleFile with a style file (APA is here).

jefdaj avatar Nov 22 '15 21:11 jefdaj

THANK YOU!! I really appreciate that. I can't quite figure it out though... At first I got this error:

Loading plugin 'plugins/CiteProc.hs'... gitit: Failed to load interface for ‘CiteProc’

I found your post here and based on that, changed to first line of CiteProc.hs to read

Module CiteProc

instead of

module Network.Gitit.Plugin.CiteProc

After that the plugin loaded, but when I try to access a page that would use it, I get

Happstack 7.4.5 Something went wrong here Internal server error Everything has stopped The error was "chapter1.bib: openFile: does not exist (No such file or directory)"

chapter1.bib does exist and I put the full path to it in the CiteProc.hs file, so I'm not sure what to do.

brp4h avatar Nov 22 '15 23:11 brp4h

Oh right, sorry about the module name! It should be module CiteProc (lowercase m), but you probably have that right already if it loaded. Not sure as far as the openFile error. The only thing I can think of is, are you sure you have the full path? Because on my system when I try to readFile something nonexistent the error includes the full path, like:

*** Exception: /home/jefdaj/nope: openFile: does not exist (No such file or directory)

Or alternatively, maybe you have the relative path in the metadata block already? If you put:

~~~
bibliography: chapter1.bib
...

In the page that would override the default, even if it doesn't exist. If not I'll have to think some more on it. What happens if you embed the citation in a bib block?

jefdaj avatar Nov 23 '15 03:11 jefdaj

Well, thank you again! You were right, I had a relative path in the metadata block. After taking that out and embedding my citations in the .page file, it works!

I still wasn't able to use a .bib file, even with the correct file path — I get this error message when trying to access a page that would use the plugin:

HTTP request failed with: "stdin" (line 24, column 2): unexpected "b" expecting "c", "C", "p", "P", "s" or "S"

I tried messing with it but obviously I have no idea what I'm doing and got nowhere. I don't need to use a .bib file anyway; I think Caleb McDaniel's method is probably better long term anyway, so I'm going to go with that. Thanks for being patient! I really appreciate all of your help.

brp4h avatar Nov 24 '15 03:11 brp4h

No problem, glad it (sort of) works! This stuff is all much more confusing than it should be. Not sure what that error means... an issue parsing the BibTex I guess? I've been generating mine by exporting from Zotero so don't have much experience with the format. I should make sure that errors like that don't crash the whole page though! Maybe instead I can insert the error in the page where the bibliography would be.

jefdaj avatar Nov 24 '15 20:11 jefdaj

@jefdaj Hi, I download one branch of your fork of gitit and install it with stack. And in the configuration file of gitit, I add plugins: Network.Gitit.Plugin.CiteProc. But the following error is generated when I start gitit:

Could not read mime types file: /etc/mime.types
/etc/mime.types: openFile: does not exist (No such file or directory)
Using defaults instead.
Loading plugin 'Network.Gitit.Plugin.CiteProc'...
gitit: Failed to load interface for ‘Network.Gitit.Plugin.CiteProc’
Use -v to see a list of the files searched for.
Failed to load interface for ‘Network.Gitit.Interface’
Use -v to see a list of the files searched for.

Could you help me to figure out what's wrong? What other information should I provide?

Quantizen avatar Nov 16 '17 14:11 Quantizen