Google Docs integration

1,872 views
Skip to first unread message

Aurimas Vinckevicius

unread,
Mar 13, 2014, 10:02:34 PM3/13/14
to zoter...@googlegroups.com

Hello everyone,

I just want to get a technical conversation going about Zotero integration with Google Docs.

Google recently introduced add-ons for Google Documents, among which is an EasyBib add-on that essentially inserts a pre-formatted bibliography into Google Docs documents. This resulted in a few people on Twitter and in the forums requesting that a similar feature for Zotero be added to Google Docs. As adamsmith explained in this post, you can essentially do the same thing using drag-and-drop from Zotero. While that's true, it would be quite nice to eventually add proper Zotero integration into Google Docs, which should be equivalent to Word/LO addons (i.e. live citations).

I started looking around at the Google Docs add-on API and I think it may be possible. The general idea is to display a pre-formatted in-text citation and associate a Zotero ID with it in a user-invisible fashion (same as is done in Word/LO with fields and bookmarks). If we end up displaying the id to the user, then it's essentially the same as ODF scan. Unfortunately, in Google Docs field codes do not exist. Bookmarks exist, but are associated with a single position in text, not a range of text. I suppose you could use two bookmarks to indicate start and end of a citation, but it becomes easy for the user to delete only one of the bookmarks and mess up this syntax. Also this system would complicate other operations (editing, deleting references, etc.)

Another possibility that is available is inserting pre-formatted citations as links and storing the reference ID as the URL (bonus points: it redirects to the reference on zotero.org). The add-on would then offer an option to strip links (same as removing field codes). Interacting with links is not very convenient, since they would be set on a segment of text without any easy way of retrieving them directly. However, if you wanted to find all citations/links in the document, you could essentially go through the document character by character and check if there is a link set there. Sounds pretty bad, but that's the best I can think of atm. If the user is trying to edit a citation, then we could check only the area surrounding the cursor for links. Scanning of the whole document would only be necessary when inserting a bibliography/updating in-text citations (this should only be done with explicit user commands, not after each addition) and stripping links, Another downside to the link approach is transferring documents from Google Docs to Word/LO. Something similar to RTF/ODF scan could be developed to convert Zotero links to live citations. Clearly this is a low priority concern.

So assuming that the above would work out for managing citations within a document, one would also need to be able to format citations/bibliography correctly. I think the most reasonable approach here would be for zotero.org to provide this through the API. The API would accept a set of references (in the order that they appear in text) as either IDs or JSON data (IDs would be easier for API users, but accepting raw JSON would be more versatile and probably somewhat easier to code on the server side) and return a set of formatted in-text references (in the same order as supplied) and the formatted bibliography. I imagine something like [ ["ref1"], ["ref2", "ref3"], ["ref1", "ref2", "ref3"] ] as the request and [ "1", "2,3", "1-3" ] as the response (plus bibliography) given a numeric style.

These are the first two core issues that I was thinking of, so I thought I'd ask for some input. Of course, the API might just not yet be suitable for Zotero integration with live citations.

Obviously this would be a good amount of work to get done and I don't expect Dan or Simon to take this up. It would be great, however, to get some input on whether Zotero would be on board with this, since it would require some additions to the API (which could, potentially, also be contributed by a third party).

Anyone have any other ideas on this topic?

Aurimas

Frank Bennett

unread,
Mar 13, 2014, 11:26:53 PM3/13/14
to zoter...@googlegroups.com
It does seem pretty thin, at this point at least. I'm not sure how you
would handle note styles ...

If someone were to undertake coding for GD integration at some point,
the approach adopted in Docear might be worth a look.

In citeproc-js there are two ways to go about context-sensitive
rendering. In Zotero (and I think in Mendeley), we track both item IDs
(individual references) and citation IDs (in-document reference
clusters), and limit document updates to the specific item or citation
where there has been a change. Both IDs are needed for targeted
updates to work.

Last I heard, Docear was using a simpler approach, recasting the
entire citeproc-js registry on each citation edit, insert or delete,
and feeding refreshed citation strings into the document on each
cycle. This might be a problem for large documents, but it is much
simpler to code -- all updates use the same rebuildProcessorState()
call on the processor, using data extracted from the document in a
uniform way. Even if you were aiming for a more efficient approach in
the end, this could be used to get a proof of concept in place a
minimum of effort.

>
> Obviously this would be a good amount of work to get done and I don't expect
> Dan or Simon to take this up. It would be great, however, to get some input
> on whether Zotero would be on board with this, since it would require some
> additions to the API (which could, potentially, also be contributed by a
> third party).
>
> Anyone have any other ideas on this topic?
>
> Aurimas
>
> --
> You received this message because you are subscribed to the Google Groups
> "zotero-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to zotero-dev+...@googlegroups.com.
> To post to this group, send email to zoter...@googlegroups.com.
> Visit this group at http://groups.google.com/group/zotero-dev.
> For more options, visit https://groups.google.com/d/optout.

Dan Stillman

unread,
Mar 13, 2014, 11:43:01 PM3/13/14
to zoter...@googlegroups.com
On 3/13/14, 10:02 PM, Aurimas Vinckevicius wrote:
[...]

So assuming that the above would work out for managing citations within a document, one would also need to be able to format citations/bibliography correctly. I think the most reasonable approach here would be for zotero.org to provide this through the API. The API would accept a set of references (in the order that they appear in text) as either IDs or JSON data (IDs would be easier for API users, but accepting raw JSON would be more versatile and probably somewhat easier to code on the server side) and return a set of formatted in-text references (in the same order as supplied) and the formatted bibliography. I imagine something like [ ["ref1"], ["ref2", "ref3"], ["ref1", "ref2", "ref3"] ] as the request and [ "1", "2,3", "1-3" ] as the response (plus bibliography) given a numeric style.


We can make the necessary API changes to support this. We've discussed it a bit, and it seems like it'll require a new format=cite request that takes item keys (and some other citation parameters) as JSON and returns JSON containing citations and a bibliography. citeproc-node/citeproc-js already do most of the heavy lifting here, so it's mostly glue on the API side.

Like Frank, I'm a bit concerned about large documents, but I don't really see how we could do targeted updating without storing state on the server. The processing for this is relatively easy to scale, at least (though we might need to consider doing the processing asynchronously, with a token returned to the plugin for polling).

I'll let others who are better versed in the requirements here comment on the other specifics, but this would be awesome to have, particularly for collaboration.

- Dan

Erik Hetzner

unread,
Mar 14, 2014, 12:12:14 AM3/14/14
to zoter...@googlegroups.com
At Thu, 13 Mar 2014 23:43:01 -0400,
Dan Stillman wrote:
>
> On 3/13/14, 10:02 PM, Aurimas Vinckevicius wrote:
> > [...]
> >
> > So assuming that the above would work out for managing citations
> > within a document, one would also need to be able to format
> > citations/bibliography correctly. I think the most reasonable
> > approach here would be for zotero.org <http://zotero.org/> to
> > provide this through the API. The API would accept a set of
> > references (in the order that they appear in text) as either IDs or
> > JSON data (IDs would be easier for API users, but accepting raw JSON
> > would be more versatile and probably somewhat easier to code on the
> > server side) and return a set of formatted in-text references (in
> > the same order as supplied) and the formatted bibliography. I
> > imagine something like [ ["ref1"], ["ref2", "ref3"], ["ref1",
> > "ref2", "ref3"] ] as the request and [ "1", "2,3", "1-3" ] as the
> > response (plus bibliography) given a numeric style.
> >
>
> We can make the necessary API changes to support this. We've discussed
> it a bit, and it seems like it'll require a new format=cite request
> that takes item keys (and some other citation parameters) as JSON and
> returns JSON containing citations and a bibliography.
> citeproc-node/citeproc-js already do most of the heavy lifting here,
> so it's mostly glue on the API side.
>
> Like Frank, I'm a bit concerned about large documents, but I don't
> really see how we could do targeted updating without storing state on
> the server. The processing for this is relatively easy to scale, at
> least (though we might need to consider doing the processing
> asynchronously, with a token returned to the plugin for polling).
>
> I'll let others who are better versed in the requirements here comment
> on the other specifics, but this would be awesome to have,
> particularly for collaboration.

I don’t really have a lot to add here, but zotxt [1] supports
something like this. You POST JSON data, e.g.,

{
"styleId": "chicago-author-date",
"citationGroups" : [ {
"citationItems" : [ { "key" : "0_ZBZQ4KMP" } ],
"properties" : { "noteIndex" : 0 }
} ]
}

And you get back:

{
"bibliography": [
{
"maxoffset": 0,
"entryspacing": 0,
"linespacing": 1,
"second-field-align": false,
"entry_ids": [
[
"3004"
]
],
"bibliography_errors": [],
"done": false,
"hangingindent": 2,
"bibstart": "<div class=\"csl-bib-body\">\n",
"bibend": "</div>"
},
[
" <div class=\"csl-entry\">Doe, John. 2005. <i>First Book</i>. Cambridge: Cambridge University Press.</div>\n"
]
],
"citationClusters": [
"(Doe 2005)"
]
}

This works well for batch processing. I don’t know how it would work
a word-processor plugin to have to generate everything each time.

best, Erik

1. https://bitbucket.org/egh/zotxt

--
Sent from my free software system <http://fsf.org/>.

Aurimas Vinckevicius

unread,
Mar 14, 2014, 11:07:27 AM3/14/14
to zoter...@googlegroups.com
It's great to hear the positive feedback.


Yes, large documents may be an issue. I was thinking that (at least to start with), the citations do not need to be automatically refreshed after each addition (though that makes numeric styles a bit messy) and can be refreshed manually or after adding a bibliography. It's not just rendering citations that could be a problem, but also scanning the whole document one character at a time and calling `getLinkUrl`. I haven't investigated this too much, but we might be able to take advantage of NamedRange to wrap citations for quicker referencing (or even as an alternative to Bookmarks in Word/LO plugins).
There are a number of things to consider for the API (perhaps we should do this in a separate thread): prefix/suffix (handled server-side or client side?), page ranges, suppress author, near-note distance (I think there may be a way to support notes, but even if not in GDocs, the API should probably be feature-complete), etc., and of course the general format of the query and response.

I think the API would be valuable to have either way, but I will try to put together a mock add-on to see if what was discussed above will be at all possible.

Aurimas

Erik Hetzner

unread,
Mar 14, 2014, 1:32:11 PM3/14/14
to zoter...@googlegroups.com, Aurimas Vinckevicius
At Fri, 14 Mar 2014 10:07:27 -0500,
Aurimas Vinckevicius wrote:
>
> […]
>
> There are a number of things to consider for the API (perhaps we should do
> this in a separate thread): prefix/suffix (handled server-side or client
> side?), page ranges, suppress author, near-note distance (I think there may
> be a way to support notes, but even if not in GDocs, the API should
> probably be feature-complete), etc., and of course the general format of
> the query and response.

Hi Aurimas,

I forgot to mention that the API I mentioned above uses (basically)
the JSON structures expected by citeproc-js. See [1] for the code.
It’s a pretty thin wrapper. I don’t know, however, what the
performance/security implications might be of hosting this on the
internet.

best, Erik

1. https://bitbucket.org/egh/zotxt/src/6abaffff306c3e18d9125db968439e8757f89ecf/extension/bootstrap.js#cl-350

Aurimas Vinckevicius

unread,
Mar 14, 2014, 1:57:45 PM3/14/14
to Erik Hetzner, zoter...@googlegroups.com
Ah, I see. It does look like citeproc-js definition of the citation data object will work out for this. Indeed, there's no need to re-invent the wheel. This would make zotero.org API even easier to write.

I was slightly hoping that we could avoid having to re-fetch citations when only the prefix/suffix changes (by having the API return citations in three parts: opening string [e.g. "("], citation, closing string. The GDocs add-on would then insert user-supplied prefix and suffix inbetween and concatenate), but it seems that this would require changes to citeproc-js (I'm also not certain if that would be feasible).

Another thought: The API needs to expect items from different group/private libraries (or we can enforce restrictions to only use one library) and gracefully handle access errors. There should probably be a way to check if a given GDocs user has access to all of the libraries being used in a given document, so we can provide warning messages about access restrictions.

Dan Stillman

unread,
Mar 14, 2014, 2:02:24 PM3/14/14
to zoter...@googlegroups.com
On 3/14/14, 1:57 PM, Aurimas Vinckevicius wrote:
> Another thought: The API needs to expect items from different
> group/private libraries (or we can enforce restrictions to only use
> one library) and gracefully handle access errors. There should
> probably be a way to check if a given GDocs user has access to all of
> the libraries being used in a given document, so we can provide
> warning messages about access restrictions.

It'd be much simpler to restrict this to a single library. The issue, I
guess, is if you write a document yourself but then want to share it?

Aurimas Vinckevicius

unread,
Mar 14, 2014, 2:12:04 PM3/14/14
to zoter...@googlegroups.com
Yes, that was one of my concerns (though I think it would be neat to be able to handle arbitrary libraries since zotero.org has access to all of them).

The private/public library issue actually needs to be addressed in Word/LO add-ons as well: we see quite a few reports of users starting to write with private libraries and then having to collaborate with someone. We would probably face this issue even more on GDocs, since it's heavily focused on collaboration. My initial thought was that we could restrict all referencing to group libraries only, but that adds unnecessary overhead for people not intending to share the document. To be clear though, the above proposal is not going to solve this issue, since no single user would have access to multiple private libraries (unless we allow users to supply multiple private keys per document)


--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+unsubscribe@googlegroups.com.

Aurimas Vinckevicius

unread,
Mar 14, 2014, 2:13:02 PM3/14/14
to zoter...@googlegroups.com
Sorry, that was meant to be private/group library

Marnen Laibow-Koser

unread,
Mar 15, 2014, 12:41:46 PM3/15/14
to zoter...@googlegroups.com


On Thursday, March 13, 2014 10:02:34 PM UTC-4, Aurimas Vinckevicius wrote:

Hello everyone,

I just want to get a technical conversation going about Zotero integration with Google Docs.

Google recently introduced add-ons for Google Documents, among which is an EasyBib add-on that essentially inserts a pre-formatted bibliography into Google Docs documents. This resulted in a few people on Twitter and in the forums requesting that a similar feature for Zotero be added to Google Docs. As adamsmith explained in this post, you can essentially do the same thing using drag-and-drop from Zotero. While that's true, it would be quite nice to eventually add proper Zotero integration into Google Docs, which should be equivalent to Word/LO addons (i.e. live citations).

[...]

Just posting here to say hi and registering my interest in working on this.  I use Google Docs extensively for my academic papers, and I'd love to help get live citations working (I'm an experienced JavaScript developer, though I've never actually worked with Apps Script or the Zotero API).  Graduate school is limiting my development time at the moment, but I'm looking forward to trying to get something working perhaps over the summer, if no one beats me to it. :) 
 

Aurimas


Best,
-- 
Marnen Laibow-Koser
Graduate student, Contemporary Improvisation
New England Conservatory of Music

Robert V

unread,
Apr 26, 2014, 7:27:10 AM4/26/14
to zoter...@googlegroups.com
Hi,

I'm an experienced Software Engineer who is studying part time and I'm very thankful to the Zotero team as I used it extensively in my academic studies.
I'm happy to contribute to the Google Docs plugin as I have many years of experience with web technologies, both front and back end, however I think this software would be more front-end programming (JavaScript).

I suggest to make this as an open source project so we can set up a GitHub account so people can start to contribute.
The Zotero team should delegate some supervisors who will set up the GitHub repository and will decide which features to create.

I'm happy to make a start once the project is set up, and once I have something working I can send a pull request.

Marnen Laibow-Koser

unread,
Apr 26, 2014, 10:15:35 AM4/26/14
to zoter...@googlegroups.com


On Saturday, April 26, 2014, Robert V <sapp...@gmail.com> wrote:
Hi,

I'm an experienced Software Engineer who is studying part time and I'm very thankful to the Zotero team as I used it extensively in my academic studies.
I'm happy to contribute to the Google Docs plugin as I have many years of experience with web technologies, both front and back end, however I think this software would be more front-end programming (JavaScript).

Actually, it would be Google Apps Script, which is basically JavaScript, but in a somewhat different environment.  Have you looked at Apps Script at all?
 

I suggest to make this as an open source project so we can set up a GitHub account so people can start to contribute.

That would be nice...but have you ever used the Google Apps Script environment?  It's actually nearly impossible to use an external version control system, and the version control system within the Apps Script environment is *extremely* limited.  (No, I'm not happy about this.)


The Zotero team should delegate some supervisors who will set up the GitHub repository and will decide which features to create.

We needn't wait for the Zotero team.  It is feasible to do this completely without their support. 

 


I'm happy to make a start once the project is set up, and once I have something working I can send a pull request.

I set something up a couple weeks ago, but I'm still ironing out some environment issues (notably getting Jasmine working with Apps Script).  
 
 Best,


--
Marnen Laibow-Koser
mar...@marnen.org
http://www.marnen.org

Sent from Gmail Mobile

Bjoern Hassler

unread,
Apr 26, 2014, 11:54:51 AM4/26/14
to zoter...@googlegroups.com
Hi all,

very interested in this - would be great to hear how this is progressing!

On a related topic, see my recent post about translators producing html/rtf snippets, which would go some way towards further integration with google docs!

Bjoern

Robert V

unread,
Apr 26, 2014, 4:41:46 PM4/26/14
to zoter...@googlegroups.com
Hi,

I played with Google Apps Script, I could load all my entries from Zotero using the REST API into Google Docs. I just had to generate an API key.

There is Eclipse integration where you can store all your Google Apps Scripts on your local machine and once you save it uploads them to Google Drive. This way we could set up a Git repo for the project.
As for Jasmine, there are some native Google classes which have to be used, as long as we can mock them somehow unit testing should be fine. Integration testing is trickier, it has to be done manually for now I guess.

Noticed there's a GitHub account for Zotero already: https://github.com/zotero

I can set up a really basic integration with Google Docs, I can publish it to my GitHub account and I can send a pull request. I can also publish it here so anyone can contribute.

Marnen Laibow-Koser

unread,
Apr 26, 2014, 5:40:29 PM4/26/14
to zoter...@googlegroups.com


On Saturday, April 26, 2014, Robert V <sapp...@gmail.com> wrote:
Hi,

I played with Google Apps Script, I could load all my entries from Zotero using the REST API into Google Docs. I just had to generate an API key.

That makes sense. 
 

There is Eclipse integration where you can store all your Google Apps Scripts on your local machine and once you save it uploads them to Google Drive. This way we could set up a Git repo for the project.

Interesting; I thought the nature of the Apps Script environment made this impossible.  Would you provide some details on how you did this?  (Ideally, I'd like to get it working without Eclipse, which I don't otherwise use.)

As for Jasmine, there are some native Google classes which have to be used, as long as we can mock them somehow unit testing should be fine. Integration testing is trickier, it has to be done manually for now I guess.

Jasmine 1.0 already works on Google Apps, thanks in part to Rajah (I'll provide links when I'm not posting from my phone).  I haven't yet figured out how to get Jasmine 2.0 working, but that's largely because I don't understand Jasmine internals very well. 


Noticed there's a GitHub account for Zotero already: https://github.com/zotero


So?  That belongs to the team, and they've shown very little interest in this
 
I can set up a really basic integration with Google Docs, I can publish it to my GitHub account and I can send a pull request. I can also publish it here so anyone can contribute.

Again, how do you integrate local files with Apps Script?  There appears to be no API that would make that possible. 

Dan Stillman

unread,
Apr 26, 2014, 6:13:27 PM4/26/14
to zoter...@googlegroups.com
On 4/26/14, 5:40 PM, Marnen Laibow-Koser wrote
Noticed there's a GitHub account for Zotero already: https://github.com/zotero


So?  That belongs to the team, and they've shown very little interest in this.

Just to clarify, we're very interested in this and will be happy to provide feedback/guidance — and I already said above in this thread that we can make the necessary API changes to support it. We just don't have developer time right now to take the lead on the client side of it.

In any case, no need for this to be under the Zotero account now, as you say. If there's mutual interest in our taking over ownership of it down the line, it can always be transferred.

Marnen Laibow-Koser

unread,
Apr 26, 2014, 6:59:25 PM4/26/14
to zoter...@googlegroups.com


On Saturday, April 26, 2014, Dan Stillman <dsti...@zotero.org> wrote:
Just to clarify, we're very interested in this and will be happy to provide feedback/guidance — and I already said above in this thread that we can make the necessary API changes to support it. 

Great!  Sorry for mischaracterizing what you said.  Glad to hear there's more interest than I thought. 

Robert V

unread,
Apr 26, 2014, 8:18:35 PM4/26/14
to zoter...@googlegroups.com
Hi,

here's the Eclipse integration tutorial: https://developers.google.com/eclipse/docs/apps_script

What I've seen so far is you still have to manually create the files in Google Drive than the Eclipse plugin will sync them. So you can't create the files locally you can just edit them.
Anyway, at least it allows me to put it under Git. I also set up unit testing with Jasmine 2.0, first test passes but it's just a string assertions so really simple.
I'll share the link to GitHub once I have something useful, but it might be a few weeks as I have other engagements.

Marnen Laibow-Koser

unread,
Apr 26, 2014, 11:25:59 PM4/26/14
to zoter...@googlegroups.com


On Saturday, April 26, 2014, Robert V <sapp...@gmail.com> wrote:
Hi,

here's the Eclipse integration tutorial: https://developers.google.com/eclipse/docs/apps_script

Thanks for the link!  And apparently there's a similar SublimeText plugin:  https://github.com/revolunet/sublimetext-google-apps-scripts

This should make life much easier. 

Bjoern Hassler

unread,
May 11, 2014, 7:11:01 AM5/11/14
to zoter...@googlegroups.com
Hi all,

I've some some further playing with Google Apps script, towards a "poor mans" integration of Zotero and Google docs (via scannable cite). Let me say up front that while what I have works for me, it's for a fairly specific use case, that may not be useful for everybody. It's mainly to implement a scannable cite workflow in Google docs, that's acceptable to my collaborators.

What I've done is to add a custom menu to Google documents, that will convert a scannable cite "{| ABC ||||zg...}" into a link (with text ABC) and the url pointing to zotero.org, with the actual scannable cite packed into a parameter. This makes the scannable cite neater, and helps you find the item on zotero.org if you want to check the reference.  (At the moment, links actually appear as {{ ABC }} with the "{{" and "}}" in a 5pt font. But that can be changed by just looking for links and examining them. I also have a work around to use Zotero stand alone with Chrome, where links don't go to zotero.org, but open in Zotero stand alone instead.)

There's also a function that unpacks such links back into scannable cites. The ideas is that in this way scannable cites can be updated (and repacked) or they can eventually be converted back into scannable cites and processed in that way.

I know it's a specific use case, but it effectively means that my collaborators are now happy to use scannable cite, and that we can thus use scannable cite in our google document (with the added benefit of looking up the items in Zotero). 

I know it's a long way from what could be done, and it's a specific use case, but it seems that there are quite a few things that aren't yet implemented in Google Apps script yet, and I couldn't find that many examples for Google Apps script (particularly for documents as opposed to spreadsheets). Hence trying something small, and see how that fares. One thing for instance is that Google apps script is really quite slow with large documents. Just getting a selection in a large document takes quite a bit of time!

If anybody is interested in the code I can put it up somewhere, for people to have a look. Also of course happy to have conversations with people who want to discuss this!

All the best,
Bjoern

Marnen Laibow-Koser

unread,
May 11, 2014, 1:07:29 PM5/11/14
to zoter...@googlegroups.com


On Sunday, May 11, 2014, Bjoern Hassler <bjo...@gmail.com> wrote:
Hi all,

I've some some further playing with Google Apps script, towards a "poor mans" integration of Zotero and Google docs (via scannable cite). Let me say up front that while what I have works for me, it's for a fairly specific use case, that may not be useful for everybody. It's mainly to implement a scannable cite workflow in Google docs, that's acceptable to my collaborators.
[...]
If anybody is interested in the code I can put it up somewhere, for people to have a look. Also of course happy to have conversations with people who want to discuss this!

Yes, please put it on GitHub or somewhere.  It may not be directly useful, but I suspect there's code that can be incorporated into other projects... 

All the best,
Bjoern


On Friday, 14 March 2014 02:02:34 UTC, Aurimas Vinckevicius wrote:

Hello everyone,

I just want to get a technical conversation going about Zotero integration with Google Docs.

Google recently introduced add-ons for Google Documents, among which is an EasyBib add-on that essentially inserts a pre-formatted bibliography into Google Docs documents. This resulted in a few people on Twitter and in the forums requesting that a similar feature for Zotero be added to Google Docs. As adamsmith explained in this post, you can essentially do the same thing using drag-and-drop from Zotero. While that's true, it would be quite nice to eventually add proper Zotero integration into Google Docs, which should be equivalent to Word/LO addons (i.e. live citations).

I started looking around at the Google Docs add-on API and I think it may be possible. The general idea is to display a pre-formatted in-text citation and associate a Zotero ID with it in a user-invisible fashion (same as is done in Word/LO with fields and bookmarks). If we end up displaying the id to the user, then it's essentially the same as ODF scan. Unfortunately, in Google Docs field codes do not exist. Bookmarks exist, but are associated with a single position in text, not a range of text. I suppose you could use two bookmarks to indicate start and end of a citation, but it becomes easy for the user to delete only one of the bookmarks and mess up this syntax. Also this system would complicate other operations (editing, deleting references, etc.)

Another possibility that is available is inserting pre-formatted citations as links and storing the reference ID as the URL (bonus points: it redirects to the reference on zotero.org). The add-on would then offer an option to strip links (same as removing field codes). Interacting with links is not very convenient, since they would be set on a segment of text without any easy way of retrieving them directly. However, if you wanted to find all citations/links in the document, you could essentially go through the document character by character and check if there is a link set there. Sounds pretty bad, but that's the best I can think of atm. If the user is trying to edit a citation, then we could check only the area surrounding the cursor for links. Scanning of the whole document would only be necessary when inserting a bibliography/updating in-text citations (this should only be done with explicit user commands, not after each addition) and stripping links, Another downside to the link approach is transferring documents from Google Docs to Word/LO. Something similar to RTF/ODF scan could be developed to convert Zotero links to live citations. Clearly this is a low priority concern.

So assuming that the above would work out for managing citations within a document, one would also need to be able to format citations/bibliography correctly. I think the most reasonable approach here would be for zotero.org to provide this through the API. The API would accept a set of references (in the order that they appear in text) as either IDs or JSON data (IDs would be easier for API users, but accepting raw JSON would be more versatile and probably somewhat easier to code on the server side) and return a set of formatted in-text references (in the same order as supplied) and the formatted bibliography. I imagine something like [ ["ref1"], ["ref2", "ref3"], ["ref1", "ref2", "ref3"] ] as the request and [ "1", "2,3", "1-3" ] as the response (plus bibliography) given a numeric style.

These a

--
You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/90ix5AiEOzQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zotero-dev+...@googlegroups.com.

To post to this group, send email to zoter...@googlegroups.com.
Visit this group at http://groups.google.com/group/zotero-dev.
For more options, visit https://groups.google.com/d/optout.

Kieren Diment

unread,
May 12, 2014, 1:46:11 AM5/12/14
to zoter...@googlegroups.com
I'm certainly interested (speaking as someone who's about to take a 6 week sabbatical to finish my thesis, currently sitting 80% complete in markdown with a homegrown zotero citation solution).


--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.

Emiliano Heyns

unread,
May 13, 2014, 9:00:15 AM5/13/14
to zoter...@googlegroups.com
On Friday, March 14, 2014 3:02:34 AM UTC+1, Aurimas Vinckevicius wrote:

Another possibility that is available is inserting pre-formatted citations as links and storing the reference ID as the URL (bonus points: it redirects to the reference on zotero.org). The add-on would then offer an option to strip links (same as removing field codes). Interacting with links is not very convenient, since they would be set on a segment of text without any easy way of retrieving them directly. However, if you wanted to find all citations/links in the document, you could essentially go through the document character by character and check if there is a link set there. Sounds pretty bad, but that's the best I can think of atm. If the user is trying to edit a citation, then we could check only the area surrounding the cursor for links. Scanning of the whole document would only be necessary when inserting a bibliography/updating in-text citations (this should only be done with explicit user commands, not after each addition) and stripping links, Another downside to the link approach is transferring documents from Google Docs to Word/LO. Something similar to RTF/ODF scan could be developed to convert Zotero links to live citations. Clearly this is a low priority concern.


I think Paperpile does it this way, but adds javascript handlers that put a GUI in front of their specific links (which should be easy to detect by either matching the URL or adding a class or id). I think adding them as links has the benefit of staying within what's supported by GDOCS (it's all a form of HTML under the hood it seems), and what you can store in an url is pretty flexible, without breaking regular use of them.

Regards,
Emile

Bjoern Hassler

unread,
May 13, 2014, 6:56:28 PM5/13/14
to zoter...@googlegroups.com, kie...@diment.org
Hi Marnen, hi Kieren, hi Emiliano, hi all,

I have uploaded my initial attempts at writing some google apps script code here:

If others are happy to contribute to this, I can also put some time in, so very happy to discuss possible improvements with others.

Bjoern


On Monday, 12 May 2014 06:46:11 UTC+1, dim...@gmail.com wrote:
I'm certainly interested (speaking as someone who's about to take a 6 week sabbatical to finish my thesis, currently sitting 80% complete in markdown with a homegrown zotero citation solution).
On Mon, May 12, 2014 at 3:07 AM, Marnen Laibow-Koser <mar...@marnen.org> wrote:


On Sunday, May 11, 2014, Bjoern Hassler <bjo...@gmail.com> wrote:
Hi all,

I've some some further playing with Google Apps script, towards a "poor mans" integration of Zotero and Google docs (via scannable cite). Let me say up front that while what I have works for me, it's for a fairly specific use case, that may not be useful for everybody. It's mainly to implement a scannable cite workflow in Google docs, that's acceptable to my collaborators.
[...]
If anybody is interested in the code I can put it up somewhere, for people to have a look. Also of course happy to have conversations with people who want to discuss this!

Yes, please put it on GitHub or somewhere.  It may not be directly useful, but I suspect there's code that can be incorporated into other projects... 

All the best,
Bjoern


On Friday, 14 March 2014 02:02:34 UTC, Aurimas Vinckevicius wrote:

Hello everyone,

I just want to get a technical conversation going about Zotero integration with Google Docs.

Google recently introduced add-ons for Google Documents, among which is an EasyBib add-on that essentially inserts a pre-formatted bibliography into Google Docs documents. This resulted in a few people on Twitter and in the forums requesting that a similar feature for Zotero be added to Google Docs. As adamsmith explained in this post, you can essentially do the same thing using drag-and-drop from Zotero. While that's true, it would be quite nice to eventually add proper Zotero integration into Google Docs, which should be equivalent to Word/LO addons (i.e. live citations).

I started looking around at the Google Docs add-on API and I think it may be possible. The general idea is to display a pre-formatted in-text citation and associate a Zotero ID with it in a user-invisible fashion (same as is done in Word/LO with fields and bookmarks). If we end up displaying the id to the user, then it's essentially the same as ODF scan. Unfortunately, in Google Docs field codes do not exist. Bookmarks exist, but are associated with a single position in text, not a range of text. I suppose you could use two bookmarks to indicate start and end of a citation, but it becomes easy for the user to delete only one of the bookmarks and mess up this syntax. Also this system would complicate other operations (editing, deleting references, etc.)

Another possibility that is available is inserting pre-formatted citations as links and storing the reference ID as the URL (bonus points: it redirects to the reference on zotero.org). The add-on would then offer an option to strip links (same as removing field codes). Interacting with links is not very convenient, since they would be set on a segment of text without any easy way of retrieving them directly. However, if you wanted to find all citations/links in the document, you could essentially go through the document character by character and check if there is a link set there. Sounds pretty bad, but that's the best I can think of atm. If the user is trying to edit a citation, then we could check only the area surrounding the cursor for links. Scanning of the whole document would only be necessary when inserting a bibliography/updating in-text citations (this should only be done with explicit user commands, not after each addition) and stripping links, Another downside to the link approach is transferring documents from Google Docs to Word/LO. Something similar to RTF/ODF scan could be developed to convert Zotero links to live citations. Clearly this is a low priority concern.

So assuming that the above would work out for managing citations within a document, one would also need to be able to format citations/bibliography correctly. I think the most reasonable approach here would be for zotero.org to provide this through the API. The API would accept a set of references (in the order that they appear in text) as either IDs or JSON data (IDs would be easier for API users, but accepting raw JSON would be more versatile and probably somewhat easier to code on the server side) and return a set of formatted in-text references (in the same order as supplied) and the formatted bibliography. I imagine something like [ ["ref1"], ["ref2", "ref3"], ["ref1", "ref2", "ref3"] ] as the request and [ "1", "2,3", "1-3" ] as the response (plus bibliography) given a numeric style.

These a

--
You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/90ix5AiEOzQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zotero-dev+unsubscribe@googlegroups.com.

To post to this group, send email to zoter...@googlegroups.com.
Visit this group at http://groups.google.com/group/zotero-dev.
For more options, visit https://groups.google.com/d/optout.

Bjoern Hassler

unread,
Jun 6, 2014, 12:33:00 PM6/6/14
to zoter...@googlegroups.com
Hi all,

I just wanted to see whether anybody had made some progress on Google docs integration!

Let me know!

Happy weekend!
Bjoern

Robert V

unread,
Jun 9, 2014, 4:25:15 PM6/9/14
to zoter...@googlegroups.com
Yes I'm still working on this and I can communicate through the Zotero API and insert stuff into the posts.

I should be able to publish something soon. However I was very busy recently that's why the delay.

But the thing is once I publish my solution there's gonna be 2 Zotero plugins on GitHub. Maybe we'll see which one will be embraced by other members?

Bjoern Hassler

unread,
Jun 9, 2014, 4:45:16 PM6/9/14
to zoter...@googlegroups.com
Hi Robert,

that's really great to hear, excellent stuff!!

> once I publish my solution there's gonna be 2 Zotero plugins on GitHub. Maybe we'll see which one will be embraced by other members?

Do you mean what I did? Thanks - but that cannot really be called a Zotero plugin. :-) It was an idea I was playing with, to have some sort of quick fix to make scannable cites look better. That's all. So really not that great or far reaching (and while it sort of works, it's really not working particularly well).

Really looking forward to seeing what you've been doing!

Bjoern

Robert V

unread,
Jun 9, 2014, 4:52:27 PM6/9/14
to zoter...@googlegroups.com
Right, actually what you've done could be integrated with my solution eventually.

I mean my insertion is not the best solution. So instead of me thinking of 2 Zotero plugin repos maybe we could think like how to merge the 2 projects into a better one? :)

Reading you made some progress pushes me towards finishing it quickly so I'm working on it right now.

I'll keep the board updated with the progress.

Bruce D'Arcus

unread,
Jun 9, 2014, 5:28:58 PM6/9/14
to zoter...@googlegroups.com

I'm not following your "problem". Why wait to "release"?

Karl Brune

unread,
Jun 15, 2014, 4:36:16 PM6/15/14
to zoter...@googlegroups.com
I appreciate the effort you two are putting into this. Keep up the good work!

Stefan S

unread,
Nov 17, 2014, 4:09:47 AM11/17/14
to zoter...@googlegroups.com
Hi Robert,

would it be possible to publish your code somewhere? I also think of contribute to a Google Drive plugin for Zotero. But it would make sense that I don't start from scratch if there is something out there.

Thanks
Stefan

Bjoern Hassler

unread,
Nov 24, 2014, 4:48:54 AM11/24/14
to zoter...@googlegroups.com
Hi Robert, hi all,

I'm doing ref management with google docs like this:

Part 1: What we've got so far is an (unreliable) function that takes "quick-copied" text from Zotero, and converts it into a hyperlink in Google docs (that is formatted in the citation style needed). The hyperlink links back to Zotero, and opens the item in Zotero, for reference.  

The google apps script "helper menu" is here:

In fact, I struggled a fair bit with google docs app script, so in the end I gave up on this, and used a command line script in OS X instad. So I do "quick-copy", run script to change paste-board content, and then paste into Google docs. Not elegant, but it works.

Part 2: In Zotero, we then manually add a tag (or put a the entry into a folder), which we then use to create the bibliography in google docs (using copy and paste from Zotero.) That part isn't ideal: It would be much better to be able to keep track of what's in the google doc in some way.

To summarise, selection of references: Quite happy to use the quick copy workflow. However, keeping refs used in a google doc in sync with Zotero in some way, to create bibliography would be great.

Of course - these are all hacks, but that's how far I got. Happy to chat more!
Bjoern




--
You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/90ix5AiEOzQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zotero-dev+...@googlegroups.com.

RideLikeTheWind

unread,
Oct 24, 2015, 11:16:08 PM10/24/15
to zotero-dev
Hi,

Just wondering if anyone has taken the lead on this or are still developing a solution? Otherwise, is there scope for obtaining code as I would like to consider how this could be achieved. I have experience with GAE, AppsScript and JS.

Cheers!

Bjoern Hassler

unread,
Oct 25, 2015, 6:37:03 AM10/25/15
to zotero-dev
Hi there,

I did write a little bit of code some time ago, but ended up doing it outside google docs - a hack, to get a quick result, that's not worth replicating. [Basically, I took a url to an article in my online zotero library, reformatted the text to look like the reference (using a shell script), and pasted it into a google document. This preserves the link to the zotero library (in case you want to look up the reference), but also allows you to process the document afterwards (as html) to create the bibliography. Like I said, a hack.]

In terms of my own priorities: I'm (initially) not too bothered about adding references from within Docs (like you can in OO/Word). Instead, I'd be happy to look these up in zotero, and (e.g.) have a quick copy option that produces the reference that can be pasted into the google doc (ideally linking back to zotero). However, what would be really helpful is to have a AppsScript that can extract such references and create a bibliography from them.

Happy to contribute in whatever way is useful. I can certainly participate in discussion, and test/tweak code. (I have experience with GAE, AppsScript, etc.) 

All the best,
Bjoern

Marnen Laibow-Koser

unread,
Oct 25, 2015, 8:49:43 AM10/25/15
to zoter...@googlegroups.com


On Sunday, October 25, 2015, Bjoern Hassler <bjo...@gmail.com> wrote:
Hi there,

I did write a little bit of code some time ago, but ended up doing it outside google docs - a hack, to get a quick result, that's not worth replicating. [Basically, I took a url to an article in my online zotero library, reformatted the text to look like the reference (using a shell script), and pasted it into a google document. This preserves the link to the zotero library (in case you want to look up the reference), but also allows you to process the document afterwards (as html) to create the bibliography. Like I said, a hack.]

Yeah, it's a hack, but that sounds like something that could be packaged up into a useful extension (except that it's in the wrong language...). 
 

In terms of my own priorities: I'm (initially) not too bothered about adding references from within Docs (like you can in OO/Word).

Whereas for me, this is the feature I most want.  (But I haven't got around to writing any actual code yet. :P ) 


Instead, I'd be happy to look these up in zotero, and (e.g.) have a quick copy option that produces the reference that can be pasted into the google doc (ideally linking back to zotero).

That would certainly be a useful second choice for my use case. 
 
 However, what would be really helpful is to have a AppsScript that can extract such references and create a bibliography from them.

Well, yes, this is absolutely necessary.  Otherwise there's no point in using Zotero in the first place. 

FWIW, I haven't done much with Apps script, but I've got lots of development experience in JavaScript and lots of other languages. 
 
Best,
Reply all
Reply to author
Forward
0 new messages