/usr/bin/hikidoc is in ruby-hikidoc 0.0.6-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #!/usr/bin/env ruby
require 'hikidoc'
require 'optparse'
require 'erb'
HTML_TEMPLATE = <<EOS
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title><%= title %></title>
</head>
<body>
<%= body %>
</body>
</html>
EOS
options = {}
format_options = {}
ARGV.options do |opts|
opts.banner = "Usage: #$0 [OPTIONS] FILE"
opts.on('-f', '--fragment',
'Output HTML fragments only') do
options[:fragment] = true
end
opts.on('-t', '--template=TEMPLATE',
'Specify a HTML template file') do |template|
options[:template] = template
end
opts.on('--no-wikiname', 'Disable WikiName link') do
format_options[:use_wiki_name] = false
end
opts.parse!
end
case ARGV.size
when 0
title, text = '-', $stdin.read
when 1
title, text = ARGV[0], File.read(ARGV[0])
else
usage
end
body = HikiDoc.to_html(text, format_options)
def result(erb, title, body, text)
erb.result(binding)
end
if options[:fragment]
puts(body)
else
template = options[:template]
if template
source = File.read(template)
else
source = HTML_TEMPLATE
end
erb = ERB.new(source)
erb.filename = template
puts(result(erb, title, body, text))
end
|