Commit 6373f86c authored by egon w. stemle's avatar egon w. stemle

re-tackles #85

This simple 'solution' returns all entries for ``--max 0``.  Now, to
avoid this the logic of ``offset`` and ``max`` needs to become more
complex - unless I am missing an obvious solution.
parent 15ef9e20
......@@ -29,11 +29,7 @@ module Jekyll
end
end
# this also allows for --max {...,-2,-1,0,1,...}
if max > -1
@max = offset + max - 1
end
items = items[offset..max]
items = items[offset..max] if limit_entries?
bibliography = items.each_with_index.map { |entry, index|
reference = bibliography_tag(entry, index + 1)
......
......@@ -27,8 +27,6 @@ module Jekyll
end
def optparse(arguments)
@offset = 0 # set default
@max = -1 # set default
return if arguments.nil? || arguments.empty?
parser = OptionParser.new do |opts|
......@@ -141,6 +139,18 @@ module Jekyll
sort bibliography[query || config['query']]
end
def offset
@offset ||= 0
end
def max
@max.nil? ? -1 : @max + offset - 1
end
def limit_entries?
!offset.nil? || !max.nil?
end
def sort(unsorted)
return unsorted if skip_sort?
......
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