375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
# File 'lib/eggshell/bundles/basics.rb', line 375
def process(type, args, lines, out, call_depth = 0)
if type == 'dl'
else
order_stack = []
otype_stack = []
last = nil
first_type = nil
if lines[0] && !lines[0].match(/[-#]/)
line = lines.shift
end
lines.each do |line_obj|
line = nil
indent = 0
if line_obj.is_a?(Eggshell::Line)
line = line_obj.line
indent = line_obj.indent_lvl
else
line = line_obj
end
ltype = line[0] == '-' ? 'ul' : 'ol'
line = line[1..line.length].strip
if order_stack.length == 0
order_stack << create_tag(type, get_block_params(type, args[0]))
otype_stack << type
elsif indent > (otype_stack.length-1) && order_stack.length > 0
last = order_stack[-1]
last = last[0...last.length-5]
order_stack[-1] = last
order_stack << "#{"\t"*indent}<#{ltype}>"
otype_stack << ltype
elsif indent < (otype_stack.length-1)
count = otype_stack.length - 1
while count > indent
ltype = otype_stack.pop
order_stack << "#{"\t"*count}</#{ltype}>\n#{"\t"*(count-1)}</li>"
count -= 1
end
end
order_stack << "#{"\t"*indent}<li>#{line}</li>"
end
d = otype_stack.length
c = 1
otype_stack.reverse.each do |ltype|
ident = d - c
order_stack << "#{"\t" * ident}</#{ltype}>\n#{ident-1 >= 0 ? "\t"*(ident-1) : ''}#{c == d ? '' : "</li>"}"
c += 1
end
out << @eggshell.expand_all(order_stack.join("\n"))
end
end
|