Class: Eggshell::Bundles::Basics::InlineMacros
- Inherits:
-
Object
- Object
- Eggshell::Bundles::Basics::InlineMacros
show all
- Includes:
- MacroHandler
- Defined in:
- lib/eggshell/bundles/basics-old.rb
Constant Summary
collapse
- HASH_FMT_DECORATORS =
{
'[*' => '<b>',
'[**' => '<strong>',
'[_' => '<i>',
'[__' => '<em>',
'*]'=> '</b>',
'**]' => '</strong>',
'_]' => '</i>',
'__]' => '</em>',
'[-_' => '<u>',
'_-]' => '</u>',
'[-' => '<strike>',
'-]' => '</strike>'
}.freeze
MacroHandler::CHAIN_CONTINUE, MacroHandler::CHAIN_END, MacroHandler::CHAIN_NONE, MacroHandler::CHAIN_START, MacroHandler::COLLECT_NORMAL, MacroHandler::COLLECT_RAW, MacroHandler::COLLECT_RAW_MACRO
Instance Method Summary
collapse
#chain_type, #collection_type
Constructor Details
Returns a new instance of InlineMacros.
433
434
435
436
437
|
# File 'lib/eggshell/bundles/basics-old.rb', line 433
def initialize
@capvar = nil
@collbuff = nil
@depth = 0
end
|
Instance Method Details
#process(buffer, macname, args, lines, depth) ⇒ Object
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
|
# 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 = []) ⇒ Object
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
# 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)
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) ⇒ Object
454
455
456
457
|
# File 'lib/eggshell/bundles/basics-old.rb', line 454
def set_processor(eggshell)
@proc = eggshell
@proc.register_macro(self, '[!', '[~', '[^', '[.', '[*', '[**', '[/', '[//', '[_', '[-')
end
|