inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.12k stars 102 forks source link

Add nocite tag #323

Closed iveney closed 1 week ago

iveney commented 3 years ago

Taking a stab at #322, which adds a nocite tag that do not output citation [1] in place, but will silently track them and print out the mentioned citations via {% bibliography --cited %}

It works locally on my own blog, but I was not able to run cucumber correctly.

➜  jekyll-scholar git:(nocite) rake
/Users/ivanx/.rbenv/versions/2.7.1/bin/ruby -S bundle exec cucumber
Traceback (most recent call last):
    13: from /Users/ivanx/.rbenv/versions/2.7.1/bin/ruby_executable_hooks:22:in `<main>'
    12: from /Users/ivanx/.rbenv/versions/2.7.1/bin/ruby_executable_hooks:22:in `eval'
    11: from /Users/ivanx/.rbenv/versions/2.7.1/bin/cucumber:23:in `<main>'
    10: from /Users/ivanx/.rbenv/versions/2.7.1/bin/cucumber:23:in `load'
     9: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/bin/cucumber:11:in `<top (required)>'
     8: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/bin/cucumber:11:in `require'
     7: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber/cli/main.rb:8:in `<top (required)>'
     6: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber/cli/main.rb:8:in `require'
     5: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber.rb:6:in `<top (required)>'
     4: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber.rb:6:in `require'
     3: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber/parser.rb:2:in `<top (required)>'
     2: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber/parser.rb:2:in `require'
     1: from /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber/ast.rb:9:in `<top (required)>'
/Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber/ast.rb:9:in `require': /Users/ivanx/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/cucumber-1.3.11/lib/cucumber/ast/step.rb:80: circular argument reference - name (SyntaxError)
inukshuk commented 3 years ago

Great, thanks!

I can take a look at this, but please add the nocite tag source file and the tests to this PR.

As for the nocite helper, we don't need to convert the entry at all, since we're not doing anything with it. It should be OK to just check bibliography.key?(key) which tells us whether or not the entry exists; if it does exist, add it to cited_keys and we're good. It's an interesting question what to do if a key is missing: since the tag isn't supposed to print anything we could either silently ignore it -- or, to alert users to the fact that they're citing a missing key print the missing reference string. What do you think?