Sha256: 05c41b32d4a0475af70101e055f69b2a769c41aa360303a3acf15c17f631f37c

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

module Jekyll
  module Diagrams
    class VegaBlock < Block
      CONFIGURATIONS = %w( scale )

      def render_svg(code, config)
        code = render_with_stdin_stdout('vl2vg', code) if block_name == 'vegalite'
        command = build_command(config)

        render_with_stdin_stdout(command, code)
      end

      def build_command(config)
        command = 'vg2svg'

        CONFIGURATIONS.each do |conf|
          command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
        end

        command
      end
    end
  end
end

%i(vega vegalite).each do |tag|
  Liquid::Template.register_tag(tag, Jekyll::Diagrams::VegaBlock)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-diagrams-0.9.1 lib/jekyll-diagrams/vega.rb