class Asciidoctor::Diagram::TikZConverter
@private
Public Instance Methods
collect_options(source)
click to toggle source
# File lib/asciidoctor-diagram/tikz/converter.rb, line 16 def collect_options(source) { :preamble => source.opt('preamble') || source.attr('preamble') == 'true' } end
convert(source, format, options)
click to toggle source
# File lib/asciidoctor-diagram/tikz/converter.rb, line 22 def convert(source, format, options) latexpath = source.find_command('pdflatex') if format == :svg svgpath = source.find_command('pdf2svg') else svgpath = nil end if options[:preamble] preamble, body = source.to_s.split(/^~~~~$/, 2) unless body body = preamble preamble = '' end else preamble = '' body = source.to_s end latex = <<'END' \documentclass[border=2bp, tikz]{standalone} \usepackage{tikz} END latex << preamble latex << <<'END' \begin{document} \begingroup \tikzset{every picture/.style={scale=1}} END latex << body latex << <<'END' \endgroup \end{document} END pdf = generate_file(latexpath, 'tex', 'pdf', latex) do |tool_path, input_path, output_path| { :args => [tool_path, '-shell-escape', '-file-line-error', '-interaction=nonstopmode', '-output-directory', Platform.native_path(File.dirname(output_path)), Platform.native_path(input_path)], :out_file => "#{File.dirname(input_path)}/#{File.basename(input_path, '.*')}.pdf" } end if svgpath generate_file(svgpath, 'pdf', 'svg', pdf) do |tool_path, input_path, output_path| { :args => [tool_path, Platform.native_path(input_path), Platform.native_path(output_path)], :chdir => source.base_dir } end else pdf end end
supported_formats()
click to toggle source
# File lib/asciidoctor-diagram/tikz/converter.rb, line 12 def supported_formats [:pdf, :svg] end