Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to parts from img and hd #490

Merged
merged 1 commit into from
Mar 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/review/book/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ def each_part(&block)
parts.each(&block)
end

def contents
# TODO: includes predef, appendix, postdef
if parts.present?
chapters + parts
else
chapters
end
end

def chapters
parts().map {|p| p.chapters }.flatten
end
Expand Down
6 changes: 4 additions & 2 deletions lib/review/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ def bibpaper(lines, id, caption)

def inline_hd(id)
m = /\A([^|]+)\|(.+)/.match(id)
chapter = @book.chapters.detect{|chap| chap.id == m[1]} if m && m[1]
if m && m[1]
chapter = @book.contents.detect{|chap| chap.id == m[1]}
end
if chapter
inline_hd_chap(chapter, m[2])
else
Expand Down Expand Up @@ -364,7 +366,7 @@ def get_chap(chapter = @chapter)
def extract_chapter_id(chap_ref)
m = /\A([\w+-]+)\|(.+)/.match(chap_ref)
if m
return [@book.chapters.detect{|chap| chap.id == m[1]}, m[2]]
return [@book.contents.detect{|chap| chap.id == m[1]}, m[2]]
else
return [@chapter, chap_ref]
end
Expand Down