Class: Asciidoctor::Diagram::LilypondConverter
- Inherits:
-
Object
- Object
- Asciidoctor::Diagram::LilypondConverter
- Includes:
- CliGenerator, DiagramConverter
- Defined in:
- lib/asciidoctor-diagram/lilypond/converter.rb
Constant Summary collapse
- EXTRA_PATH =
[]
Instance Method Summary collapse
- #collect_options(source) ⇒ Object
- #convert(source, format, options) ⇒ Object
- #supported_formats ⇒ Object
Methods included from CliGenerator
#generate_file, #generate_file_stdout, #generate_stdin, #generate_stdin_file, #generate_stdin_stdout
Methods included from DiagramConverter
#native_scaling?, #wrap_source
Instance Method Details
#collect_options(source) ⇒ Object
27 28 29 30 31 |
# File 'lib/asciidoctor-diagram/lilypond/converter.rb', line 27 def (source) { :resolution => source.attr('resolution') } end |
#convert(source, format, options) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/asciidoctor-diagram/lilypond/converter.rb', line 33 def convert(source, format, ) code = <<-EOF \\paper{ oddFooterMarkup=##f oddHeaderMarkup=##f bookTitleMarkup=##f scoreTitleMarkup=##f } EOF code << source.to_s resolution = [: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 ⇒ Object
23 24 25 |
# File 'lib/asciidoctor-diagram/lilypond/converter.rb', line 23 def supported_formats [:png, :pdf] end |