md2man 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -112,27 +112,6 @@ Mix-in your own renderer:
112
112
  engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
113
113
  your_roff_output = engine.render(your_markdown_input)
114
114
 
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
115
  ### For HTML output
137
116
 
138
117
  #### At the command line
@@ -177,6 +156,34 @@ Mix-in your own renderer:
177
156
  engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
178
157
  your_html_output = engine.render(your_markdown_input)
179
158
 
159
+ ### Building man pages
160
+
161
+ #### At the command line
162
+
163
+ md2man-rake --help
164
+
165
+ #### Inside a Ruby script
166
+
167
+ Add this snippet to your gemspec file:
168
+
169
+ s.files += Dir['man/man?/*.?'] # UNIX man pages
170
+ s.files += Dir['man/**/*.{html,css,js}'] # HTML man pages
171
+ s.add_development_dependency 'md2man', '~> 1.4'
172
+
173
+ Add this line to your Rakefile:
174
+
175
+ require 'md2man/rakefile'
176
+
177
+ You now have a `rake md2man` task that builds manual pages from Markdown files
178
+ (with ".markdown", ".mkd", or ".md" extension) inside `man/man*/` directories.
179
+ There are also sub-tasks to build manual pages individually as [roff] or HTML.
180
+
181
+ If you're using Bundler, this task also hooks into Bundler's gem packaging
182
+ tasks and ensures that your manual pages are built for packaging into a gem:
183
+
184
+ bundle exec rake build
185
+ gem spec pkg/*.gem | fgrep man/
186
+
180
187
  ## License
181
188
 
182
189
  Released under the ISC license. See the LICENSE file for details.
data/VERSION.markdown CHANGED
@@ -1,3 +1,27 @@
1
+ ## Version 1.6.0 (2013-03-10)
2
+
3
+ Minor:
4
+
5
+ * Added an md2man-rake(1) executable that lets you run md2man's rake(1)
6
+ tasks _directly_ from the command line: without the need for a "Rakefile"
7
+ in your working directory that loads the `md2man/rakefile` library.
8
+
9
+ * In web pages generated by the `md2man:web` Rake task:
10
+
11
+ * extract CSS into a separate `man/style.css` file
12
+
13
+ * center manpage on screen & auto-split into columns
14
+
15
+ Patch:
16
+
17
+ * In web pages generated by the `md2man:web` Rake task:
18
+
19
+ * don't rely on being emitted into a `man/` directory
20
+
21
+ Other:
22
+
23
+ * add README and VERSION to generated HTML man pages
24
+
1
25
  ## Version 1.5.1 (2013-03-06)
2
26
 
3
27
  Patch:
data/bin/md2man CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # MD2MAN 1 2013-03-06 1.5.1
4
+ # MD2MAN 1 2013-03-10 1.6.0
5
5
 
6
6
  ## NAME
7
7
 
@@ -53,7 +53,7 @@ The following [Redcarpet] extensions are enabled while processing markdown(7):
53
53
 
54
54
  ## SEE ALSO
55
55
 
56
- md2man-html(1)
56
+ md2man-html(1), md2man-rake(1)
57
57
 
58
58
  [md2man]: https://github.com/sunaku/md2man
59
59
  [Redcarpet]: https://github.com/vmg/redcarpet
data/bin/md2man-html CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # MD2MAN-HTML 1 2013-03-06 1.5.1
4
+ # MD2MAN-HTML 1 2013-03-10 1.6.0
5
5
 
6
6
  ## NAME
7
7
 
data/bin/md2man-rake ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ =begin =======================================================================
3
+
4
+ # MD2MAN-RAKE 1 2013-03-10 1.6.0
5
+
6
+ ## NAME
7
+
8
+ md2man-rake - run rake(1) tasks from md2man(1)
9
+
10
+ ## SYNOPSIS
11
+
12
+ `md2man-rake` [*OPTION*]... [*TASK*]...
13
+
14
+ ## DESCRIPTION
15
+
16
+ This program lets you run rake(1) tasks provided by md2man(1) without having
17
+ to create a special file named `Rakefile` that contains the following snippet:
18
+
19
+ require 'md2man/rakefile'
20
+
21
+ If no *TASK* is specified, then the `md2man` task is run by default.
22
+
23
+ ## TASKS
24
+
25
+ `md2man`
26
+ Runs the `md2man:man` and `md2man:web` tasks, in that order.
27
+
28
+ `md2man:man`
29
+ Builds UNIX manual pages from `*.markdown`, `*.mkd`, and `*.md` files
30
+ found in or beneath the `man/` subdirectory in your working directory.
31
+
32
+ `md2man:web`
33
+ Builds HTML manual pages from `*.markdown`, `*.mkd`, and `*.md` files
34
+ found in or beneath the `man/` subdirectory in your working directory.
35
+
36
+ ## OPTIONS
37
+
38
+ `-h`, `--help`
39
+ Show this help manual.
40
+
41
+ Run `rake --help` to see more options.
42
+
43
+ ## SEE ALSO
44
+
45
+ rake(1), md2man(1), markdown(7)
46
+
47
+ =end =========================================================================
48
+
49
+ require 'binman'
50
+ BinMan.help
51
+
52
+ require 'rake'
53
+ Rake.application.init File.basename(__FILE__)
54
+
55
+ require 'md2man/rakefile'
56
+ task :default => :md2man
57
+
58
+ Rake.application.top_level
@@ -0,0 +1,74 @@
1
+ @import url('http://twitter.github.com/bootstrap/assets/css/bootstrap.css');
2
+
3
+ @media all {
4
+ .manpage h1,
5
+ .manpage h2,
6
+ .manpage h3,
7
+ .manpage h4,
8
+ .manpage h5,
9
+ .manpage h6 {
10
+ margin-top: 1em;
11
+ }
12
+
13
+ /* deactivate external manual page cross-references */
14
+ a.manpage-reference:not([href]) {
15
+ color: inherit;
16
+ text-decoration: none;
17
+ }
18
+ }
19
+
20
+ @media screen {
21
+ body {
22
+ column-count: auto;
23
+ -moz-column-count: auto;
24
+ -webkit-column-count: auto;
25
+
26
+ column-width: 78ex;
27
+ -moz-column-width: 78ex;
28
+ -webkit-column-width: 78ex;
29
+
30
+ column-gap: none;
31
+ -moz-column-gap: none;
32
+ -webkit-column-gap: none;
33
+
34
+ column-rule: thin solid Gainsboro;
35
+ -moz-column-rule: thin solid Gainsboro;
36
+ -webkit-column-rule: thin solid Gainsboro;
37
+ }
38
+
39
+ .manpage {
40
+ font-family: monospace;
41
+ max-width: 78ex;
42
+ margin: auto;
43
+ }
44
+
45
+ .manpage > h1:first-child {
46
+ margin-top: -5em;
47
+ font-weight: normal;
48
+ font-size: smaller;
49
+ text-align: right;
50
+ }
51
+ }
52
+
53
+ @media print {
54
+ .navbar {
55
+ display: none;
56
+ }
57
+
58
+ /* improve readability of revealed hyperlink URLs */
59
+ a:after {
60
+ font-family: monospace;
61
+ }
62
+
63
+ /* internal links and manual page cross-references */
64
+ a[href^='#'], a[href^='../man'] {
65
+ color: inherit;
66
+ font-weight: bolder;
67
+ text-decoration: none;
68
+ }
69
+
70
+ /* undo bootstrap's revealing of those hyperlinks */
71
+ a[href^='#']:after, a[href^='../man']:after {
72
+ content: none;
73
+ }
74
+ }
@@ -37,10 +37,10 @@ end
37
37
 
38
38
  #-----------------------------------------------------------------------------
39
39
  desc 'Build HTML manual pages from Markdown files in man/.'
40
- task 'md2man:web' => 'man/index.html'
40
+ task 'md2man:web' => ['man/index.html', 'man/style.css']
41
41
  #-----------------------------------------------------------------------------
42
42
 
43
- wrap_html_template = lambda do |title, content|
43
+ wrap_html_template = lambda do |title, content, ascent|
44
44
  <<WRAP_HTML_TEMPLATE
45
45
  <!DOCTYPE html>
46
46
  <html>
@@ -48,62 +48,8 @@ wrap_html_template = lambda do |title, content|
48
48
  <meta charset="utf-8" />
49
49
  <meta name="generator" content="md2man #{Md2Man::VERSION} https://github.com/sunaku/md2man" />
50
50
  <title>#{title}</title>
51
+ <link rel="stylesheet" href="#{ascent}style.css"/>
51
52
  <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
52
- <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
53
- <style type="text/css">
54
- @media all {
55
- .manpage h1,
56
- .manpage h2,
57
- .manpage h3,
58
- .manpage h4,
59
- .manpage h5,
60
- .manpage h6 {
61
- margin-top: 1em;
62
- }
63
-
64
- /* deactivate external manual page cross-references */
65
- a.manpage-reference:not([href]) {
66
- color: inherit;
67
- text-decoration: none;
68
- }
69
- }
70
- @media screen {
71
- .manpage {
72
- font-family: monospace;
73
- max-width: 78ex;
74
- }
75
-
76
- .manpage > h1:first-child {
77
- margin-top: -5em;
78
- font-weight: normal;
79
- font-size: smaller;
80
- text-align: right;
81
- }
82
- }
83
-
84
- @media print {
85
- .navbar {
86
- display: none;
87
- }
88
-
89
- /* improve readability of revealed hyperlink URLs */
90
- a:after {
91
- font-family: monospace;
92
- }
93
-
94
- /* internal links and manual page cross-references */
95
- a[href^='#'], a[href^='../man'] {
96
- color: inherit;
97
- font-weight: bolder;
98
- text-decoration: none;
99
- }
100
-
101
- /* undo bootstrap's revealing of those hyperlinks */
102
- a[href^='#']:after, a[href^='../man']:after {
103
- content: none;
104
- }
105
- }
106
- </style>
107
53
  </head>
108
54
  <body>#{content}</body>
109
55
  </html>
@@ -122,14 +68,12 @@ end
122
68
 
123
69
  file 'man/index.html' => webs do |t|
124
70
  buffer = ['<div class="container-fluid">']
125
- webs.sort.group_by {|web| web.pathmap('%d') }.each do |dir, dir_webs|
126
- subdir = dir.sub('man/', '')
71
+ webs.sort.group_by {|web| web.pathmap('%d').sub('man/', '') }.each do |subdir, dir_webs|
127
72
  buffer << %{<h2 id="#{subdir}">#{subdir}</h2>}
128
-
129
73
  dir_webs.each do |web|
130
74
  name = parse_manpage_name.call(web)
131
75
  info = parse_manpage_info.call(File.read(web))
132
- link = %{<a href="../#{web}">#{name}</a>}
76
+ link = %{<a href="#{web.sub('man/', '')}">#{name}</a>}
133
77
  buffer << %{<dl class="dl-horizontal"><dt>#{link}</dt><dd>#{info}</dd></dl>}
134
78
  end
135
79
  end
@@ -137,10 +81,14 @@ file 'man/index.html' => webs do |t|
137
81
  content = buffer.join
138
82
 
139
83
  title = t.name.pathmap('%X')
140
- output = wrap_html_template.call(title, content)
84
+ output = wrap_html_template.call(title, content, nil)
141
85
  File.open(t.name, 'w') {|f| f << output }
142
86
  end
143
87
 
88
+ file 'man/style.css' => __FILE__.pathmap('%X/style.css') do |t|
89
+ cp t.prerequisites.first, t.name if t.needed?
90
+ end
91
+
144
92
  mkds.zip(webs).each do |src, dst|
145
93
  render_file_task.call src, dst, lambda {|input|
146
94
  require 'md2man/html/engine'
@@ -173,6 +121,6 @@ mkds.zip(webs).each do |src, dst|
173
121
  '</div>',
174
122
  ].join
175
123
 
176
- wrap_html_template.call title, content
124
+ wrap_html_template.call title, content, ascent
177
125
  }
178
126
  end
@@ -1,3 +1,3 @@
1
1
  module Md2Man
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
data/man/README.html ADDED
@@ -0,0 +1,111 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="generator" content="md2man 1.6.0 https://github.com/sunaku/md2man" />
6
+ <title>README</title>
7
+ <link rel="stylesheet" href="style.css"/>
8
+ <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
9
+ </head>
10
+ <body><div class="navbar"><div class="navbar-inner"><span class="brand"><a href="index.html#man">man</a>/README</span></div></div><div class="container-fluid"><div class="manpage"><h1 id="md2man-markdown-to-manpage">md2man - markdown to manpage</h1><p>md2man is a Ruby library and command-line program that converts <a href="http://daringfireball.net/projects/markdown/">Markdown</a>
11
+ documents into UNIX manual pages (both <a href="http://troff.org">roff</a> and HTML) using <a href="https://github.com/vmg/redcarpet">Redcarpet</a>.</p><h2 id="Features">Features</h2>
12
+ <ul>
13
+ <li><p>Formats tagged and indented paragraphs (see &quot;document format&quot; below).</p></li>
14
+ <li><p>Translates all HTML4 and XHTML1 entities into native <a href="http://troff.org">roff</a> equivalents.</p></li>
15
+ <li><p>Supports markdown extensions such as <a href="http://michelf.com/projects/php-markdown/extra/#table">PHP Markdown Extra tables</a>.</p></li>
16
+ <li><p>Usable from the command line as a filter in a UNIX pipeline.</p></li>
17
+ </ul>
18
+ <h3 id="Demonstration">Demonstration</h3><p>Try converting <a href="https://raw.github.com/sunaku/md2man/master/EXAMPLE.markdown">this example Markdown file</a> into a UNIX manual page:</p><pre><code>md2man EXAMPLE.markdown &gt; EXAMPLE.1
19
+ man -l EXAMPLE.1
20
+ </code></pre><p><img src="https://raw.github.com/sunaku/md2man/master/EXAMPLE.png" alt="Obligatory screenshot of <a class="manpage-reference">md2man(1)</a> in action!"></p><h3 id="Limitations">Limitations</h3><p>At present, md2man does not translate the following <a href="https://github.com/vmg/redcarpet">Redcarpet</a> node types:</p>
21
+ <ul>
22
+ <li><code>block_html</code></li>
23
+ <li><code>strikethrough</code></li>
24
+ <li><code>superscript</code></li>
25
+ <li><code>image</code></li>
26
+ <li><code>raw_html</code></li>
27
+ </ul>
28
+ <p>It issues a warning when it encounters these instead. Patches are welcome!</p><h2 id="Installation">Installation</h2><pre><code>gem install md2man
29
+ </code></pre><h3 id="Development">Development</h3><pre><code>git clone git://github.com/sunaku/md2man
30
+ cd md2man
31
+ bundle install
32
+ bundle exec md2man --help # run it directly
33
+ bundle exec rake --tasks # packaging tasks
34
+ </code></pre><h2 id="Usage">Usage</h2><h3 id="Document-format">Document format</h3><p>md2man extends <a href="http://daringfireball.net/projects/markdown/">Markdown</a> syntax in the following ways, as provisioned in the
35
+ <code>Md2Man::Document</code> module and defined in its derivative <code>Md2Man::Roff</code> module:</p>
36
+ <ul>
37
+ <li><p>Paragraphs whose lines are all uniformly indented by two spaces are
38
+ considered to be &quot;indented paragraphs&quot;. They are unindented accordingly
39
+ before emission as <code>.IP</code> in the <a href="http://troff.org">roff</a> output.</p></li>
40
+ <li><p>Paragraphs whose subsequent lines (all except the first) are uniformly
41
+ indented by two spaces are considered to be a &quot;tagged paragraphs&quot;. They
42
+ are unindented accordingly before emission as <code>.TP</code> in the <a href="http://troff.org">roff</a> output.</p></li>
43
+ </ul>
44
+ <p>md2man extends <a href="http://daringfireball.net/projects/markdown/">Markdown</a> semantics in the following ways:</p>
45
+ <ul>
46
+ <li>The first top-level heading (H1) found in the document is emitted as <code>.TH</code>
47
+ in the <a class="manpage-reference">roff(7)</a> output to define the UNIX manual page&#39;s header and footer.
48
+ Any subsequent top-level headings (H1) are treated as second-level (H2).</li>
49
+ </ul>
50
+ <h3 id="For-roff-output">For <a href="http://troff.org">roff</a> output</h3><h4 id="At-the-command-line">At the command line</h4><pre><code>md2man --help
51
+ </code></pre><h4 id="Inside-a-Ruby-script">Inside a Ruby script</h4><p>Use the default renderer:</p><pre><code>require 'md2man'
52
+
53
+ your_roff_output = Md2Man::ENGINE.render(your_markdown_input)
54
+ </code></pre><p>Build your own renderer:</p><pre><code>require 'md2man'
55
+
56
+ engine = Redcarpet::Markdown.new(Md2Man::Engine, your_options_hash)
57
+ your_roff_output = engine.render(your_markdown_input)
58
+ </code></pre><p>Define your own renderer:</p><pre><code>require 'md2man'
59
+
60
+ class YourManpageRenderer &lt; Md2Man::Engine
61
+ # ... your stuff here ...
62
+ end
63
+
64
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
65
+ your_roff_output = engine.render(your_markdown_input)
66
+ </code></pre><p>Mix-in your own renderer:</p><pre><code>require 'md2man'
67
+
68
+ class YourManpageRenderer &lt; Redcarpet::Render::Base
69
+ include Md2Man::Roff
70
+ # ... your stuff here ...
71
+ end
72
+
73
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
74
+ your_roff_output = engine.render(your_markdown_input)
75
+ </code></pre><h3 id="For-HTML-output">For HTML output</h3><h4 id="At-the-command-line">At the command line</h4><pre><code>md2man-html --help
76
+ </code></pre><h4 id="Inside-a-Ruby-script">Inside a Ruby script</h4><p>Use the default renderer:</p><pre><code>require 'md2man/html/engine'
77
+
78
+ your_html_output = Md2Man::HTML::ENGINE.render(your_markdown_input)
79
+ </code></pre><p>Build your own renderer:</p><pre><code>require 'md2man/html/engine'
80
+
81
+ engine = Redcarpet::Markdown.new(Md2Man::HTML::Engine, your_options_hash)
82
+ your_html_output = engine.render(your_markdown_input)
83
+ </code></pre><p>Define your own renderer:</p><pre><code>require 'md2man/html/engine'
84
+
85
+ class YourManpageRenderer &lt; Md2Man::HTML::Engine
86
+ # ... your stuff here ...
87
+ end
88
+
89
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
90
+ your_html_output = engine.render(your_markdown_input)
91
+ </code></pre><p>Mix-in your own renderer:</p><pre><code>require 'md2man/html'
92
+
93
+ class YourManpageRenderer &lt; Redcarpet::Render::Base
94
+ include Md2Man::HTML
95
+ # ... your stuff here ...
96
+ end
97
+
98
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
99
+ your_html_output = engine.render(your_markdown_input)
100
+ </code></pre><h3 id="Building-man-pages">Building man pages</h3><h4 id="At-the-command-line">At the command line</h4><pre><code>md2man-rake --help
101
+ </code></pre><h4 id="Inside-a-Ruby-script">Inside a Ruby script</h4><p>Add this snippet to your gemspec file:</p><pre><code>s.files += Dir['man/man?/*.?'] # UNIX man pages
102
+ s.files += Dir['man/**/*.{html,css,js}'] # HTML man pages
103
+ s.add_development_dependency 'md2man', '~&gt; 1.4'
104
+ </code></pre><p>Add this line to your Rakefile:</p><pre><code>require 'md2man/rakefile'
105
+ </code></pre><p>You now have a <code>rake md2man</code> task that builds manual pages from Markdown files
106
+ (with &quot;.markdown&quot;, &quot;.mkd&quot;, or &quot;.md&quot; extension) inside <code>man/man*/</code> directories.
107
+ There are also sub-tasks to build manual pages individually as <a href="http://troff.org">roff</a> or HTML.</p><p>If you&#39;re using Bundler, this task also hooks into Bundler&#39;s gem packaging
108
+ tasks and ensures that your manual pages are built for packaging into a gem:</p><pre><code>bundle exec rake build
109
+ gem spec pkg/*.gem | fgrep man/
110
+ </code></pre><h2 id="License">License</h2><p>Released under the ISC license. See the LICENSE file for details.</p></div></div></body>
111
+ </html>
@@ -0,0 +1,195 @@
1
+ # md2man - markdown to manpage
2
+
3
+ md2man is a Ruby library and command-line program that converts [Markdown]
4
+ documents into UNIX manual pages (both [roff] and HTML) using [Redcarpet].
5
+
6
+ ## Features
7
+
8
+ * Formats tagged and indented paragraphs (see "document format" below).
9
+
10
+ * Translates all HTML4 and XHTML1 entities into native [roff] equivalents.
11
+
12
+ * Supports markdown extensions such as [PHP Markdown Extra tables][tables].
13
+
14
+ * Usable from the command line as a filter in a UNIX pipeline.
15
+
16
+ ### Demonstration
17
+
18
+ Try converting [this example Markdown file][example] into a UNIX manual page:
19
+
20
+ md2man EXAMPLE.markdown > EXAMPLE.1
21
+ man -l EXAMPLE.1
22
+
23
+ ![Obligatory screenshot of md2man(1) in action!](
24
+ https://raw.github.com/sunaku/md2man/master/EXAMPLE.png)
25
+
26
+ ### Limitations
27
+
28
+ At present, md2man does not translate the following [Redcarpet] node types:
29
+
30
+ * `block_html`
31
+ * `strikethrough`
32
+ * `superscript`
33
+ * `image`
34
+ * `raw_html`
35
+
36
+ It issues a warning when it encounters these instead. Patches are welcome!
37
+
38
+ ## Installation
39
+
40
+ gem install md2man
41
+
42
+ ### Development
43
+
44
+ git clone git://github.com/sunaku/md2man
45
+ cd md2man
46
+ bundle install
47
+ bundle exec md2man --help # run it directly
48
+ bundle exec rake --tasks # packaging tasks
49
+
50
+ ## Usage
51
+
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
74
+
75
+ md2man --help
76
+
77
+ #### Inside a Ruby script
78
+
79
+ Use the default renderer:
80
+
81
+ require 'md2man'
82
+
83
+ your_roff_output = Md2Man::ENGINE.render(your_markdown_input)
84
+
85
+ Build your own renderer:
86
+
87
+ require 'md2man'
88
+
89
+ engine = Redcarpet::Markdown.new(Md2Man::Engine, your_options_hash)
90
+ your_roff_output = engine.render(your_markdown_input)
91
+
92
+ Define your own renderer:
93
+
94
+ require 'md2man'
95
+
96
+ class YourManpageRenderer < Md2Man::Engine
97
+ # ... your stuff here ...
98
+ end
99
+
100
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
101
+ your_roff_output = engine.render(your_markdown_input)
102
+
103
+ Mix-in your own renderer:
104
+
105
+ require 'md2man'
106
+
107
+ class YourManpageRenderer < Redcarpet::Render::Base
108
+ include Md2Man::Roff
109
+ # ... your stuff here ...
110
+ end
111
+
112
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
113
+ your_roff_output = engine.render(your_markdown_input)
114
+
115
+ ### For HTML output
116
+
117
+ #### At the command line
118
+
119
+ md2man-html --help
120
+
121
+ #### Inside a Ruby script
122
+
123
+ Use the default renderer:
124
+
125
+ require 'md2man/html/engine'
126
+
127
+ your_html_output = Md2Man::HTML::ENGINE.render(your_markdown_input)
128
+
129
+ Build your own renderer:
130
+
131
+ require 'md2man/html/engine'
132
+
133
+ engine = Redcarpet::Markdown.new(Md2Man::HTML::Engine, your_options_hash)
134
+ your_html_output = engine.render(your_markdown_input)
135
+
136
+ Define your own renderer:
137
+
138
+ require 'md2man/html/engine'
139
+
140
+ class YourManpageRenderer < Md2Man::HTML::Engine
141
+ # ... your stuff here ...
142
+ end
143
+
144
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
145
+ your_html_output = engine.render(your_markdown_input)
146
+
147
+ Mix-in your own renderer:
148
+
149
+ require 'md2man/html'
150
+
151
+ class YourManpageRenderer < Redcarpet::Render::Base
152
+ include Md2Man::HTML
153
+ # ... your stuff here ...
154
+ end
155
+
156
+ engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
157
+ your_html_output = engine.render(your_markdown_input)
158
+
159
+ ### Building man pages
160
+
161
+ #### At the command line
162
+
163
+ md2man-rake --help
164
+
165
+ #### Inside a Ruby script
166
+
167
+ Add this snippet to your gemspec file:
168
+
169
+ s.files += Dir['man/man?/*.?'] # UNIX man pages
170
+ s.files += Dir['man/**/*.{html,css,js}'] # HTML man pages
171
+ s.add_development_dependency 'md2man', '~> 1.4'
172
+
173
+ Add this line to your Rakefile:
174
+
175
+ require 'md2man/rakefile'
176
+
177
+ You now have a `rake md2man` task that builds manual pages from Markdown files
178
+ (with ".markdown", ".mkd", or ".md" extension) inside `man/man*/` directories.
179
+ There are also sub-tasks to build manual pages individually as [roff] or HTML.
180
+
181
+ If you're using Bundler, this task also hooks into Bundler's gem packaging
182
+ tasks and ensures that your manual pages are built for packaging into a gem:
183
+
184
+ bundle exec rake build
185
+ gem spec pkg/*.gem | fgrep man/
186
+
187
+ ## License
188
+
189
+ Released under the ISC license. See the LICENSE file for details.
190
+
191
+ [roff]: http://troff.org
192
+ [Markdown]: http://daringfireball.net/projects/markdown/
193
+ [Redcarpet]: https://github.com/vmg/redcarpet
194
+ [example]: https://raw.github.com/sunaku/md2man/master/EXAMPLE.markdown
195
+ [tables]: http://michelf.com/projects/php-markdown/extra/#table