Comments (5)
Matt!
When you parse BibTeX entries the names will be parsed by default; since you are creating the names from a hash, though, this doesn't happen automatically. Observe (working with your exampe):
> bib.to_citeproc['author']
=> "Ruby, Sam and Thomas, Dave, and Hansson, David Heinemeier"
> bib.parse_names
> bib.to_citeproc['author']
=> [{"family"=>"Ruby", "given"=>"Sam"}, {"family"=>"Thomas", "given"=>"Dave"}, {"family"=>"Hansson", "given"=>"David Heinemeier"}]
Once you've parsed the names, the citeproc processor can work with the values:
> CiteProc.process bib.to_citeproc, :style => :mla
=> "Ruby, Sam, Dave Thomas, and David Heinemeier Hansson. Agile Web Development with Rails. 2009."
> CiteProc.process bib.to_citeproc, :style => :mla, :mode => :citation
=> ["(Ruby, Thomas & Hansson)"]
from bibtex-ruby.
We should probably have #to_citeproc
enforce name parsing; I'll include that with 2.0.1 which we'll push in the next couple of days.
from bibtex-ruby.
Ah! That makes sense. Thanks for the quick reply.
from bibtex-ruby.
One more question: This works great in a 1.9.2 irb session, but when running in a 1.9.2 and rails 3.1 console I get the following error and I am not sure how to proceed. Any help will be appreciated. (This is directly after the call to parse_names)
SystemStackError: stack level too deep
from /Users/mattsmith/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/forwardable.rb:185
from bibtex-ruby.
Matt,
thanks for reporting this issue. It quite clearly happens somewhere in the racc parser; to reproduce you can run
BibTeX::NameParser.new.parse('Sebastian Melmoth')
or, indeed, any name, and it will fail. The parse method calls the lexical analysis (which works, as you can try to call #scan
directly with the name) followed by racc's #do_parse
– that's where the error occurs.
As for debugging, we will have to look at the Racc module that ships with Ruby; or try to get at it from the other direction and find out what modifications Rails makes that may cause the error.
In any case, that's something we must figure out, as it's not acceptable for the name parser not to work with rails. I'll open a separate issue for this, please report back your findings if you're debugging this further!
from bibtex-ruby.
Related Issues (20)
- Unable to parse bibtex if `+` is in the key HOT 1
- Allow BibTeX::Filter access more metadata HOT 2
- Does bibtex-ruby read all fields (PMID in specific) HOT 8
- tag name with spaces break parser
- TeX-like comments (for use with biber) HOT 1
- Can this gem convert from CSL-JSON to BibTex? HOT 5
- Accents in bibtex files HOT 3
- Adding Rubocop HOT 4
- Corruption of @comment fields used by BibDesk for library management HOT 1
- warning: Capturing the given block using Proc.new is deprecated; use `&block` instead HOT 1
- BibTeX.open(file) cannot handle remote files HOT 2
- Export to Medline/wiki page with pointers to gists of people's custom formats? HOT 1
- A name that doesn't parse correctly HOT 1
- Braces in citekey HOT 2
- Move CI to Github Actions
- CiteProc.process returns nill (fails) HOT 2
- racc dependency needed HOT 2
- bibtex-ruby crashes with NoMethodError inside Names.convert! in Ruby 3.3 HOT 2
- bug: incorrect handling of lastnames with whitespaces
- error with ruby 3.3.1: names.rb:51:in `to_s': wrong number of arguments HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bibtex-ruby.