Search code examples
rubyguardasciidocasciidoctor

Asciidoctor.renderFile with additional options


I'm using asciidoc with a guard file descibed here.

Given the asciidoctor options: asciidoctor -a icons -a iconsdir /foo -a copycss bar.adoc I want to add those options to the guard file. But I don't know how.

The guard file currently looks like:

require 'asciidoctor'
require 'erb'

guard 'shell' do
  watch(/^ble\.adoc$/) {|m|
    Asciidoctor.render_file(m[0], :in_place => true, :backend => 'html5')
  }
end

guard 'livereload' do
  watch(%r{^.+\.(css|js|html)$})
end

Solution

  • Attributes are just options, essentially you could add an :attributes key to the options you have there and make that another hash:

    Asciidoctor.render_file(m[0], :in_place => true, :backend => 'html5', :attributes => { :icons => true, :copycss => true })

    That should work just fine