Commit 2d646b85 authored by Alex Gil's avatar Alex Gil

added method for link target, with a new tag and documentation

parent 3000c6e6
......@@ -384,6 +384,12 @@ a specific page. As an example, the tag
will attempt to read the key `ruby` from file `/home/foo/bar.bib`. It will not
fallback to the default BibTeX file.
<!-- elotroalex edit: added documentation for changes -->
#### Citation pointing to another page in your site
In some cases, you might want your citation to link to another page on your cite (ex. a separate works cited page). As a solution, Jekyll-Scholar provides the `--relative` tag. For example, if you wanted the link to point to an ID in a bibliography.html page, you would use:
{% cite ruby --relative bibliography.html %}
#### Multiple bibliographies within one document (like [multibib.sty](http://www.ctan.org/pkg/multibib))
When you have multiple `{% bibliography %}` sections in one file,
......
......@@ -17,7 +17,11 @@ module Jekyll
# #site readers
module Utilities
attr_reader :config, :site, :context, :prefix, :text, :offset, :max
#elotroalex edit: added local variable relative
attr_reader :config, :site, :context, :prefix, :text, :offset, :max, :relative
def split_arguments(arguments)
......@@ -52,12 +56,18 @@ module Jekyll
opts.on('-q', '--query QUERY') do |query|
@query = query
end
end
opts.on('-p', '--prefix PREFIX') do |prefix|
@prefix = prefix
end
# elotroalex edit: added flag for relative url for link_to
opts.on('-r', '--relative RELATIVE') do |relative|
@relative = relative
end
opts.on('-t', '--text TEXT') do |text|
@text = text
end
......@@ -567,6 +577,12 @@ module Jekyll
(context['citation_numbers'] ||= {})[key] ||= cited_keys.length
end
# #elotroalex edit: Added new method to control href output for cite
def link_target_for key
"#{relative}##{[prefix, key].compact.join('-')}"
end
def cite(keys)
items = keys.map do |key|
if bibliography.key?(key)
......@@ -577,7 +593,7 @@ module Jekyll
end
end
link_to "##{[prefix, keys[0]].compact.join('-')}", render_citation(items)
link_to link_target_for(keys[0]), render_citation(items)
end
def cite_details(key, text)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment