Editorial Workflows

Insert BibTex Citekey

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: A workflow for inserting Pandoc formatted citation from a BibTeX file.

Opens one or more BibTeX formatted bibliography files (uses *.bib by default) in the current directory, extracts and lists citekeys, and inserts one into the document. Uses the Pandoc citation format but doesn't insert brackets so adding multiple citations, locators, prefix, or suffix is left to the user.

Shared by: @mcburton

Comments: Comment Feed (RSS)

Mendel — 22 Feb 2015
Thank you so much for this, really an amazing idea.

My one quip with it which I'm actually wondering if you could fix somehow: is there a way to display the listed references by their title (author and name) as opposed to their cite key? But still insert only the cite key not the title..

I have a number of references by the same author and remembering which year the specific book I need was published is pretty tedious.

Also, I used this to creat a workflow which automatically inserts a footnote with the cite key. Here's the link http://www.editorial-workflows.com/workflow/rss/5782197969616896/IIRMId_xTWA
Mendel — 22 Feb 2015

+ Add Comment

Workflow Preview
Set Bibliography Filename ?
Variable Name
Bibliography Filename
Get Current Working Directory ?
Source Code
#coding: utf-8
import workflow
import editor
# Get the current file path
file_path = editor.get_path()
# remove filename to get path
current_dir = ''.join(file_path.rpartition('/')[0:2])
Get bibliography file list ?
Source Code
#coding: utf-8
import workflow
from glob import glob
import console

cwd_path = workflow.get_input()
bib_filename = workflow.get_variable("Bibliography Filename")
bib_path = ''.join([cwd_path, bib_filename]) 
bib_path = glob(bib_path) 

if not bib_path:
	console.hud_alert("No bibliography file(s) found.")

action_out = '\n'.join(bib_path)
Parse .bib files ?
Source Code
#coding: utf-8
import workflow
import editor
import fileinput
import console

bib_path = workflow.get_input().split('\n')

# use fileinput to iterate over each line of each file 
citekeys = "".join([line.split("{")[1].replace(",","") for line in fileinput.input(bib_path) if line.startswith("@")])

workflow.set_output(citekeys) #output newline string
Display Citekeys ?
Select Citekeys
List (Lines)
Multiple Selection
Show in Popover
Insert Citekeys ?
Replacement Text