lib/md2man/rakefile.rb in md2man-5.0.3 vs lib/md2man/rakefile.rb in md2man-5.1.0
- old
+ new
@@ -65,10 +65,16 @@
if html_file_body =~ %r{<p>.+?\s-\s+(.+?)</p>}
$1.gsub(/<.+?>/, '') # strip HTML tags
end
end
+build_html_title = lambda do |title, info|
+ # fallback to adding directory name for standalone titles, such as "README"
+ # and "man/index", so that users know what project those manuals belong to
+ [title, info || Dir.pwd.pathmap('%n')].join(' — ')
+end
+
directory 'man'
file 'man/index.html' => ['man'] + webs do |t|
buffer = ['<div class="container-fluid">']
webs.
@@ -84,17 +90,23 @@
end
end
buffer << '</div>'
content = buffer.join
- title = t.name.pathmap('%X')
+ title = build_html_title.call(t.name.pathmap('%X'), nil)
output = wrap_html_template.call(title, content, nil)
File.open(t.name, 'w') {|f| f << output }
end
file 'man/style.css' => ['man', __FILE__.pathmap('%X/style.css')] do |t|
- cp t.prerequisites.last, t.name if t.needed?
+ cp t.prerequisites.last, t.name
+
+ # add syntax highlighting theme
+ File.open(t.name, 'a') do |css|
+ require 'rouge'
+ css << Rouge::Themes::Github.render
+ end
end
mkds.zip(webs).each do |src, dst|
render_file_task.call src, dst, lambda {|input|
require 'md2man/html/engine'
@@ -104,10 +116,10 @@
$& if webs.include? 'man' + $1
end
name = parse_manpage_name.call(dst)
info = parse_manpage_info.call(output)
- title = [name, info].compact.join(' — ')
+ title = build_html_title.call(name, info)
subdir = dst.pathmap('%d').sub('man/', '')
ascent = '../' * (dst.count('/') - 1)
content = [
'<div class="navbar">',