Commit 714c9e0a authored by Sylvester Keil's avatar Sylvester Keil

Merge pull request #123 from elotroalex/master

added method for link target, with a new tag and documentation
parents 3000c6e6 d4aeac70
......@@ -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,10 @@ module Jekyll
# #site readers
module Utilities
attr_reader :config, :site, :context, :prefix, :text, :offset, :max
attr_reader :config, :site, :context, :prefix, :text, :offset, :max, :relative
def split_arguments(arguments)
......@@ -52,12 +55,16 @@ module Jekyll
opts.on('-q', '--query QUERY') do |query|
@query = query
end
end
opts.on('-p', '--prefix PREFIX') do |prefix|
@prefix = prefix
end
opts.on('-r', '--relative RELATIVE') do |relative|
@relative = relative
end
opts.on('-t', '--text TEXT') do |text|
@text = text
end
......@@ -83,7 +90,7 @@ module Jekyll
end
end
argv = arguments.split(/(\B-[cCfqptTslomA]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|template|locator|offset|max|suppress_author|))/)
argv = arguments.split(/(\B-[cCfqrptTslomA]|\B--(?:cited(_in_order)?|file|query|relative|prefix|text|style|template|locator|offset|max|suppress_author|))/)
parser.parse argv.map(&:strip).reject(&:empty?)
end
......@@ -567,6 +574,10 @@ module Jekyll
(context['citation_numbers'] ||= {})[key] ||= cited_keys.length
end
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 +588,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