Skip to content

Commit

Permalink
refactor HeadlineIndex.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Apr 12, 2014
1 parent 7305d5a commit 8c27ba4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/review/book/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ def number(id)
end

class HeadlineIndex < Index
HEADLINE_PATTERN = /\A(=+)(?:\[(.+?)\])?(?:\{(.+?)\})?(.*)/
Item = Struct.new(:id, :number, :caption)

def HeadlineIndex.parse(src, chap)
items = []
indexs = []
headlines = []
src.each do |line|
if m = /\A(=+)(?:\[(.+?)\])?(?:\{(.+?)\})?(.*)/.match(line)
if m = HEADLINE_PATTERN.match(line)
next if m[2] == 'column'
index = m[1].size - 2
if index >= 0
Expand Down

0 comments on commit 8c27ba4

Please sign in to comment.