samples/sample-book/src/lib/tasks/review.rake in review-5.0.0 vs samples/sample-book/src/lib/tasks/review.rake in review-5.1.0
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (c) 2006-2020 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
+# Copyright (c) 2006-2021 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -34,10 +34,15 @@
EPUB_OPTIONS = ENV['REVIEW_EPUB_OPTIONS'] || ''
WEB_OPTIONS = ENV['REVIEW_WEB_OPTIONS'] || ''
IDGXML_OPTIONS = ENV['REVIEW_IDGXML_OPTIONS'] || ''
TEXT_OPTIONS = ENV['REVIEW_TEXT_OPTIONS'] || ''
+REVIEW_VSCLI = ENV['REVIEW_VSCLI'] || 'vivliostyle'
+REVIEW_VSCLI_USESANDBOX = ENV['REVIEW_VSCLI_USESANDBOX'] ? '' : '--no-sandbox'
+REVIEW_VSCLI_PDF = ENV['REVIEW_VSCLI_PDF'] || BOOK_PDF
+REVIEW_VSCLI_OPTIONS = ENV['REVIEW_VSCLI_OPTIONS'] || ''
+
def build(mode, chapter)
sh("review-compile --target=#{mode} --footnotetext --stylesheet=style.css #{chapter} > tmp")
mode_ext = { 'html' => 'html', 'latex' => 'tex', 'idgxml' => 'xml', 'top' => 'txt', 'plaintext' => 'txt' }
FileUtils.mv('tmp', chapter.gsub(/re\z/, mode_ext[mode]))
end
@@ -122,7 +127,18 @@
end
file IDGXMLROOT => SRC do
FileUtils.rm_rf([IDGXMLROOT])
end
+
+desc 'run vivliostyle'
+task 'vivliostyle:preview': BOOK_EPUB do
+ sh "#{REVIEW_VSCLI} preview #{REVIEW_VSCLI_USESANDBOX} #{REVIEW_VSCLI_OPTIONS} #{BOOK_EPUB}"
+end
+
+task 'vivliostyle:build': BOOK_EPUB do
+ sh "#{REVIEW_VSCLI} build #{REVIEW_VSCLI_USESANDBOX} #{REVIEW_VSCLI_OPTIONS} -o #{REVIEW_VSCLI_PDF} #{BOOK_EPUB}"
+end
+
+task vivliostyle: 'vivliostyle:build'
CLEAN.include([BOOK, BOOK_PDF, BOOK_EPUB, BOOK + '-pdf', BOOK + '-epub', WEBROOT, 'images/_review_math', 'images/_review_math_text', TEXTROOT, IDGXMLROOT])