md2man 1.6.2 → 2.0.0
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/README.markdown +24 -43
- data/VERSION.markdown +36 -0
- data/bin/md2man-html +11 -14
- data/bin/md2man-rake +2 -2
- data/bin/md2man-roff +49 -0
- data/lib/md2man/document.rb +12 -41
- data/lib/md2man/html/engine.rb +2 -4
- data/lib/md2man/html.rb +9 -15
- data/lib/md2man/rakefile/style.css +9 -9
- data/lib/md2man/rakefile.rb +4 -6
- data/lib/md2man/{engine.rb → roff/engine.rb} +5 -4
- data/lib/md2man/roff.rb +6 -8
- data/lib/md2man/version.rb +1 -1
- data/lib/md2man.rb +0 -1
- data/man/index.html +2 -2
- data/man/man0/README.html +76 -61
- data/man/man0/README.markdown +24 -43
- data/man/man0/VERSION.html +41 -9
- data/man/man0/VERSION.markdown +36 -0
- data/man/man1/md2man-html.1 +19 -18
- data/man/man1/md2man-html.1.html +10 -7
- data/man/man1/md2man-rake.1 +4 -3
- data/man/man1/md2man-rake.1.html +7 -5
- data/man/man1/md2man-roff.1 +53 -0
- data/man/man1/md2man-roff.1.html +21 -0
- data/man/man5/md2man.5 +116 -0
- data/man/man5/md2man.5.html +64 -0
- data/man/man5/md2man.5.markdown +91 -0
- data/man/style.css +9 -9
- data/test/md2man/html_test.rb +31 -7
- data/test/md2man/roff_test.rb +46 -7
- metadata +11 -8
- data/bin/md2man +0 -67
- data/man/man1/md2man.1 +0 -84
- data/man/man1/md2man.1.html +0 -37
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# md2man - markdown to manpage
|
2
2
|
|
3
|
-
md2man is a Ruby library and command-line
|
4
|
-
|
3
|
+
md2man is a Ruby library and a set of command-line programs that convert
|
4
|
+
[Markdown] into UNIX manual pages (both [roff] and HTML) using [Redcarpet].
|
5
5
|
|
6
6
|
## Features
|
7
7
|
|
@@ -11,29 +11,22 @@ documents into UNIX manual pages (both [roff] and HTML) using [Redcarpet].
|
|
11
11
|
|
12
12
|
* Supports markdown extensions such as [PHP Markdown Extra tables][tables].
|
13
13
|
|
14
|
-
* Usable from the command line as a filter in a UNIX pipeline.
|
14
|
+
* Usable from the command line as a filter in a UNIX command pipeline.
|
15
15
|
|
16
16
|
### Demonstration
|
17
17
|
|
18
18
|
Try converting [this example Markdown file][example] into a UNIX manual page:
|
19
19
|
|
20
|
-
md2man EXAMPLE.markdown > EXAMPLE.1
|
20
|
+
md2man-roff EXAMPLE.markdown > EXAMPLE.1
|
21
21
|
man -l EXAMPLE.1
|
22
22
|
|
23
23
|

|
25
25
|
|
26
|
-
|
26
|
+
Also try converting [that example Markdown file][example] into a web page:
|
27
27
|
|
28
|
-
|
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!
|
28
|
+
md2man-html EXAMPLE.markdown > EXAMPLE.html
|
29
|
+
open EXAMPLE.html
|
37
30
|
|
38
31
|
## Installation
|
39
32
|
|
@@ -44,56 +37,40 @@ It issues a warning when it encounters these instead. Patches are welcome!
|
|
44
37
|
git clone git://github.com/sunaku/md2man
|
45
38
|
cd md2man
|
46
39
|
bundle install
|
47
|
-
bundle exec
|
48
|
-
bundle exec
|
40
|
+
bundle exec rake --tasks # packaging tasks
|
41
|
+
bundle exec md2man-roff --help # run it directly
|
42
|
+
bundle exec md2man-html --help # run it directly
|
49
43
|
|
50
44
|
## Usage
|
51
45
|
|
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
46
|
### For [roff] output
|
72
47
|
|
73
48
|
#### At the command line
|
74
49
|
|
75
|
-
|
50
|
+
See md2man-roff(1) manual:
|
51
|
+
|
52
|
+
md2man-roff --help
|
76
53
|
|
77
54
|
#### Inside a Ruby script
|
78
55
|
|
79
56
|
Use the default renderer:
|
80
57
|
|
81
|
-
require 'md2man'
|
58
|
+
require 'md2man/roff/engine'
|
82
59
|
|
83
|
-
your_roff_output = Md2Man::ENGINE.render(your_markdown_input)
|
60
|
+
your_roff_output = Md2Man::Roff::ENGINE.render(your_markdown_input)
|
84
61
|
|
85
62
|
Build your own renderer:
|
86
63
|
|
87
|
-
require 'md2man'
|
64
|
+
require 'md2man/roff/engine'
|
88
65
|
|
89
|
-
engine = Redcarpet::Markdown.new(Md2Man::Engine, your_options_hash)
|
66
|
+
engine = Redcarpet::Markdown.new(Md2Man::Roff::Engine, your_options_hash)
|
90
67
|
your_roff_output = engine.render(your_markdown_input)
|
91
68
|
|
92
69
|
Define your own renderer:
|
93
70
|
|
94
|
-
require 'md2man'
|
71
|
+
require 'md2man/roff/engine'
|
95
72
|
|
96
|
-
class YourManpageRenderer < Md2Man::Engine
|
73
|
+
class YourManpageRenderer < Md2Man::Roff::Engine
|
97
74
|
# ... your stuff here ...
|
98
75
|
end
|
99
76
|
|
@@ -102,7 +79,7 @@ Define your own renderer:
|
|
102
79
|
|
103
80
|
Mix-in your own renderer:
|
104
81
|
|
105
|
-
require 'md2man'
|
82
|
+
require 'md2man/roff'
|
106
83
|
|
107
84
|
class YourManpageRenderer < Redcarpet::Render::Base
|
108
85
|
include Md2Man::Roff
|
@@ -116,6 +93,8 @@ Mix-in your own renderer:
|
|
116
93
|
|
117
94
|
#### At the command line
|
118
95
|
|
96
|
+
See md2man-html(1) manual:
|
97
|
+
|
119
98
|
md2man-html --help
|
120
99
|
|
121
100
|
#### Inside a Ruby script
|
@@ -160,6 +139,8 @@ Mix-in your own renderer:
|
|
160
139
|
|
161
140
|
#### At the command line
|
162
141
|
|
142
|
+
See md2man-rake(1) manual:
|
143
|
+
|
163
144
|
md2man-rake --help
|
164
145
|
|
165
146
|
#### Inside a Ruby script
|
data/VERSION.markdown
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
## Version 2.0.0 (2013-05-05)
|
2
|
+
|
3
|
+
This release renames md2man executables and libraries to highlight the fact
|
4
|
+
that md2man provides two processing pathways: one for Roff and one for HTML.
|
5
|
+
|
6
|
+
Major:
|
7
|
+
|
8
|
+
* Rename md2man(1) executable to md2man-roff(1).
|
9
|
+
|
10
|
+
* Rename `Md2Man::Engine` to `Md2Man::Roff::Engine`.
|
11
|
+
|
12
|
+
* Rename "manpage-reference" CSS class to "md2man-xref" in HTML output.
|
13
|
+
|
14
|
+
* The `Md2Man::Document#reference()` method now takes only two parameters:
|
15
|
+
|
16
|
+
* `input_match` - MatchData object for the reference in Markdown input
|
17
|
+
containing the following named capture groups:
|
18
|
+
|
19
|
+
* `:page` - name of the manual page
|
20
|
+
|
21
|
+
* `:section` - section number of the manual page
|
22
|
+
|
23
|
+
* `output_match` - MatchData object for the reference in output document
|
24
|
+
containing the following named capture groups:
|
25
|
+
|
26
|
+
* `:addendum` - non-space characters immediately after the reference in
|
27
|
+
the output document
|
28
|
+
|
29
|
+
Patch:
|
30
|
+
|
31
|
+
* Prevent cross-references from being expanded inside HTML tags.
|
32
|
+
|
33
|
+
Other:
|
34
|
+
|
35
|
+
* Add md2man(5) manual page detailing md2man's markdown file format.
|
36
|
+
|
1
37
|
## Version 1.6.2 (2013-05-05)
|
2
38
|
|
3
39
|
Patch:
|
data/bin/md2man-html
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
=begin =======================================================================
|
3
3
|
|
4
|
-
# MD2MAN-HTML 1 2013-05-05
|
4
|
+
# MD2MAN-HTML 1 2013-05-05 2.0.0
|
5
5
|
|
6
6
|
## NAME
|
7
7
|
|
8
|
-
md2man-html - convert md2man(
|
8
|
+
md2man-html - convert md2man(5) flavored markdown(7) into HTML
|
9
9
|
|
10
10
|
## SYNOPSIS
|
11
11
|
|
@@ -13,22 +13,19 @@ md2man-html - convert md2man(1) flavored markdown(7) into HTML
|
|
13
13
|
|
14
14
|
## DESCRIPTION
|
15
15
|
|
16
|
-
This program converts
|
17
|
-
and then prints the result to
|
16
|
+
This program converts md2man(5) flavored markdown(7) input from the given
|
17
|
+
*FILE* into HTML and then prints the result to the standard output stream.
|
18
|
+
If *FILE* is not given, then the standard input stream is read in its place.
|
18
19
|
|
19
|
-
###
|
20
|
+
### Cross references
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
### Cross linking
|
24
|
-
|
25
|
-
References to other manual pages are converted into hyperlinks that have
|
26
|
-
class="manpage-reference" and href="../man${section}/${page}.${section}.html"
|
22
|
+
Cross references to manual pages are emitted as HTML hyperlinks that have
|
23
|
+
`class="md2man-xref"` and `href="../man$SECTION/$PAGE.$SECTION.html"`
|
27
24
|
attributes.
|
28
25
|
|
29
|
-
For example, the
|
26
|
+
For example, the `printf(3)` cross reference would be emitted as this HTML:
|
30
27
|
|
31
|
-
<a class="
|
28
|
+
<a class="md2man-xref" href="../man3/printf.3.html">printf(3)</a>
|
32
29
|
|
33
30
|
## OPTIONS
|
34
31
|
|
@@ -37,7 +34,7 @@ For example, the markdown(7) reference would be converted into HTML as:
|
|
37
34
|
|
38
35
|
## SEE ALSO
|
39
36
|
|
40
|
-
md2man(1)
|
37
|
+
md2man-roff(1), md2man-rake(1), md2man(5)
|
41
38
|
|
42
39
|
=end =========================================================================
|
43
40
|
|
data/bin/md2man-rake
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
=begin =======================================================================
|
3
3
|
|
4
|
-
# MD2MAN-RAKE 1 2013-05-05
|
4
|
+
# MD2MAN-RAKE 1 2013-05-05 2.0.0
|
5
5
|
|
6
6
|
## NAME
|
7
7
|
|
@@ -42,7 +42,7 @@ Run `rake --help` to see more options.
|
|
42
42
|
|
43
43
|
## SEE ALSO
|
44
44
|
|
45
|
-
rake(1), md2man(1),
|
45
|
+
rake(1), md2man-roff(1), md2man-html(1), md2man(5)
|
46
46
|
|
47
47
|
=end =========================================================================
|
48
48
|
|
data/bin/md2man-roff
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
=begin =======================================================================
|
3
|
+
|
4
|
+
# MD2MAN-ROFF 1 2013-05-05 2.0.0
|
5
|
+
|
6
|
+
## NAME
|
7
|
+
|
8
|
+
md2man-roff - convert md2man(5) flavored markdown(7) into roff(7)
|
9
|
+
|
10
|
+
## SYNOPSIS
|
11
|
+
|
12
|
+
`md2man-roff` [*OPTION*]... [*FILE*]
|
13
|
+
|
14
|
+
## DESCRIPTION
|
15
|
+
|
16
|
+
This program converts md2man(5) flavored markdown(7) input from the given
|
17
|
+
*FILE* into roff(7) and then prints the result to the standard output stream.
|
18
|
+
If *FILE* is not given, then the standard input stream is read in its place.
|
19
|
+
|
20
|
+
### Limitations
|
21
|
+
|
22
|
+
This program does not convert the following [Redcarpet] nodes into roff(7):
|
23
|
+
|
24
|
+
* `block_html`
|
25
|
+
* `strikethrough`
|
26
|
+
* `superscript`
|
27
|
+
* `image`
|
28
|
+
* `raw_html`
|
29
|
+
|
30
|
+
It issues a warning when it encounters these instead. Patches are welcome!
|
31
|
+
|
32
|
+
## OPTIONS
|
33
|
+
|
34
|
+
`-h`, `--help`
|
35
|
+
Show this help manual.
|
36
|
+
|
37
|
+
## SEE ALSO
|
38
|
+
|
39
|
+
md2man-html(1), md2man-rake(1), md2man(5)
|
40
|
+
|
41
|
+
[Redcarpet]: https://github.com/vmg/redcarpet
|
42
|
+
|
43
|
+
=end =========================================================================
|
44
|
+
|
45
|
+
require 'binman'
|
46
|
+
BinMan.help
|
47
|
+
|
48
|
+
require 'md2man/roff/engine'
|
49
|
+
puts Md2Man::Roff::ENGINE.render(ARGF.read)
|
data/lib/md2man/document.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'md2man'
|
2
|
+
|
3
|
+
module Md2Man::Document
|
3
4
|
|
4
5
|
#---------------------------------------------------------------------------
|
5
6
|
# document-level processing
|
@@ -18,21 +19,6 @@ module Document
|
|
18
19
|
# block-level processing
|
19
20
|
#---------------------------------------------------------------------------
|
20
21
|
|
21
|
-
# This method blocks Redcarpet's default behavior, which cannot be accessed
|
22
|
-
# using super() due to the limitation of how Redcarpet is implemented in C.
|
23
|
-
# See https://github.com/vmg/redcarpet/issues/51 for the complete details.
|
24
|
-
#
|
25
|
-
# You MUST override this method in derived classes and call super() therein:
|
26
|
-
#
|
27
|
-
# def block_code code, language
|
28
|
-
# code = super
|
29
|
-
# # now do something with code
|
30
|
-
# end
|
31
|
-
#
|
32
|
-
def block_code code, language
|
33
|
-
decode_references code, true
|
34
|
-
end
|
35
|
-
|
36
22
|
PARAGRAPH_INDENT = /^\s*$|^ (?=\S)/
|
37
23
|
|
38
24
|
# This method blocks Redcarpet's default behavior, which cannot be accessed
|
@@ -75,23 +61,8 @@ module Document
|
|
75
61
|
# span-level processing
|
76
62
|
#---------------------------------------------------------------------------
|
77
63
|
|
78
|
-
|
79
|
-
|
80
|
-
# See https://github.com/vmg/redcarpet/issues/51 for the complete details.
|
81
|
-
#
|
82
|
-
# You MUST override this method in derived classes and call super() therein.
|
83
|
-
#
|
84
|
-
# def codespan code
|
85
|
-
# code = super
|
86
|
-
# # now do something with code
|
87
|
-
# end
|
88
|
-
#
|
89
|
-
def codespan code
|
90
|
-
decode_references code, true
|
91
|
-
end
|
92
|
-
|
93
|
-
def reference page, section, addendum
|
94
|
-
warn "md2man/document: reference not implemented: #{page}(#{section})"
|
64
|
+
def reference input_match, output_match
|
65
|
+
warn "md2man/document: reference not implemented: #{input_match}"
|
95
66
|
end
|
96
67
|
|
97
68
|
protected
|
@@ -105,7 +76,7 @@ private
|
|
105
76
|
def encode_references text
|
106
77
|
# the [^\n\S] captures all non-newline whitespace
|
107
78
|
# basically, it's meant to be \s but excluding \n
|
108
|
-
text.gsub(/([\w\-\.]+)\((
|
79
|
+
text.gsub(/(?<page>[\w\-\.]+)\((?<section>\w+)\)/) do
|
109
80
|
match = $~
|
110
81
|
key = encode(match)
|
111
82
|
@references[key] = match
|
@@ -113,13 +84,13 @@ private
|
|
113
84
|
end
|
114
85
|
end
|
115
86
|
|
116
|
-
def decode_references text
|
117
|
-
@references.
|
118
|
-
|
119
|
-
|
120
|
-
|
87
|
+
def decode_references text
|
88
|
+
@references.delete_if do |key, match|
|
89
|
+
text.sub! /#{Regexp.escape key}(?<addendum>\S*[^\n\S]*)/ do
|
90
|
+
reference match, $~
|
91
|
+
end
|
92
|
+
end
|
121
93
|
text
|
122
94
|
end
|
123
95
|
|
124
96
|
end
|
125
|
-
end
|
data/lib/md2man/html/engine.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'redcarpet'
|
2
2
|
require 'md2man/html'
|
3
3
|
|
4
|
-
module Md2Man
|
5
|
-
module HTML
|
4
|
+
module Md2Man::HTML
|
6
5
|
|
7
6
|
class Engine < Redcarpet::Render::HTML
|
8
|
-
include HTML
|
7
|
+
include Md2Man::HTML
|
9
8
|
end
|
10
9
|
|
11
10
|
ENGINE = Redcarpet::Markdown.new(Engine,
|
@@ -18,4 +17,3 @@ module HTML
|
|
18
17
|
)
|
19
18
|
|
20
19
|
end
|
21
|
-
end
|
data/lib/md2man/html.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
require 'md2man/document'
|
3
3
|
|
4
|
-
module Md2Man
|
5
|
-
module HTML
|
4
|
+
module Md2Man::HTML
|
6
5
|
|
7
|
-
include Document
|
6
|
+
include Md2Man::Document
|
8
7
|
|
9
8
|
#---------------------------------------------------------------------------
|
10
9
|
# block-level processing
|
@@ -23,10 +22,6 @@ module HTML
|
|
23
22
|
"<dl><dd>#{text}</dd></dl>"
|
24
23
|
end
|
25
24
|
|
26
|
-
def block_code code, language
|
27
|
-
"<pre>#{codespan(super)}</pre>"
|
28
|
-
end
|
29
|
-
|
30
25
|
def header text, level
|
31
26
|
id = text.gsub(/<.+?>/, '-'). # strip all HTML tags
|
32
27
|
gsub(/\W+/, '-').gsub(/^-|-$/, '') # fold non-word chars
|
@@ -37,13 +32,13 @@ module HTML
|
|
37
32
|
# span-level processing
|
38
33
|
#---------------------------------------------------------------------------
|
39
34
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
35
|
+
def reference input_match, output_match
|
36
|
+
if output_match.pre_match =~ /<[^>]*\z/
|
37
|
+
input_match.to_s
|
38
|
+
else
|
39
|
+
url = reference_url(input_match[:page], input_match[:section])
|
40
|
+
%{<a class="md2man-xref" href="#{url}">#{input_match}</a>}
|
41
|
+
end + output_match[:addendum].to_s
|
47
42
|
end
|
48
43
|
|
49
44
|
# You can override this in a derived class to compute URLs as you like!
|
@@ -52,4 +47,3 @@ module HTML
|
|
52
47
|
end
|
53
48
|
|
54
49
|
end
|
55
|
-
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
@import url('http://twitter.github.com/bootstrap/assets/css/bootstrap.css');
|
2
2
|
|
3
3
|
@media all {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
h1,
|
5
|
+
h2,
|
6
|
+
h3,
|
7
|
+
h4,
|
8
|
+
h5,
|
9
|
+
h6 {
|
10
10
|
margin-top: 1em;
|
11
11
|
}
|
12
12
|
|
13
13
|
/* deactivate external manual page cross-references */
|
14
|
-
a.
|
14
|
+
a.md2man-xref:not([href]) {
|
15
15
|
color: inherit;
|
16
16
|
text-decoration: none;
|
17
17
|
}
|
@@ -25,7 +25,7 @@
|
|
25
25
|
margin: auto;
|
26
26
|
}
|
27
27
|
|
28
|
-
|
28
|
+
h1:first-child {
|
29
29
|
margin-top: -5em;
|
30
30
|
font-weight: normal;
|
31
31
|
font-size: smaller;
|
@@ -34,7 +34,7 @@
|
|
34
34
|
}
|
35
35
|
|
36
36
|
@media print {
|
37
|
-
.navbar {
|
37
|
+
.navbar:first-child {
|
38
38
|
display: none;
|
39
39
|
}
|
40
40
|
|
data/lib/md2man/rakefile.rb
CHANGED
@@ -30,8 +30,8 @@ task 'md2man:man' => mans
|
|
30
30
|
|
31
31
|
mkds.zip(mans).each do |src, dst|
|
32
32
|
render_file_task.call src, dst, lambda {|input|
|
33
|
-
require 'md2man/engine'
|
34
|
-
Md2Man::ENGINE.render(input)
|
33
|
+
require 'md2man/roff/engine'
|
34
|
+
Md2Man::Roff::ENGINE.render(input)
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
@@ -95,7 +95,7 @@ mkds.zip(webs).each do |src, dst|
|
|
95
95
|
require 'md2man/html/engine'
|
96
96
|
output = Md2Man::HTML::ENGINE.render(input).
|
97
97
|
# deactivate external manual page cross-references
|
98
|
-
gsub(/(?<=<a class="
|
98
|
+
gsub(/(?<=<a class="md2man-xref") href="\.\.(.+?)"/) do
|
99
99
|
$& if webs.include? 'man' + $1
|
100
100
|
end
|
101
101
|
|
@@ -116,9 +116,7 @@ mkds.zip(webs).each do |src, dst|
|
|
116
116
|
'</div>',
|
117
117
|
'</div>',
|
118
118
|
'<div class="container-fluid">',
|
119
|
-
|
120
|
-
output,
|
121
|
-
'</div>',
|
119
|
+
output,
|
122
120
|
'</div>',
|
123
121
|
].join
|
124
122
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'redcarpet'
|
2
2
|
require 'md2man/roff'
|
3
3
|
|
4
|
-
module Md2Man
|
4
|
+
module Md2Man::Roff
|
5
|
+
|
5
6
|
class Engine < Redcarpet::Render::Base
|
6
|
-
include Roff
|
7
|
+
include Md2Man::Roff
|
7
8
|
end
|
8
9
|
|
9
|
-
ENGINE = Redcarpet::Markdown.new(
|
10
|
-
Md2Man::Engine,
|
10
|
+
ENGINE = Redcarpet::Markdown.new(Engine,
|
11
11
|
:tables => true,
|
12
12
|
:autolink => true,
|
13
13
|
:superscript => true,
|
@@ -15,4 +15,5 @@ module Md2Man
|
|
15
15
|
:no_intra_emphasis => false,
|
16
16
|
:fenced_code_blocks => true
|
17
17
|
)
|
18
|
+
|
18
19
|
end
|
data/lib/md2man/roff.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'md2man/document'
|
2
2
|
|
3
|
-
module Md2Man
|
4
|
-
module Roff
|
3
|
+
module Md2Man::Roff
|
5
4
|
|
6
|
-
include Document
|
5
|
+
include Md2Man::Document
|
7
6
|
|
8
7
|
#---------------------------------------------------------------------------
|
9
8
|
# document-level processing
|
@@ -43,7 +42,7 @@ module Roff
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def block_code code, language
|
46
|
-
code = escape_backslashes(
|
45
|
+
code = escape_backslashes(code)
|
47
46
|
block_quote "\n.nf\n#{code.chomp}\n.fi\n"
|
48
47
|
end
|
49
48
|
|
@@ -133,8 +132,8 @@ module Roff
|
|
133
132
|
# span-level processing
|
134
133
|
#---------------------------------------------------------------------------
|
135
134
|
|
136
|
-
def reference
|
137
|
-
"\n.BR #{page} (#{section})#{addendum}\n"
|
135
|
+
def reference input_match, output_match
|
136
|
+
"\n.BR #{input_match[:page]} (#{input_match[:section]})#{output_match[:addendum]}\n"
|
138
137
|
end
|
139
138
|
|
140
139
|
def linebreak
|
@@ -162,7 +161,7 @@ module Roff
|
|
162
161
|
end
|
163
162
|
|
164
163
|
def codespan code
|
165
|
-
code = escape_backslashes(
|
164
|
+
code = escape_backslashes(code)
|
166
165
|
# NOTE: this double font sequence gives us the best of both worlds:
|
167
166
|
# man(1) shows it in bold and `groff -Thtml` shows it in monospace
|
168
167
|
"\\fB\\fC#{code}\\fR"
|
@@ -864,4 +863,3 @@ private
|
|
864
863
|
}
|
865
864
|
|
866
865
|
end
|
867
|
-
end
|
data/lib/md2man/version.rb
CHANGED
data/lib/md2man.rb
CHANGED
data/man/index.html
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
|
-
<meta name="generator" content="md2man
|
5
|
+
<meta name="generator" content="md2man 2.0.0 https://github.com/sunaku/md2man" />
|
6
6
|
<title>man/index</title>
|
7
7
|
<link rel="stylesheet" href="style.css"/>
|
8
8
|
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
9
9
|
</head>
|
10
|
-
<body><div class="container-fluid"><h2 id="man0">man0</h2><dl class="dl-horizontal"><dt><a href="man0/README.html">README</a></dt><dd></dd></dl><dl class="dl-horizontal"><dt><a href="man0/VERSION.html">VERSION</a></dt><dd></dd></dl><h2 id="man1">man1</h2><dl class="dl-horizontal"><dt><a href="man1/md2man-html.1.html">md2man-html(1)</a></dt><dd>convert md2man(
|
10
|
+
<body><div class="container-fluid"><h2 id="man0">man0</h2><dl class="dl-horizontal"><dt><a href="man0/README.html">README</a></dt><dd></dd></dl><dl class="dl-horizontal"><dt><a href="man0/VERSION.html">VERSION</a></dt><dd></dd></dl><h2 id="man1">man1</h2><dl class="dl-horizontal"><dt><a href="man1/md2man-html.1.html">md2man-html(1)</a></dt><dd>convert md2man(5) flavored markdown(7) into HTML</dd></dl><dl class="dl-horizontal"><dt><a href="man1/md2man-rake.1.html">md2man-rake(1)</a></dt><dd>run rake(1) tasks from md2man(1)</dd></dl><dl class="dl-horizontal"><dt><a href="man1/md2man-roff.1.html">md2man-roff(1)</a></dt><dd>convert md2man(5) flavored markdown(7) into roff(7)</dd></dl><h2 id="man5">man5</h2><dl class="dl-horizontal"><dt><a href="man5/md2man.5.html">md2man(5)</a></dt><dd>manual page flavoring for the markdown(7) file format</dd></dl></div></body>
|
11
11
|
</html>
|