Method: MaRuKu::Out::Latex#array_to_latex

Defined in:
lib/maruku/output/to_latex.rb

#array_to_latex(array, join_char = '') ⇒ Object



554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/maruku/output/to_latex.rb', line 554

def array_to_latex(array, join_char='')
	e = []
	array.each do |c|
		method = c.kind_of?(MDElement) ? 
		   "to_latex_#{c.node_type}" : "to_latex"
		
		if not c.respond_to?(method)
	#		raise "Object does not answer to #{method}: #{c.class} #{c.inspect[0,100]}"
			next
		end
		
		h =  c.send(method)
		
		if h.nil?
			raise "Nil html for #{c.inspect} created with method #{method}"
		end
		
		if h.kind_of?Array
			e = e + h
		else
			e << h
		end
	end
	
	# puts a space after commands if needed
	# e.each_index do |i|
	# 	if e[i] =~ /\\\w+\s*$/ # command
	# 		if (s=e[i+1]) && s[0] == ?\ # space
	# 			e[i]  = e[i] + "\\ "
	# 		end
	# 	end
	# end
	
	e.join(join_char)
end