require 'cgi' require 'shellwords' require 'md2man/document' module Md2Man::HTML include Md2Man::Document #--------------------------------------------------------------------------- # document-level processing #--------------------------------------------------------------------------- def preprocess document @h1_seen = false @seen_count_by_id = Hash.new {|h,k| h[k] = 0 } super end #--------------------------------------------------------------------------- # block-level processing #--------------------------------------------------------------------------- def normal_paragraph text "
#{text}
" end def tagged_paragraph text head, *body = text.lines.to_a "#{CGI.escape_html super}
\n"
end
#---------------------------------------------------------------------------
# span-level processing
#---------------------------------------------------------------------------
def codespan code
"#{CGI.escape_html super}
"
end
def reference input_match, output_match
if output_match.pre_match =~ /<[^>]*\z/
input_match.to_s
else
url = reference_url(input_match[:page], input_match[:section])
%{#{input_match}}
end + output_match[:addendum].to_s
end
# You can override this in a derived class to compute URLs as you like!
def reference_url page, section
"../man#{section}/#{page}.#{section}.html"
end
end