RTF/ODF Scan for Zotero

2456717
  • Also as a theologian ... pipes are fine!
  • @epedrick - Frank and I feel strongly about backwards compatibility, ie.
    My only request is that if this system is updated (ie made prettier) that the ODF scan will continue to be able to read citations entered in the current Scannable Citation format.
    this will definitely be the case. In the highly unlikely case that we ever feel like we can't support a legacy format any more we'll provide a conversion tool, but I doubt that will happen.

    We've already implemented a lot of the changes suggested above, btw. the default citation with the latest version of the marker looks like this
    { | Smith, (2000) | | |zu:2433:MDA5XMVR} in version 1.0.9 which should update automatically for you.
    (and as per above, the old version of the marker continues to work, of course).
  • edited May 14, 2013
    Thank you, Frank and Sebastian! And thank you, baby Jesus, that we can now reliable cite out of Scrivener! :) The big ugly marker doesn't bother me.
  • Dear Frank and Sebastian, thank you for this great plugin. I am testing it out on Ubuntu Linux, and it seems to work great. Yes, the extra text in the editing window for Scrivener is a little distracting, particularly with longer citations, but the fact the there is now a seamless bridge between Zotero and Scrivener (and the fact that it works with LibreOffice which I much prefer to MS Word) is quite exciting. Kudos! I cannot live without Zotero, and this makes something great even better. Thanks again. I edited the Scannable Cite.js file as per the instructions above but I didn't see any change in the verbiage in Scrivener. Maybe I did something wrong?
  • how do your citations currently look? The newest version should do author-date anyway - along the lines of { | Smith, (2000) | | |zu:2433:MDA5XMVR}
  • Oh, right, that's how it looks. I somehow thought that editing the Scannable Cite.js file would eliminate the zu: stuff and only leave the author and date. Maybe I misunderstood your previous post. My bad.
  • no, the zu stuff is what makes this work. The markers used to also include the title of the item, that's what the above instructions removed - they're no longer relevant, I'll edit the post.
  • Hello,

    I think your plugin is awesome. Nevertheless, I have some issues. I am not able to use the plugin to parse rtf files. Is it possible? or an upcomming feature? This definitely is a major issue in my work and I need an answer in order to choose wether I'll use one or the other tool
  • edited May 17, 2013
    That should be no problem. LibreOffice can read rtf files and save them as ODF (*.odt); the markers can then be converted to live Zotero links.
  • It is a problem when your plugin proposes to perform a conversion in two steps (save in odf open the odf convert with zotero then save into rtf) rather than in one (save in rtf convert and done)

    It is not a problem. It is just that your tool is so good and cleverer than the simple basic rtf converter zotero proposes that I hopped a way to replace zotero's one with yours.

    Nevermind. i'll use your solution.
  • the tool won't work with RTF because it writes actual Zotero field codes - which don't exist in RTF. The formatting of references is done by the Zotero LO plugin (which only reads ODF). So we don't expect this to change any time soon. It would generally be possible to change RTF scan to work with out syntax, but that would be an almost entirely separate set of code (and would require solving some of the same issues plaguing RTF scan now).
  • Allright. Thanks for your answers.

    PS: Your plugin still rock.
  • FYI - I had to update to Zotero 4.0.8 (from 4.0.7) to get this to work.

    You may want to add a version check, or at least a note on the webpage about version requirements. Before I updated, I got the javascript error message "An error occurred while trying to export the selected file." when I dragged and dropped a citation out of Zotero.

    All seems to be well after updating.
  • There aren't any new features in 4.0.8 - so if this was indeed not working in 4.0.7 that would have been a Zotero bug. But it could very well have been a fluke or related to the 4.0.7 specific database update bug.
    While we haven't tested this, I'd be surprised if it didn't work even in the 3.0 release.
  • Hmmm...it was working yesterday, but today it is not. I logged output (below) after uninstalling, then reinstalling the plugin.

    1) Scannable Cite has not been added to the styles (or rather, seems to have been removed now)
    2) RTF scan is back to saying "RTF scan" instead of "RTF/ODF Scan".

    The odd thing is that yesterday I played around with it for a while - converting several files. Today (after a restart), it all seems to be missing...

    Thanks,
    CB

    --------
    Output:

    [JavaScript Error: "Error loading style '_.csl': undefined" {file: "/Users/CB/Documents/Zotero Home/styles/_.csl" line: 0}]

    [JavaScript Error: "The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature." {file: "zotero://debug/" line: 0}]

    version => 4.0.8, platform => MacIntel, oscpu => Intel Mac OS X 10.7, locale => en-US, appName => Zotero, appVersion => 4.0.8

    =========================================================

    (5)(+0000000): SELECT leafName, translatorJSON, code, lastModifiedTime FROM translatorCache

    (3)(+0000062): Cached 408 translators in 62 ms

    (3)(+0000000): Saving translator 'Scannable Cite'

    (3)(+0000000): {
    "translatorID": "248bebf1-46ab-4067-9f93-ec3d2960d0cd",
    "label": "Scannable Cite",
    "creator": "Scott Campbell, Avram Lyon, Nathan Schneider, Sebastian Karcher, Frank Bennett",
    "target": "html",
    "minVersion": "3.0",
    "maxVersion": "",
    "priority": 100,
    "displayOptions": {
    "exportCharset": "UTF-8"
    },
    "inRepository": true,
    "translatorType": 2,
    "browserSupport": "",
    "lastUpdated": "2013-04-16 11:10:08"
    }

    // legal types are weird
    var LEGAL_TYPES = ["patent","case","statute","bill","treaty","regulation","gazette"];
    var Mem = function () {
    var isLegal = false;
    var lst = [];
    this.init = function (item) { lst = []; isLegal = (LEGAL_TYPES.indexOf(item.itemType)>-1)};
    this.set = function (str, punc, slug) { if (!punc) {punc=""}; if (str) {lst.push((str + punc))} else if (!isLegal) {lst.push(slug)}};
    this.setlaw = function (str, punc) { if (!punc) {punc=""}; if (str && isLegal) {lst.push(str + punc)}};
    this.get = function () { return lst.join(" ") };
    }
    var mem = new Mem();
    var memdate = new Mem();

    function doExport() {
    var item;
    while (item = Zotero.nextItem()) {
    mem.init(item);
    Zotero.write("{ |");
    var library_id = item.libraryID ? item.libraryID : 0;
    if (item.creators.length >0){
    mem.set(item.creators[0].lastName,",");
    if (item.creators.length > 2) mem.set("et al.", ",");
    else if (item.creators.length == 2) mem.set("& " + item.creators[1].lastName, ",");
    }
    else {
    mem.set(false, ",","anon.");
    }
    if (Zotero.getHiddenPref("ODFScan.includeTitle")) {
    mem.set(item.title,",","(no title)");
    }
    mem.setlaw(item.authority, ",");
    mem.setlaw(item.volume);
    mem.setlaw(item.reporter);
    mem.setlaw(item.pages);
    memdate.setlaw(item.court,",");
    var date = Zotero.Utilities.strToDate(item.date);
    var dateS = (date.year) ? date.year : item.date;
    memdate.set(dateS,"","no date");
    Zotero.write(" " + mem.get() + " (" + memdate.get() + ") | | |");
    if (Zotero.getHiddenPref("ODFScan.useZoteroSelect")) {
    Zotero.write("zotero://select/items/" + library_id + "_" + item.key + "}");
    } else {
    var m = item.uri.match(/http:\/\/zotero\.org\/(users|groups)\/([^\/]+)\/items\/(.+)/);
    var prefix;
    var lib;
    var key;
    if (m) {
    if (m[1] === "users") {
    prefix = "zu:";
    if (m[2] === "local") {
    lib = "0";
    } else {
    lib = m[2];
    }
    } else {
    prefix = "zg:";
    lib = m[2];
    }
    } else {
    prefix = "zu:";
    lib = "0";
    }
    Zotero.write(prefix + lib + ":" + item.key + "}");
    }
    }
    }

    (5)(+0000001): SELECT leafName, translatorJSON, code, lastModifiedTime FROM translatorCache

    (5)(+0000049): Beginning DB transaction

    (3)(+0000000): Beginning Notifier event queue

    (5)(+0000000): REPLACE INTO translatorCache VALUES (?, ?, ?, ?)

    (5)(+0000000): Binding parameter 1 of type string: "Scannable Cite.js"

    (5)(+0000000): Binding parameter 2 of type string: "{
    "translatorID": "248bebf1-46ab-4067-9f93-ec3d2960d0cd",
    "label": "Scannable Cite",
    "creator": "Scott Campbell, Avram Lyon, Nathan Schneider, Sebastian Karcher, Frank Bennett",
    "target": "html",
    "minVersion": "3.0",
    "maxVersion": "",
    "priority": 100,
    "displayOptions": {
    "exportCharset": "UTF-8"
    },
    "inRepository": true,
    "translatorType": 2,
    "browserSupport": "",
    "lastUpdated": "2013-04-16 11:10:08"
    }
    "

    (5)(+0000000): Binding parameter 3 of type NULL

    (5)(+0000000): Binding parameter 4 of type int64: 1369571518000

    (5)(+0000009): Committing transaction

    (3)(+0000003): Resetting Notifier event queue

    (3)(+0000005): Cached 408 translators in 67 ms
  • From that trace, it looks like the translator is installing (although if it's not turning up in the UI, something is clearly not working).

    Out of curiosity, what version of Firefox are you running (or if Standalone, its version)?

    If you have other plugins installed, try disabling them and see if that makes a difference.
  • Zotero Standalone 4.0.8
    No other plugins...
  • The only other variable I can think of tonight would be something weird getting set in the plugin preferences that crashes the install, but I'm not sure how you should go about inspecting either JS errors or the preferences in Standalone (the former would be via Web Developer -> Error Console in Firefox; the latter via about:config in the address bar).
  • Here is the about:config from the Standalone: https://www.evernote.com/shard/s7/sh/37db4e8d-0ccf-4dab-874c-4e4889e72710/0f19c957ef10b48df6602a35399700de

    Thanks for helping think this through...
  • I'm actually wondering about

    [JavaScript Error: "Error loading style '_.csl': undefined" {file: "/Users/CB/Documents/Zotero Home/styles/_.csl" line: 0}]
    That seems like something else may be corrupted
    Could you open your Zotero data folder http://www.zotero.org/support/zotero_data
    then close down Zotero, delete the styles and the translator folder, restart Zotero and re-install the plugin.
  • I just renamed my Zotero directories (both the one in Application Support and my data directory (which is NOT in that folder)) and started over with a "blank slate" for testing purposes (Obviously, my data is still intact).

    I now get this in the error log when I install the add-in:

    [JavaScript Error: "NS_ERROR_FAILURE: Root node doesn't exist for 'discover' view" {file: "chrome://mozapps/content/extensions/extensions.js" line: 596}]

    version => 4.0.8, platform => MacIntel, oscpu => Intel Mac OS X 10.7, locale => en-US, appName => Zotero, appVersion => 4.0.8

    Continued thank yous, Adam :)
  • edited May 27, 2013
    I just renamed my Zotero directories (both the one in Application Support and my data directory (which is NOT in that folder)) and started over with a "blank slate" for testing purposes (Obviously, my data is still intact).
    not sure I follow that. I'm not sure it's a good idea to rename the zotero folder in application support (and I hope nothing I said suggested that'd be necessary).
    But if your data is still intact, how is this a clean slate - the translator and styles folder are in your data directory. Did you move the data? Unless you really know what you're doing I'd council some caution mucking around with that beyond instructions.

    If you actually do want a clean slate, try creating a new Standalone profile
    https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles (works the same way with zotero - obviously with changed filepath)
    Ideally you'd first try install the plugin to see if that works. Only then transfer your data (if you want to).
  • edited May 28, 2013
    I'm getting the same error message as cricketbird.

    Updated LibreOffice, re-installed the plug-in - didn't help.

    If I click "Add Citation" from LibreOffice, it just shifts focus to the Zotero window - no special window opens up.
  • which OS and Zotero version? Also, why click "add citation" from Libre Office?
  • edited May 28, 2013
    Sorry, that was absentminded of me:
    OS X 10.7.5
    Zotero 3.0.8.1
    RTF/ODF Scan 1.0.9

    I think this line from the Zotero log is of interest:

    [JavaScript Error: "Zotero.getHiddenPref is not a function" {file: "/Users/Rafter/Desktop/Devonthink & Sente/Zotero/translators/Scannable Cite.js" line: 45}]

    Here is the error in context:

    (2)(+0000001): Translate: Translation using Scannable Cite failed:
    fileName => /Users/Rafter/Desktop/Devonthink & Sente/Zotero/translators/Scannable Cite.js
    lineNumber => 45
    string => TypeError: Zotero.getHiddenPref is not a function
    stack => doExport()@/Users/Rafter/Desktop/Devonthink & Sente/Zotero/translators/Scannable Cite.js:45


    I'm using the "Add Citation" button in LibreOffice because I'm trying to find something that will work so I can submit this damn paper. :) I thought it might be relevant because (as I just confirmed) on my MacBook Pro (10.8.3) both the copy-paste function using your plug-in, and the LibreOffice plugin functions, are working

    For now I'll be working on my laptop I suppose!
  • update Zotero to the most recent version from zotero.org/download (4.0.8) and both the libre office plugin and RTF scan should work
  • I just created a new, blank, user profile on my computer and installed a fresh copy of Zotero. The add-in still does not install correctly. Here is the most relevant looking part of the error log from the install:

    [JavaScript Error: "The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature." {file: "zotero://debug/" line: 0}]

    version => 4.0.8, platform => MacIntel, oscpu => Intel Mac OS X 10.7, locale => en-US, appName => Zotero, appVersion => 4.0.8
  • what exactly happens on install? The error is unrelated
  • The install appears to work (no obvious error messages and it appears in the extensions list). However, the citation style is not added, and the Tools menu still says RTF Scan...
  • Adam - thank you for your continued assistance. Here is the rest of the error code. Sorry it is so long :(

    =========================================================

    (5)(+0000000): SELECT leafName, translatorJSON, code, lastModifiedTime FROM translatorCache

    (3)(+0000061): Cached 407 translators in 62 ms

    (3)(+0000000): Saving translator 'Scannable Cite'

    (3)(+0000000): {
    "translatorID": "248bebf1-46ab-4067-9f93-ec3d2960d0cd",
    "label": "Scannable Cite",
    "creator": "Scott Campbell, Avram Lyon, Nathan Schneider, Sebastian Karcher, Frank Bennett",
    "target": "html",
    "minVersion": "3.0",
    "maxVersion": "",
    "priority": 100,
    "displayOptions": {
    "exportCharset": "UTF-8"
    },
    "inRepository": true,
    "translatorType": 2,
    "browserSupport": "",
    "lastUpdated": "2013-04-16 11:10:08"
    }

    // legal types are weird
    var LEGAL_TYPES = ["patent","case","statute","bill","treaty","regulation","gazette"];
    var Mem = function () {
    var isLegal = false;
    var lst = [];
    this.init = function (item) { lst = []; isLegal = (LEGAL_TYPES.indexOf(item.itemType)>-1)};
    this.set = function (str, punc, slug) { if (!punc) {punc=""}; if (str) {lst.push((str + punc))} else if (!isLegal) {lst.push(slug)}};
    this.setlaw = function (str, punc) { if (!punc) {punc=""}; if (str && isLegal) {lst.push(str + punc)}};
    this.get = function () { return lst.join(" ") };
    }
    var mem = new Mem();
    var memdate = new Mem();

    function doExport() {
    var item;
    while (item = Zotero.nextItem()) {
    mem.init(item);
    Zotero.write("{ |");
    var library_id = item.libraryID ? item.libraryID : 0;
    if (item.creators.length >0){
    mem.set(item.creators[0].lastName,",");
    if (item.creators.length > 2) mem.set("et al.", ",");
    else if (item.creators.length == 2) mem.set("& " + item.creators[1].lastName, ",");
    }
    else {
    mem.set(false, ",","anon.");
    }
    if (Zotero.getHiddenPref("ODFScan.includeTitle")) {
    mem.set(item.title,",","(no title)");
    }
    mem.setlaw(item.authority, ",");
    mem.setlaw(item.volume);
    mem.setlaw(item.reporter);
    mem.setlaw(item.pages);
    memdate.setlaw(item.court,",");
    var date = Zotero.Utilities.strToDate(item.date);
    var dateS = (date.year) ? date.year : item.date;
    memdate.set(dateS,"","no date");
    Zotero.write(" " + mem.get() + " (" + memdate.get() + ") | | |");
    if (Zotero.getHiddenPref("ODFScan.useZoteroSelect")) {
    Zotero.write("zotero://select/items/" + library_id + "_" + item.key + "}");
    } else {
    var m = item.uri.match(/http:\/\/zotero\.org\/(users|groups)\/([^\/]+)\/items\/(.+)/);
    var prefix;
    var lib;
    var key;
    if (m) {
    if (m[1] === "users") {
    prefix = "zu:";
    if (m[2] === "local") {
    lib = "0";
    } else {
    lib = m[2];
    }
    } else {
    prefix = "zg:";
    lib = m[2];
    }
    } else {
    prefix = "zu:";
    lib = "0";
    }
    Zotero.write(prefix + lib + ":" + item.key + "}");
    }
    }
    }
Sign In or Register to comment.