class Eggshell::Bundles::Basics::InlineMacros
Constants
- HASH_FMT_DECORATORS
Public Class Methods
new()
click to toggle source
# File lib/eggshell/bundles/basics-old.rb, line 433 def initialize @capvar = nil @collbuff = nil @depth = 0 end
Public Instance Methods
process(buffer, macname, args, lines, depth)
click to toggle source
# File lib/eggshell/bundles/basics-old.rb, line 459 def process(buffer, macname, args, lines, depth) prefix = macname[0..1] textpart = args.shift tag = nil case prefix when '[^' tag = 'sup' when '[.' tag = 'sub' when '[*' tag = macname == '[**' ? 'strong' : 'b' when '[/' tag = macname == '[//' ? 'em' : 'i' when '[-' tag = 'strike' when '[_' tag = 'u' when '[~' tag = 'a' link = textpart ? textpart.strip : textpart text = nil if link == '' text = '' elsif link.index('; ') == nil textpart = link args.unshift('href:'+ link); else textpart, link = link.split('; ') link = '' if !link args.unshift('href:'+link) end when '[!' tag = 'img' args.unshift('src:'+textpart) textpart = nil end buffer << restructure_html(tag, textpart ? textpart.strip : textpart, args) end
restructure_html(tag, text, attributes = [])
click to toggle source
# File lib/eggshell/bundles/basics-old.rb, line 500 def restructure_html(tag, text, attributes = []) buff = "<#{tag}" attributes.each do |attrib| key, val = attrib.split(':', 2) # @todo html escape? if val buff = "#{buff} #{key}=\"#{val.gsub('\\|', '|')}\"" else buff = "#{buff} #{key}" end end if text == nil buff += ' />' else buff = "#{buff}>#{text}</#{tag}>" end buff end
set_processor(eggshell)
click to toggle source
# File lib/eggshell/bundles/basics-old.rb, line 454 def set_processor(eggshell) @proc = eggshell @proc.register_macro(self, '[!', '[~', '[^', '[.', '[*', '[**', '[/', '[//', '[_', '[-') end