def convert
plcode = ''
if @options[:header_text] then
@options[:header_text].each_line do |line|
line.sub!(/\n/, '\n')
line.gsub!(/'/, '\\\\\'')
plcode << ":print('#{line}')\n"
end
end
if @options[:header_plcode] then
plcode << @options[:header_plcode]
end
text = ''
while fv = _fetch() do
text << fv.head_text
if fv.directive_name then
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})\n"
s << body.gsub(/^/, ' ')
s << ":end\n"
s << "\n"
end
plcode = s + plcode
if @options[:footer_text] then
@options[:footer_text].each_line do |line|
line.sub!(/\n/, '\n')
line.gsub!(/'/, '\\\\\'')
plcode << ":print('#{line}')\n"
end
end
if @options[:footer_plcode] then
plcode << @options[:footer_plcode]
end
return plcode
end