module Webgen::Tag::Tikz
This tag allows you to create and use complex graphics using the PGF/TikZ library of LaTeX. It uses Webgen::ContentProcessor::Tikz
for doing the hard work.
Public Class Methods
call(tag, body, context)
click to toggle source
Create a graphic (i.e. an HTML img tag) from the commands in the body of the tag.
# File lib/webgen/tag/tikz.rb 12 def self.call(tag, body, context) 13 path = Webgen::Path.append(context.ref_node.parent.alcn, context[:config]['tag.tikz.path']) 14 path = Webgen::Path.new(path) 15 16 add_tikz_options!(path, context) 17 node = context.website.ext.path_handler.create_secondary_nodes(path, body, context.ref_node.alcn).first 18 19 attrs = {'alt' => ''}.merge(context[:config]['tag.tikz.img_attr']).collect do |name, value| 20 "#{name.to_s}=\"#{value}\"" 21 end.sort.unshift('').join(' ') 22 "<img src=\"#{context.dest_node.route_to(node)}\"#{attrs} />" 23 end
Private Class Methods
add_tikz_options!(path, context)
click to toggle source
Add all needed options for Webgen::ContentProcessor::Tikz
to the given path.
# File lib/webgen/tag/tikz.rb 26 def self.add_tikz_options!(path, context) 27 %w[content_processor.tikz.resolution content_processor.tikz.transparent 28 content_processor.tikz.libraries content_processor.tikz.opts 29 content_processor.tikz.template].each do |opt| 30 path.meta_info[opt] = context[:config][opt] 31 end 32 path.meta_info['pipeline'] = 'tikz' 33 path.meta_info['handler'] = 'copy' 34 end