Skip to content

A short script using org-babel and ruby to append a plaintext bibliography using the specified csl style.

Notifications You must be signed in to change notification settings

scokobro/org-plaintext-rubybib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

org-plaintext-rubybib

This is a short org-babel/ruby script (actually a code-block) that scans through an org-mode file for citations and uses citeproc-ruby to append a plaintext bibliography using the specified csl style.

What else you need

For more info on code blocks in org look here!

Also...

  • a Bibtex bibliography database of your own

Excuses

As anyone who might chance on this can probably tell, I'm not a programmer and I don't really know what I'm doing ;) I am thus not really aware of whether this is 'the right solution' to this problem or not.

My primary aim was to be able to preview the cited items in any paper I am writing in org-mode. I wasn't really expecting to be able to create a perfectly formatted and publishable bibliography, ulitmately I would leave that to the standard, more sophisticated tools (LaTeX/Bibtex/biber/biblatex etc)

Use

Copy and paste the code block (from #+NAME: create-bibliography to #+RESULTS: create-bibliography into your org-mode buffer.

Make sure you replace the dummy path-name in the following line ...

cp.import BibTeX.open('/path/to/your/bibliography.bib').to_citeproc

... with the path to your bibliography file.

Then place the cursor somewhere in the code-block and hit C-c C-c. Unless you've already change your settings otherwise you will be asked to give permission for the code-block to run, if you're happy that it's not doing anything naughty (it certainly shouldn't be!) then hit 'y' and within a second or two a new drawer names RESULTS should appear after the #+RESULTS: create-bibliography line, and it should be filled with your reference list.

Finding citations

The script is set up to bibtex keys in the text of the file that contains it; my bibtex keys all follows the same basic pattern: |SOME LETTERS(maybe a 'dash' somewhere in there too)|A COLON|FOUR NUMBERS|MAYBE AN EXTRA LETTER|, and the regex in the line...

res = content.scan(/[a-zA-Z\-]*:[0-9]{4}[a|b|c]?/)#collect regex matches

... is set up to match this. You may have a different schema for your bibtex keys, in which case you'll have to change the regex to match.

About

A short script using org-babel and ruby to append a plaintext bibliography using the specified csl style.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published