lib/rpub/compilation_helpers.rb in rpub-0.2.1 vs lib/rpub/compilation_helpers.rb in rpub-0.3.0
- old
+ new
@@ -2,17 +2,24 @@
# Provide a set of helper methods that are used across various commands to
# simplify the compilation process. These methods mostly deal with loading files
# from the current project directory.
module CompilationHelpers
+ def concatenated_document
+ Kramdown::Document.new(
+ markdown_files.join("\n"),
+ KRAMDOWN_OPTIONS.merge(:template => layout)
+ )
+ end
+
# Factory method for {Rpub::Book} objects, loading every markdown file as a
# chapter.
#
# @see #markdown_files
# @return [Rpub::Book]
def create_book
- book = Book.new(layout, config)
+ book = Book.new(layout, config, fonts)
markdown_files.each(&book.method(:<<))
book
end
# All chapter input files loaded into strings. This does not include any of
@@ -43,9 +50,13 @@
YAML.load_file('config.yml') || {}
end
end
private
+
+ def fonts
+ @fonts ||= File.read(styles).scan(/url\((?:'|")?([^'")]+\.otf)(?:'|")?\)/i).flatten
+ end
def filter_exceptions(filenames)
return filenames unless config.has_key?('ignore')
filenames.reject(&config['ignore'].method(:include?))
end