extend CSL.Output.formats in a plugin?

Hi,

I am trying, in the most tentative and exploratory way, to extend Erik Hetzner's zotxt plugin (https://bitbucket.org/egh/zotxt) to output bibliographies formatted in the org-mode (http://orgmode.org) syntax, which is a little bit like markdown, only different.

The code appears to rely on underlying capabilities in citeproc-js, which currently generates output in html, plain-text, and rtf. It looks to me as though it is not so hard to write a new output filter in citeproc, but I don't know how long it would take to get that accepted into citeproc, and then for the changes to propagate up to Zotero.

So I wondered, in the interim, whether it would be possible to just extend CSL.Output.Formats from within a hacked version of the plugin.
So, I would imitate formts.js from citeproc-js (https://bitbucket.org/fbennett/citeproc-js/src/789b5a8a2d694c6afd4073161e4d5941b695e2be/src/formats.js?at=default) and define

CSL.Output.Formats.prototype.org = {
.....
}

at the top of the extension's main file, bootstrap.js ; and then allow the plugin to serve up org-syntax output in the relevant functions there.

I guess I don't understand javascript's object model very well, nor do I quite understand how much of the underlying citeproc code the plugin has access to. I think it pulls in the Zotero functionality with these lines:

if (!z) {
z = Components.classes["@zotero.org/Zotero;1"].
getService(Components.interfaces.nsISupports).wrappedJSObject;

/* these must be initialized AFTER zotero is loaded */
easyKeyRe = z.Utilities.XRegExp("^(\\p{Lu}[\\p{Ll}_-]+)(\\p{Lu}\\p{Ll}+)?([0-9]{4})?");
alternateEasyKeyRe = z.Utilities.XRegExp("^([\\p{Ll}_-]+)(:[0-9]{4})?(\\p{Ll}+)?");
}


I don't know if I would have to somehow work my way deep into the Zotero code base and access the citeproc functions from somewhere in the z object?

Anyway, thanks for your help!
Matt
  • (that's a bit technical for here, we try to keep anything that's more technical than CSL styles off the forums to not intimidate people with "ordinary" technical problems. zotero-dev is the place to go:
    https://groups.google.com/forum/?fromgroups=#!forum/zotero-dev )
Sign In or Register to comment.