inukshuk / citeproc-ruby

A Citation Style Language (CSL) Cite Processor
103 stars 23 forks source link

citeproc-ruby cannot deal with XML comments in CSL files #3

Closed vanto closed 12 years ago

vanto commented 12 years ago

XML comments (i.e. ) in CSL files cause citeproc-ruby to die with the following error:

ERROR  CiteProc : failed to process item {"id"=>, "author"=>[Edgar Allen Poe], "title"=>Poetry, Tales, and Selected Essays, "type"=>book, "issued"=>{"date-parts"=>[[1996]], "literal"=>nil}, "editor"=>[Patrick F. Quinn, G.R. Thompson], "publisher"=>Library of America, "publisher-place"=>New York}: 
undefined method `evaluate' for {"node"=>"CSL::Nodes::Node"}:CSL::Nodes::Node

I'm pretty sure it is because the Node factory does not know the Comment XML node and thus creates a Node instance. This instance, however, does not have an evaluate method.

I currently see three possible solutions:

  1. Ignore comments during parsing and do not create node objects for comments at all.
  2. Define a CommentNode which basically does nothing.
  3. Put an evaluate method to Node
def evaluate(data, processor)
  false
end

All options have (little) pros and cons, so I leave it up to you to decide :)

inukshuk commented 12 years ago

Could you try option 3?

I won't have the time to look into this until tomorrow.

vanto commented 12 years ago

Sure, no problem. I filed a pull request -- didn't know that they are also shown as an issue. Is there any possibility to merge them?

inukshuk commented 12 years ago

Great! I merged and since this didn't influence any of our tests I pushed gem version 0.0.3 to make it easier for you to use this.

By the way, if you run into any limitations, the new citeproc gem is already usable with the citeproc-js engine; it is a bit difficult to get the embedded javascript engine up and running though.