1 # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
3 # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4 # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
6 libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
7 $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
13 def format(parsetree, title = 'Song-Sheet')
16 <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
18 <meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
19 <title>#{escape(title)}</title>
20 <meta http-equiv='content-language' content='en' />
42 <h1>#{escape(title)}</h1>
46 parsetree.each do |section|
47 output << "\t"*3 << "<p>\n"
48 section.each do |line|
52 regex = /(?:\[(.*?)\])/
57 output << escape(token)
59 token = ' ' if token =~ /^\s$/
60 output << "<span class='chord'><span><span class='brackets'>[</span>#{escape(last_chord)}<span class='brackets'>]</span></span>#{escape(token)}</span>"
67 output.gsub! %r|<br />\Z|, ''
68 output << "\t"*3 << "</p>\n"
70 return output << <<-'HERE'
80 return CGI.escapeHTML(str)