| 1 |
Bundler.require(:default) |
| 2 |
|
| 3 |
if !File.exist?('../../target/asciidoc-preview') |
| 4 |
Dir.mkdir '../../target/asciidoc-preview' |
| 5 |
end |
| 6 |
guard 'shell' do |
| 7 |
watch(/.*\.asciidoc$/) {|m| |
| 8 |
doc_file_name = m[0].split('/')[1] |
| 9 |
html_file_name = doc_file_name.gsub(/asciidoc/, 'html') |
| 10 |
html = Asciidoctor.convert_file(m[0], :header_footer => true) |
| 11 |
File.open("../../target/asciidoc-preview/#{html_file_name}", 'w') { |file| file.write("#{html.render}") } |
| 12 |
# not sure why the file also gets created in the source directory!? |
| 13 |
if File.exist?("asciidoc/#{html_file_name}") |
| 14 |
File.delete("asciidoc/#{html_file_name}") |
| 15 |
end |
| 16 |
} |
| 17 |
end |
| 18 |
|
| 19 |
|