zotero / citeproc-js-server

Web service to generate citations and bibliographies using citeproc-js
Other
60 stars 39 forks source link

Editor showing as author #26

Closed dstillman closed 8 years ago

dstillman commented 8 years ago

Not sure if this is a bug in citeproc-node or the processor or somewhere else, but it kind of seems too fundamental to be a processor bug:

https://forums.zotero.org/discussion/54447/

% cat data
{"items":[{"id":"2531249/FHNRKQIJ","type":"book","title":"The grammar-phobe's guide to better English","publisher":"Macmillan","publisher-place":"New York","event-place":"New York","editor":[{"family":"Bly","given":"Robert W."}],"issued":{"raw":"1995"}}]}

% curl -d @data 'http://127.0.0.1:9082?style=chicago-author-date&responseformat=html'
<div class="csl-bib-body">
  <div class="csl-entry">Robert W. Bly. 1995. <i>The Grammar-Phobe’s Guide to Better English</i>. New York: Macmillan.</div>
</div>
dstillman commented 8 years ago

@fbennett Any idea what's going on here? We're not seeing any reason this should be happening, and @inukshuk gets the correct output in citeproc-rb. But we see this in multiple versions of citeproc-js going back months.

fbennett commented 8 years ago

That's very weird, isn't it. In a citeproc-js test, I get correct output with that input:

<div class="csl-bib-body">
  <div class="csl-entry">Bly, Robert W. (ed.). 1995. <i>The Grammar-Phobe’s Guide to Better English</i> (New York: Macmillan)</div>
</div>

As a wild guess, maybe there is a loose global variable in the processor context? I'll try to set up a citeproc-node instance locally to dig further.

dstillman commented 8 years ago

OK, thanks — at least we're not going crazy.

I can reproduce this by slotting in the above data here (no HTTP necessary): https://github.com/zotero/citeproc-node/blob/master/node_example.js

dstillman commented 8 years ago

I don't know the details, but @fcheslack makes some modifications to citeproc-js here to use JSON for style parsing, so it's possible there's a bug being introduced there.

fcheslack commented 8 years ago

The modification is just defining CSL_JSON when it's nodejs and making sure it gets used as XML_PARSING. That's the only thing I could think of that seems likely to cause this kind of error (though I don't know how) and not see it in normal citeproc-js testing.

inukshuk commented 8 years ago

That's curious! @fbennett your output is not using chicago-author-date though is it? (Not that I see anything suspicious in the style that could be causing this, but just to make sure we're using the same data)

fbennett commented 8 years ago

That was MHRA (the style in the original report I think). Chicago Author-Date yields:

<div class="csl-bib-body">
  <div class="csl-entry">Bly, Robert W., ed. 1995. <i>The Grammar-Phobe’s Guide to Better English</i>. New York: Macmillan.</div>
</div>
fbennett commented 8 years ago

Have hit a snag attempting to get citeproc-node running locally, failing on let. I've upgraded node.js on Ubuntu:

bennett@black-slate:~/src/citeproc-js$ node --version
v0.12.7

But I still get the error:

bennett@black-slate:~/src/citeproc-node$ node lib/citeServer.js 
/home/bennett/src/citeproc-node/lib/citeServer.js:75
let jsonWalker = require("./json_walker.js");
^^^
SyntaxError: Unexpected strict mode reserved word
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Time for breakfast.

fcheslack commented 8 years ago

I believe 'node --harmony' should allow it to run on node 0.12.x

inukshuk commented 8 years ago

You could try to run in strict mode if you are not already; or else it may help to start node with node --harmony (don't know when let/const was enabled by default).

@dstillman after what you said the other day, I read json as 'Jason' all the time. Jason Walker.

fbennett commented 8 years ago

The --harmony flags brings in ES6 let - thanks all. It stops on jsdom, though. Switching over to iojs did the trick, and I have the server up. Seems like it might be some interaction thing - something special in the JSON parser or conversions, plus some bug in the processor. Will muck about and see what emerges.

fbennett commented 8 years ago

Progress. Tracing the name operations in citeproc-node and in the test bed shows an extraneous node initialization immediately before each rendering, which loses the formatting attributes. That suggests a problem in the refactoring of the style code that takes place in the JSON parsing module - it must be throwing in an extra node object. Should be a straight path to a fix now. More later.