md2man 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.markdown +18 -0
- data/README.markdown +49 -47
- data/Rakefile +1 -0
- data/bin/md2man +1 -1
- data/bin/md2man-html +1 -1
- data/lib/md2man/rakefile.rb +112 -19
- data/lib/md2man/version.rb +1 -1
- data/man/man1/md2man-html.1 +1 -1
- data/man/man1/md2man.1 +1 -1
- metadata +3 -3
data/HISTORY.markdown
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## Version 1.4.2 (2013-02-24)
|
2
|
+
|
3
|
+
Patch:
|
4
|
+
|
5
|
+
* The `md2man:web` task from `md2man/rakefile` now:
|
6
|
+
|
7
|
+
* emits valid HTML5 with helpful HTML page titles
|
8
|
+
|
9
|
+
* uses Twitter Bootstrap styling for HTML man pages
|
10
|
+
|
11
|
+
* emits only ONE index page for all HTML man pages
|
12
|
+
|
13
|
+
Other:
|
14
|
+
|
15
|
+
* README: better organize the subsections of "Usage"
|
16
|
+
|
17
|
+
* include md2man rake tasks in developer's rakefile
|
18
|
+
|
1
19
|
## Version 1.4.1 (2013-02-23)
|
2
20
|
|
3
21
|
Patch:
|
data/README.markdown
CHANGED
@@ -45,15 +45,36 @@ It issues a warning when it encounters these instead. Patches are welcome!
|
|
45
45
|
cd md2man
|
46
46
|
bundle install
|
47
47
|
bundle exec md2man --help # run it directly
|
48
|
-
bundle exec rake
|
48
|
+
bundle exec rake --tasks # packaging tasks
|
49
49
|
|
50
|
-
## Usage
|
50
|
+
## Usage
|
51
51
|
|
52
|
-
###
|
52
|
+
### Document format
|
53
|
+
|
54
|
+
md2man extends [Markdown] syntax in the following ways, as provisioned in the
|
55
|
+
`Md2Man::Document` module and defined in its derivative `Md2Man::Roff` module:
|
56
|
+
|
57
|
+
* Paragraphs whose lines are all uniformly indented by two spaces are
|
58
|
+
considered to be "indented paragraphs". They are unindented accordingly
|
59
|
+
before emission as `.IP` in the [roff] output.
|
60
|
+
|
61
|
+
* Paragraphs whose subsequent lines (all except the first) are uniformly
|
62
|
+
indented by two spaces are considered to be a "tagged paragraphs". They
|
63
|
+
are unindented accordingly before emission as `.TP` in the [roff] output.
|
64
|
+
|
65
|
+
md2man extends [Markdown] semantics in the following ways:
|
66
|
+
|
67
|
+
* The first top-level heading (H1) found in the document is emitted as `.TH`
|
68
|
+
in the roff(7) output to define the UNIX manual page's header and footer.
|
69
|
+
Any subsequent top-level headings (H1) are treated as second-level (H2).
|
70
|
+
|
71
|
+
### For [roff] output
|
72
|
+
|
73
|
+
#### At the command line
|
53
74
|
|
54
75
|
md2man --help
|
55
76
|
|
56
|
-
|
77
|
+
#### Inside a Ruby script
|
57
78
|
|
58
79
|
Use the default renderer:
|
59
80
|
|
@@ -91,13 +112,34 @@ Mix-in your own renderer:
|
|
91
112
|
engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
|
92
113
|
your_roff_output = engine.render(your_markdown_input)
|
93
114
|
|
94
|
-
|
115
|
+
#### Pre-building man pages
|
116
|
+
|
117
|
+
Add the following lines to your gemspec:
|
118
|
+
|
119
|
+
s.files += Dir['man/man?/*.?']
|
120
|
+
s.add_development_dependency 'md2man', '~> 1.4'
|
121
|
+
|
122
|
+
Add the following line to your Rakefile:
|
123
|
+
|
124
|
+
require 'md2man/rakefile'
|
125
|
+
|
126
|
+
You now have a `rake md2man` task that builds manual pages from Markdown files
|
127
|
+
(with ".markdown", ".mkd", or ".md" extension) inside `man/man*/` directories.
|
128
|
+
There are also sub-tasks to build manual pages individually as [roff] or HTML.
|
129
|
+
|
130
|
+
If you're using Bundler, this task also hooks into Bundler's gem packaging
|
131
|
+
tasks and ensures that your manual pages are built for packaging into a gem:
|
132
|
+
|
133
|
+
bundle exec rake build
|
134
|
+
gem spec pkg/*.gem | fgrep man/man
|
135
|
+
|
136
|
+
### For HTML output
|
95
137
|
|
96
|
-
|
138
|
+
#### At the command line
|
97
139
|
|
98
140
|
md2man-html --help
|
99
141
|
|
100
|
-
|
142
|
+
#### Inside a Ruby script
|
101
143
|
|
102
144
|
Use the default renderer:
|
103
145
|
|
@@ -135,46 +177,6 @@ Mix-in your own renderer:
|
|
135
177
|
engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
|
136
178
|
your_html_output = engine.render(your_markdown_input)
|
137
179
|
|
138
|
-
### Document format
|
139
|
-
|
140
|
-
md2man extends [Markdown] syntax in the following ways, as provisioned in the
|
141
|
-
`Md2Man::Document` module and defined in its derivative `Md2Man::Roff` module:
|
142
|
-
|
143
|
-
* Paragraphs whose lines are all uniformly indented by two spaces are
|
144
|
-
considered to be "indented paragraphs". They are unindented accordingly
|
145
|
-
before emission as `.IP` in the [roff] output.
|
146
|
-
|
147
|
-
* Paragraphs whose subsequent lines (all except the first) are uniformly
|
148
|
-
indented by two spaces are considered to be a "tagged paragraphs". They
|
149
|
-
are unindented accordingly before emission as `.TP` in the [roff] output.
|
150
|
-
|
151
|
-
md2man extends [Markdown] semantics in the following ways:
|
152
|
-
|
153
|
-
* The first top-level heading (H1) found in the document is emitted as `.TH`
|
154
|
-
in the roff(7) output to define the UNIX manual page's header and footer.
|
155
|
-
Any subsequent top-level headings (H1) are treated as second-level (H2).
|
156
|
-
|
157
|
-
### Pre-building man pages
|
158
|
-
|
159
|
-
Add the following lines to your gemspec:
|
160
|
-
|
161
|
-
s.files += Dir['man/man?/*.?']
|
162
|
-
s.add_development_dependency 'md2man', '~> 1.4'
|
163
|
-
|
164
|
-
Add the following line to your Rakefile:
|
165
|
-
|
166
|
-
require 'md2man/rakefile'
|
167
|
-
|
168
|
-
You now have a `rake md2man` task that builds manual pages from Markdown files
|
169
|
-
(with ".markdown", ".mkd", or ".md" extension) inside `man/man*/` directories.
|
170
|
-
There are also sub-tasks to build manual pages individually as [roff] or HTML.
|
171
|
-
|
172
|
-
If you're using Bundler, this task also hooks into Bundler's gem packaging
|
173
|
-
tasks and ensures that your manual pages are built for packaging into a gem:
|
174
|
-
|
175
|
-
bundle exec rake build
|
176
|
-
gem spec pkg/*.gem | fgrep man/man
|
177
|
-
|
178
180
|
## License
|
179
181
|
|
180
182
|
Released under the ISC license. See the LICENSE file for details.
|
data/Rakefile
CHANGED
data/bin/md2man
CHANGED
data/bin/md2man-html
CHANGED
data/lib/md2man/rakefile.rb
CHANGED
@@ -40,34 +40,127 @@ desc 'Build HTML manual pages from Markdown files in man/.'
|
|
40
40
|
task 'md2man:web' => 'man/index.html'
|
41
41
|
#-----------------------------------------------------------------------------
|
42
42
|
|
43
|
+
wrap_html_template = lambda do |title, content|
|
44
|
+
<<WRAP_HTML_TEMPLATE
|
45
|
+
<!DOCTYPE html>
|
46
|
+
<html>
|
47
|
+
<head>
|
48
|
+
<meta charset="utf-8" />
|
49
|
+
<title>#{title}</title>
|
50
|
+
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
51
|
+
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
|
52
|
+
<style type="text/css">
|
53
|
+
@media all {
|
54
|
+
.manpage h1 {
|
55
|
+
font-weight: normal;
|
56
|
+
font-size: smaller;
|
57
|
+
text-align: right;
|
58
|
+
}
|
59
|
+
.manpage h2,
|
60
|
+
.manpage h3,
|
61
|
+
.manpage h4,
|
62
|
+
.manpage h5,
|
63
|
+
.manpage h6 {
|
64
|
+
margin-top: 1em;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
@media screen {
|
68
|
+
.manpage {
|
69
|
+
font-family: monospace;
|
70
|
+
max-width: 78ex;
|
71
|
+
}
|
72
|
+
.manpage h1 {
|
73
|
+
margin-top: -5em;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
@media print {
|
78
|
+
.navbar {
|
79
|
+
display: none;
|
80
|
+
}
|
81
|
+
|
82
|
+
/* improve readability of revealed hyperlink URLs */
|
83
|
+
a:after {
|
84
|
+
font-family: monospace;
|
85
|
+
}
|
86
|
+
|
87
|
+
/* internal links and manual page cross-references */
|
88
|
+
a[href^='#'], a[href^='../man'] {
|
89
|
+
color: inherit;
|
90
|
+
font-weight: bolder;
|
91
|
+
text-decoration: none;
|
92
|
+
}
|
93
|
+
|
94
|
+
/* undo bootstrap's revealing of those hyperlinks */
|
95
|
+
a[href^='#']:after, a[href^='../man']:after {
|
96
|
+
content: none;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
</style>
|
100
|
+
</head>
|
101
|
+
<body>#{content}</body>
|
102
|
+
</html>
|
103
|
+
WRAP_HTML_TEMPLATE
|
104
|
+
end
|
105
|
+
|
106
|
+
parse_manpage_name = lambda do |html_file_name|
|
107
|
+
html_file_name.pathmap('%n').sub(/\.(.+)$/, '(\1)')
|
108
|
+
end
|
109
|
+
|
110
|
+
parse_manpage_info = lambda do |html_file_body|
|
111
|
+
html_file_body.scan(%r{<h2.*?>NAME</h2>(.+?)<h2}m).flatten.first.
|
112
|
+
to_s.split(/\s+-\s+/, 2).last.to_s.gsub(/<.+?>/, '') # strip HTML
|
113
|
+
end
|
114
|
+
|
43
115
|
file 'man/index.html' => webs do |t|
|
44
|
-
|
45
|
-
|
46
|
-
subdir = dir.
|
47
|
-
|
116
|
+
buffer = ['<div class="container-fluid">']
|
117
|
+
webs.group_by {|web| web.pathmap('%d') }.each do |dir, dir_webs|
|
118
|
+
subdir = dir.sub('man/', '')
|
119
|
+
buffer << %{<h2 id="#{subdir}">#{subdir}</h2>}
|
120
|
+
|
48
121
|
dir_webs.each do |web|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
output << "<dl><dt>#{link}</dt><dd>#{info}</dd></dl>"
|
54
|
-
end
|
55
|
-
File.open("#{dir}/index.html", 'w') do |f|
|
56
|
-
f << %{<meta http-equiv="refresh" content="0;url=../index.html##{subdir}"/>}
|
122
|
+
name = parse_manpage_name.call(web)
|
123
|
+
info = parse_manpage_info.call(File.read(web))
|
124
|
+
link = %{<a href="#{subdir}/#{web.pathmap('%f')}">#{name}</a>}
|
125
|
+
buffer << %{<dl class="dl-horizontal"><dt>#{link}</dt><dd>#{info}</dd></dl>}
|
57
126
|
end
|
58
127
|
end
|
59
|
-
|
128
|
+
buffer << '</div>'
|
129
|
+
content = buffer.join
|
130
|
+
|
131
|
+
title = t.name.pathmap('%X')
|
132
|
+
output = wrap_html_template.call(title, content)
|
133
|
+
File.open(t.name, 'w') {|f| f << output }
|
60
134
|
end
|
61
135
|
|
62
136
|
mkds.zip(webs).each do |src, dst|
|
63
137
|
render_file_task.call src, dst, lambda {|input|
|
64
138
|
require 'md2man/html/engine'
|
65
139
|
output = Md2Man::HTML::ENGINE.render(input)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
140
|
+
|
141
|
+
name = parse_manpage_name.call(dst)
|
142
|
+
info = parse_manpage_info.call(output)
|
143
|
+
title = [name, info].join(' — ')
|
144
|
+
|
145
|
+
subdir = dst.pathmap('%d').sub('man/', '')
|
146
|
+
ascend = '../' * subdir.count('/').next
|
147
|
+
content = [
|
148
|
+
'<div class="navbar">',
|
149
|
+
'<div class="navbar-inner">',
|
150
|
+
'<span class="brand">',
|
151
|
+
%{<a href="#{ascend}index.html##{subdir}">#{subdir}</a>},
|
152
|
+
'/',
|
153
|
+
dst.pathmap('%n'),
|
154
|
+
'</span>',
|
155
|
+
'</div>',
|
156
|
+
'</div>',
|
157
|
+
'<div class="container-fluid">',
|
158
|
+
'<div class="manpage">',
|
159
|
+
output,
|
160
|
+
'</div>',
|
161
|
+
'</div>',
|
162
|
+
].join
|
163
|
+
|
164
|
+
wrap_html_template.call title, content
|
72
165
|
}
|
73
166
|
end
|
data/lib/md2man/version.rb
CHANGED
data/man/man1/md2man-html.1
CHANGED
data/man/man1/md2man.1
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: md2man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: binman
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
segments:
|
130
130
|
- 0
|
131
|
-
hash:
|
131
|
+
hash: -4385989232300827218
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
134
|
rubygems_version: 1.8.23
|