#
# This file is part of kramdown.
#
# kramdown is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#++
#
EOF
desc "Insert/Update copyright notice"
task :update_copyright do
inserted = false
Dir["lib/**/*.rb"].each do |file|
if !File.read(file).start_with?(CODING_LINE + COPYRIGHT)
inserted = true
puts "Updating file #{file}"
old = File.read(file)
if !(result = old.gsub!(/\A#{Regexp.escape(CODING_LINE)}#\n#--.*?\n#\+\+\n#\n/m, CODING_LINE + COPYRIGHT))
old.gsub!(/\A(#{Regexp.escape(CODING_LINE)})?/, CODING_LINE + COPYRIGHT + "\n")
end
File.open(file, 'w+') {|f| f.puts(old)}
end
end
puts "Look through the above mentioned files and correct all problems" if inserted
end
end
task :clobber => ['dev:clobber']
# Helper methods and misc ###################################################################
if defined? Webgen
class OptionsDisplay
include Webgen::Tag::Base
def call(tag, body, context)
param('optionsdisplay.items').collect do |opt|
Kramdown::Options.definitions[opt]
end.collect do |term|
lines = term.desc.split(/\n/)
first = lines.shift
rest = lines[0..-2].collect {|l| " " + l}.join("\n")
"`#{term.name}`\n: #{first}\n#{rest}\n\n"
end.join("\n")
end
end
require 'cgi'
class KDExample
include Webgen::Tag::Base
def call(tag, body, context)
body.strip!
result = ::Kramdown::Document.new(body, :auto_ids => false).to_html
before = "#{CGI::escapeHTML(body)}\n
"
after = "#{CGI::escapeHTML(result)}\n
"
afterhtml = "#{result}
"
"#{before}#{after}#{afterhtml}\n
"
end
end
class KDLink
include Webgen::Tag::Base
def call(tag, body, context)
link = "→ Syntax for #{param('kdlink.part')}"
"#{link}\n
"
end
end
end