class Asciidoctor::Diagram::LilypondConverter

@private

Constants

EXTRA_PATH

Public Instance Methods

collect_options(source) click to toggle source
# File lib/asciidoctor-diagram/lilypond/converter.rb, line 27
def collect_options(source)
  {
      :resolution => source.attr('resolution')
  }
end
convert(source, format, options) click to toggle source
# File lib/asciidoctor-diagram/lilypond/converter.rb, line 33
      def convert(source, format, options)
        code = <<-EOF
\\paper{
  oddFooterMarkup=##f
  oddHeaderMarkup=##f
  bookTitleMarkup=##f
  scoreTitleMarkup=##f
}

        EOF
        code << source.to_s

        resolution = options[:resolution]

        generate_stdin(source.find_command('lilypond', :path => EXTRA_PATH), format.to_s, code) do |tool_path, output_path|
          args = [tool_path, '-daux-files=#f', '-dbackend=eps', '-dno-gs-load-fonts', '-dinclude-eps-fonts', '-o', Platform.native_path(output_path), '-f', format.to_s]

          args << "-dcrop=#t"
          args << "-dresolution=#{resolution}" if resolution
          args << "-dpixmap-format=pngalpha" if format == :png

          args << '-'

          {
              :args => args,
              :out_file => "#{output_path}.cropped.#{format.to_s}",
              :chdir => source.base_dir
          }
        end        
      end
supported_formats() click to toggle source
# File lib/asciidoctor-diagram/lilypond/converter.rb, line 23
def supported_formats
  [:png, :pdf]
end