class Eggshell::Bundles::Basic::BasicFormatHandlers
Constants
- ESCAPE_MAP_HTML
- TAG_MAP
Public Class Methods
new()
click to toggle source
# File lib/eggshell/bundles/basics.rb, line 565 def initialize @fmt_delimeters = [ ['[*', '*]'], # bold ['[**', '**]'], # strong ['[/', '/]'], # italic ['[//', '//]'], # emphasis ['[__', '__]'], # underline ['[-', '-]'], # strike ['[^', '^]'], # superscript ['[_', '_]'], # subscript, ['[[', ']]'], # span ['[~', '~]'], # anchor ['[!', '!]'], # image ['%{', '}%', true], # entity expansion ['`', '`', '%{'], # code, backtick ['{{', '}}', '%{'] # code, normal ] end
Public Instance Methods
format(tag, str)
click to toggle source
# File lib/eggshell/bundles/basics.rb, line 584 def format(tag, str) if tag == '{{' || tag == '`' cls = tag == '{{' ? 'normal' : 'backtick' return "<code class='#{cls}'>#{str}</code>" elsif tag == '%{' # @todo find a way to expand char map and handle unmapped strings at runtime buff = '' str.split(' ').each do |part| c = ESCAPE_MAP_HTML[part] buff += c || part end return buff end st = tag[0..1] args = parse_args(str.strip) akey = BH::BlockParams::ATTRIBUTES atts = {akey => {}} atts[akey].update(args.pop) tagname = nil tagopen = true text = args[0] if tag == '[~' link, text = args link = '' if !link text = '' if !text if text.strip == '' text = link end atts[akey]['href'] = link if link != '' tagname = 'a' elsif tag == '[!' link, alt = args link = '' if !link alt = '' if !alt atts[akey]['src'] = link if link != '' atts[akey]['alt'] = alt if alt != '' tagname = 'img' tagopen = false else tagname = TAG_MAP[tag] end return create_tag(tagname, atts, tagopen, text) end