lib/md2man/rakefile.rb in md2man-1.5.1 vs lib/md2man/rakefile.rb in md2man-1.6.0
- old
+ new
@@ -35,77 +35,23 @@
}
end
#-----------------------------------------------------------------------------
desc 'Build HTML manual pages from Markdown files in man/.'
-task 'md2man:web' => 'man/index.html'
+task 'md2man:web' => ['man/index.html', 'man/style.css']
#-----------------------------------------------------------------------------
-wrap_html_template = lambda do |title, content|
+wrap_html_template = lambda do |title, content, ascent|
<<WRAP_HTML_TEMPLATE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="md2man #{Md2Man::VERSION} https://github.com/sunaku/md2man" />
<title>#{title}</title>
+ <link rel="stylesheet" href="#{ascent}style.css"/>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
- <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
- <style type="text/css">
- @media all {
- .manpage h1,
- .manpage h2,
- .manpage h3,
- .manpage h4,
- .manpage h5,
- .manpage h6 {
- margin-top: 1em;
- }
-
- /* deactivate external manual page cross-references */
- a.manpage-reference:not([href]) {
- color: inherit;
- text-decoration: none;
- }
- }
- @media screen {
- .manpage {
- font-family: monospace;
- max-width: 78ex;
- }
-
- .manpage > h1:first-child {
- margin-top: -5em;
- font-weight: normal;
- font-size: smaller;
- text-align: right;
- }
- }
-
- @media print {
- .navbar {
- display: none;
- }
-
- /* improve readability of revealed hyperlink URLs */
- a:after {
- font-family: monospace;
- }
-
- /* internal links and manual page cross-references */
- a[href^='#'], a[href^='../man'] {
- color: inherit;
- font-weight: bolder;
- text-decoration: none;
- }
-
- /* undo bootstrap's revealing of those hyperlinks */
- a[href^='#']:after, a[href^='../man']:after {
- content: none;
- }
- }
- </style>
</head>
<body>#{content}</body>
</html>
WRAP_HTML_TEMPLATE
end
@@ -120,29 +66,31 @@
end
end
file 'man/index.html' => webs do |t|
buffer = ['<div class="container-fluid">']
- webs.sort.group_by {|web| web.pathmap('%d') }.each do |dir, dir_webs|
- subdir = dir.sub('man/', '')
+ webs.sort.group_by {|web| web.pathmap('%d').sub('man/', '') }.each do |subdir, dir_webs|
buffer << %{<h2 id="#{subdir}">#{subdir}</h2>}
-
dir_webs.each do |web|
name = parse_manpage_name.call(web)
info = parse_manpage_info.call(File.read(web))
- link = %{<a href="../#{web}">#{name}</a>}
+ link = %{<a href="#{web.sub('man/', '')}">#{name}</a>}
buffer << %{<dl class="dl-horizontal"><dt>#{link}</dt><dd>#{info}</dd></dl>}
end
end
buffer << '</div>'
content = buffer.join
title = t.name.pathmap('%X')
- output = wrap_html_template.call(title, content)
+ output = wrap_html_template.call(title, content, nil)
File.open(t.name, 'w') {|f| f << output }
end
+file 'man/style.css' => __FILE__.pathmap('%X/style.css') do |t|
+ cp t.prerequisites.first, t.name if t.needed?
+end
+
mkds.zip(webs).each do |src, dst|
render_file_task.call src, dst, lambda {|input|
require 'md2man/html/engine'
output = Md2Man::HTML::ENGINE.render(input).
# deactivate external manual page cross-references
@@ -171,8 +119,8 @@
output,
'</div>',
'</div>',
].join
- wrap_html_template.call title, content
+ wrap_html_template.call title, content, ascent
}
end