Class: Asciidoctor::Diagram::AsciiToSvgConverter

Inherits:
Object
  • Object
show all
Includes:
CliGenerator, DiagramConverter
Defined in:
lib/asciidoctor-diagram/a2s/converter.rb

Instance Method Summary collapse

Methods included from CliGenerator

#generate_file, #generate_file_stdout, #generate_stdin, #generate_stdin_file, #generate_stdin_stdout

Methods included from DiagramConverter

#wrap_source

Instance Method Details

#collect_options(source) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/asciidoctor-diagram/a2s/converter.rb', line 16

def collect_options(source)
  options = {}
  options[:sx] = source.attr('scalex')
  options[:sy] = source.attr('scaley')
  options[:scale] = source.attr('scale')
  options[:noblur] = source.attr('noblur') == 'true'
  options[:font] = source.attr('fontfamily')
  options
end

#convert(source, format, options) ⇒ Object



26
27
28
29
30
31
32
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
# File 'lib/asciidoctor-diagram/a2s/converter.rb', line 26

def convert(source, format, options)
  return source.to_s if format == :txt

  sx = options[:sx]
  sy = options[:sy]
  scale = options[:scale]
  noblur = options[:noblur]
  font = options[:font]

  generate_stdin(source.find_command('a2s'), format.to_s, source.to_s) do |tool_path, output_path|
    args = [tool_path, '-o', Platform.native_path(output_path)]

    if sx && sy
      args << '-s' << "#{sx},#{sy}"
    elsif scale
      args << '-s' << "#{scale},#{scale}"
    end

    if noblur
      args << '-b'
    end

    if font
      args << '-f' << font
    end

    {
      :args => args,
      :chdir => source.base_dir
    }
  end
end

#native_scaling?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/asciidoctor-diagram/a2s/converter.rb', line 59

def native_scaling?
  true
end

#supported_formatsObject



12
13
14
# File 'lib/asciidoctor-diagram/a2s/converter.rb', line 12

def supported_formats
  [:svg, :txt]
end