def convert
plcode = ''
if @toppings[:header_text]
@toppings[:header_text].each_line do |line|
plcode << ":print(\"#{_escape(line)}\")#{@newline}"
end
end
if @toppings[:header_plcode]
plcode << @toppings[:header_plcode]
end
text = ''
while fv = _fetch() do
text << fv.head_text
if fv.directive_name
plcode << _print_text(text)
text = ''
plcode << _convert_element(fv)
else
text << fv.tag_str()
end
end
plcode << _print_text(text)
rest = @input
plcode << _print_text(rest) if ! rest.empty?
s = ''
_each_macro do |name, body|
s << ":macro(#{name})" << @newline
s << body.gsub(/^/, ' ')
s << ":end" << @newline
s << @newline
end
plcode = s + plcode
if @toppings[:footer_text]
@toppings[:footer_text].each_line do |line|
plcode << ":print('#{_escape(line)}')#{@newline}"
end
end
if @toppings[:footer_plcode]
plcode << @toppings[:footer_plcode]
end
return plcode
end