md2man 1.3.2 → 1.4.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/HISTORY.markdown +22 -0
- data/README.markdown +24 -2
- data/bin/md2man +4 -3
- data/bin/md2man-html +48 -0
- data/lib/md2man/html/engine.rb +21 -0
- data/lib/md2man/html.rb +55 -0
- data/lib/md2man/rakefile.rb +71 -0
- data/lib/md2man/roff.rb +8 -1
- data/lib/md2man/version.rb +1 -1
- data/man/man1/md2man-html.1 +44 -0
- data/man/man1/md2man.1 +4 -4
- data/md2man.gemspec +1 -1
- data/test/md2man/html_test.rb +127 -0
- data/test/md2man/roff_test.rb +25 -1
- metadata +12 -4
data/HISTORY.markdown
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## Version 1.4.0 (2012-10-14)
|
2
|
+
|
3
|
+
Minor:
|
4
|
+
|
5
|
+
* roff: emit non-first H1 headings as H2 headings
|
6
|
+
|
7
|
+
* html: add `Md2Man::HTML::Engine` class for HTML manual page generation
|
8
|
+
|
9
|
+
* html: add md2man-html(1) bin script for command line access to the above
|
10
|
+
|
11
|
+
* html: add ID attributes on all headings for easy permalinking
|
12
|
+
|
13
|
+
* rake: add `md2man/rakefile` to process markdown files in man/
|
14
|
+
|
15
|
+
This library provides a `rake md2man` task that builds UNIX and HTML
|
16
|
+
manual pages from Markdown files (with ".markdown", ".mkd", or ".md"
|
17
|
+
extension) inside your `man/man*/` directories. It also provides
|
18
|
+
sub-tasks to build *only* UNIX or HTML manual pages separately.
|
19
|
+
|
20
|
+
It also hooks into Bundler's gem packaging tasks to automatically build
|
21
|
+
your manual pages for packaging into a gem. See the README for details.
|
22
|
+
|
1
23
|
## Version 1.3.2 (2012-10-13)
|
2
24
|
|
3
25
|
Patch:
|
data/README.markdown
CHANGED
@@ -104,8 +104,30 @@ md2man extends [Markdown] syntax in the following ways, as provisioned in the
|
|
104
104
|
|
105
105
|
md2man extends [Markdown] semantics in the following ways:
|
106
106
|
|
107
|
-
*
|
108
|
-
in the
|
107
|
+
* The first top-level heading (H1) found in the document is emitted as `.TH`
|
108
|
+
in the roff(7) output to define the UNIX manual page's header and footer.
|
109
|
+
Any subsequent top-level headings (H1) are treated as second-level (H2).
|
110
|
+
|
111
|
+
### Pre-building man pages
|
112
|
+
|
113
|
+
Add the following lines to your gemspec:
|
114
|
+
|
115
|
+
s.files += Dir['man/man?/*.?']
|
116
|
+
s.add_development_dependency 'md2man', '~> 1.4'
|
117
|
+
|
118
|
+
Add the following line to your Rakefile:
|
119
|
+
|
120
|
+
require 'md2man/rakefile'
|
121
|
+
|
122
|
+
You now have a `rake md2man` task that builds manual pages from Markdown files
|
123
|
+
(with ".markdown", ".mkd", or ".md" extension) inside `man/man*/` directories.
|
124
|
+
There are also sub-tasks to build *only* UNIX or HTML manual pages separately.
|
125
|
+
|
126
|
+
If you're using Bundler, this task also hooks into Bundler's gem packaging
|
127
|
+
tasks and ensures that your manual pages are built for packaging into a gem:
|
128
|
+
|
129
|
+
bundle exec rake build
|
130
|
+
gem spec pkg/*.gem | fgrep man/man
|
109
131
|
|
110
132
|
## License
|
111
133
|
|
data/bin/md2man
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
=begin =======================================================================
|
3
3
|
|
4
|
-
# MD2MAN 1 2012-10-
|
4
|
+
# MD2MAN 1 2012-10-14 1.4.0
|
5
5
|
|
6
6
|
## NAME
|
7
7
|
|
@@ -32,8 +32,9 @@ md2man extends markdown(7) syntax in the following ways, as provisioned in the
|
|
32
32
|
|
33
33
|
md2man extends markdown(7) semantics in the following ways:
|
34
34
|
|
35
|
-
*
|
35
|
+
* The first top-level heading (H1) found in the document is emitted as `.TH`
|
36
36
|
in the roff(7) output to define the UNIX manual page's header and footer.
|
37
|
+
Any subsequent top-level headings (H1) are treated as second-level (H2).
|
37
38
|
|
38
39
|
### Markdown extensions
|
39
40
|
|
@@ -53,7 +54,7 @@ The following [Redcarpet] extensions are enabled while processing markdown(7):
|
|
53
54
|
|
54
55
|
## SEE ALSO
|
55
56
|
|
56
|
-
|
57
|
+
md2man-html(1)
|
57
58
|
|
58
59
|
[md2man]: https://github.com/sunaku/md2man
|
59
60
|
[Redcarpet]: https://github.com/vmg/redcarpet
|
data/bin/md2man-html
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
=begin =======================================================================
|
3
|
+
|
4
|
+
# MD2MAN-HTML 1 2012-10-14 1.4.0
|
5
|
+
|
6
|
+
## NAME
|
7
|
+
|
8
|
+
md2man-html - convert md2man(1) flavored markdown(7) into HTML
|
9
|
+
|
10
|
+
## SYNOPSIS
|
11
|
+
|
12
|
+
`md2man-html` [*OPTION*]... [*FILE*]
|
13
|
+
|
14
|
+
## DESCRIPTION
|
15
|
+
|
16
|
+
This program converts the markdown(7) input from the given *FILE* into HTML
|
17
|
+
and then prints the result to stdout. stdin is read if *FILE* is not given.
|
18
|
+
|
19
|
+
### Document format
|
20
|
+
|
21
|
+
See md2man(1) for details about the document format and Markdown extensions.
|
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"
|
27
|
+
attributes.
|
28
|
+
|
29
|
+
For example, the markdown(7) reference would be converted into HTML as:
|
30
|
+
|
31
|
+
<a class="manpage-reference" href="../man7/markdown.7.html">markdown(7)</a>
|
32
|
+
|
33
|
+
## OPTIONS
|
34
|
+
|
35
|
+
`-h`, `--help`
|
36
|
+
Show this help manual.
|
37
|
+
|
38
|
+
## SEE ALSO
|
39
|
+
|
40
|
+
md2man(1)
|
41
|
+
|
42
|
+
=end =========================================================================
|
43
|
+
|
44
|
+
require 'binman'
|
45
|
+
BinMan.help
|
46
|
+
|
47
|
+
require 'md2man/html/engine'
|
48
|
+
puts Md2Man::HTML::ENGINE.render(ARGF.read)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'md2man/html'
|
3
|
+
|
4
|
+
module Md2Man
|
5
|
+
module HTML
|
6
|
+
|
7
|
+
class Engine < Redcarpet::Render::HTML
|
8
|
+
include HTML
|
9
|
+
end
|
10
|
+
|
11
|
+
ENGINE = Redcarpet::Markdown.new(Engine,
|
12
|
+
:tables => true,
|
13
|
+
:autolink => true,
|
14
|
+
:superscript => true,
|
15
|
+
:strikethrough => true,
|
16
|
+
:no_intra_emphasis => false,
|
17
|
+
:fenced_code_blocks => true
|
18
|
+
)
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/md2man/html.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'md2man/document'
|
3
|
+
|
4
|
+
module Md2Man
|
5
|
+
module HTML
|
6
|
+
|
7
|
+
include Document
|
8
|
+
|
9
|
+
#---------------------------------------------------------------------------
|
10
|
+
# block-level processing
|
11
|
+
#---------------------------------------------------------------------------
|
12
|
+
|
13
|
+
def normal_paragraph text
|
14
|
+
"<p>#{text}</p>"
|
15
|
+
end
|
16
|
+
|
17
|
+
def tagged_paragraph text
|
18
|
+
head, *body = text.lines.to_a
|
19
|
+
"<dl><dt>#{head.chomp}</dt><dd>#{body.join}</dd></dl>"
|
20
|
+
end
|
21
|
+
|
22
|
+
def indented_paragraph text
|
23
|
+
"<dl><dd>#{text}</dd></dl>"
|
24
|
+
end
|
25
|
+
|
26
|
+
def block_code code, language
|
27
|
+
"<pre>#{codespan(super)}</pre>"
|
28
|
+
end
|
29
|
+
|
30
|
+
def header text, level
|
31
|
+
id = text.gsub(/<.+?>/, '-'). # strip all HTML tags
|
32
|
+
gsub(/\W+/, '-').gsub(/^-|-$/, '') # fold non-word chars
|
33
|
+
%{<h#{level} id="#{id}">#{text}</h#{level}>}
|
34
|
+
end
|
35
|
+
|
36
|
+
#---------------------------------------------------------------------------
|
37
|
+
# span-level processing
|
38
|
+
#---------------------------------------------------------------------------
|
39
|
+
|
40
|
+
def codespan code
|
41
|
+
"<code>#{CGI.escapeHTML(super)}</code>"
|
42
|
+
end
|
43
|
+
|
44
|
+
def reference page, section, addendum
|
45
|
+
url = reference_url(page, section)
|
46
|
+
%{<a class="manpage-reference" href="#{url}">#{page}(#{section})</a>#{addendum}}
|
47
|
+
end
|
48
|
+
|
49
|
+
# You can override this in a derived class to compute URLs as you like!
|
50
|
+
def reference_url page, section
|
51
|
+
"../man#{section}/#{page}.#{section}.html"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
# build man pages before building ruby gem using bundler
|
4
|
+
%w[build install release].each {|t| task t => :md2man }
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
desc 'Build manual pages from Markdown files in man/.'
|
8
|
+
task :md2man => ['md2man:man', 'md2man:web']
|
9
|
+
#-----------------------------------------------------------------------------
|
10
|
+
|
11
|
+
mkds = FileList['man/man*/*.{markdown,mkd,md}']
|
12
|
+
mans = mkds.pathmap('%X')
|
13
|
+
webs = mans.pathmap('%p.html')
|
14
|
+
|
15
|
+
render_file_task = lambda do |src, dst, renderer|
|
16
|
+
directory dir = dst.pathmap('%d')
|
17
|
+
file dst => [dir, src] do
|
18
|
+
input = File.read(src)
|
19
|
+
output = renderer.call(input)
|
20
|
+
File.open(dst, 'w') {|f| f << output }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#-----------------------------------------------------------------------------
|
25
|
+
desc 'Build UNIX manual pages from Markdown files in man/.'
|
26
|
+
task 'md2man:man' => mans
|
27
|
+
#-----------------------------------------------------------------------------
|
28
|
+
|
29
|
+
mkds.zip(mans).each do |src, dst|
|
30
|
+
render_file_task.call src, dst, lambda {|input|
|
31
|
+
require 'md2man/engine'
|
32
|
+
Md2Man::ENGINE.render(input)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
#-----------------------------------------------------------------------------
|
37
|
+
desc 'Build HTML manual pages from Markdown files in man/.'
|
38
|
+
task 'md2man:web' => 'man/index.html'
|
39
|
+
#-----------------------------------------------------------------------------
|
40
|
+
|
41
|
+
file 'man/index.html' => webs do |t|
|
42
|
+
output = []
|
43
|
+
dirs = webs.group_by {|web| web.pathmap('%d') }.each do |dir, dir_webs|
|
44
|
+
subdir = dir.pathmap('%f')
|
45
|
+
output << %{<h2 id="#{subdir}">#{subdir}</h2>}
|
46
|
+
dir_webs.each do |web|
|
47
|
+
title = web.pathmap('%n').sub(/\.(.+)$/, '(\1)')
|
48
|
+
link = %{<a href="#{subdir}/#{web.pathmap('%f')}">#{title}</a>}
|
49
|
+
info = File.read(web).scan(%r{<h2.*?>NAME</h2>(.+?)<h2}m).flatten.first.
|
50
|
+
to_s.split(/\s+-\s+/, 2).last.to_s.gsub(/<.+?>/, '') # strip HTML
|
51
|
+
output << "<dl><dt>#{link}</dt><dd>#{info}</dd></dl>"
|
52
|
+
end
|
53
|
+
File.open("#{dir}/index.html", 'w') do |f|
|
54
|
+
f << %{<meta http-equiv="refresh" content="0;url=../index.html##{subdir}"/>}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
File.open(t.name, 'w') {|f| f.puts output }
|
58
|
+
end
|
59
|
+
|
60
|
+
mkds.zip(webs).each do |src, dst|
|
61
|
+
render_file_task.call src, dst, lambda {|input|
|
62
|
+
require 'md2man/html/engine'
|
63
|
+
output = Md2Man::HTML::ENGINE.render(input)
|
64
|
+
navbar = '<div class="manpath-navigation">' + [
|
65
|
+
%{<a href="../index.html">#{dst.pathmap('%1d')}</a>},
|
66
|
+
%{<a href="index.html">#{dst.pathmap('%-1d')}</a>},
|
67
|
+
%{<a href="">#{dst.pathmap('%n')}</a>},
|
68
|
+
].join(' → ') + '</div>'
|
69
|
+
[navbar, output, navbar].join('<hr/>')
|
70
|
+
}
|
71
|
+
end
|
data/lib/md2man/roff.rb
CHANGED
@@ -12,6 +12,7 @@ module Roff
|
|
12
12
|
def preprocess document
|
13
13
|
@ordered_list_id = 0
|
14
14
|
@table_cells = {}
|
15
|
+
@h1_seen = false
|
15
16
|
super
|
16
17
|
end
|
17
18
|
|
@@ -57,7 +58,13 @@ module Roff
|
|
57
58
|
def header text, level
|
58
59
|
macro =
|
59
60
|
case level
|
60
|
-
when 1
|
61
|
+
when 1
|
62
|
+
if @h1_seen
|
63
|
+
:SH
|
64
|
+
else
|
65
|
+
@h1_seen = true
|
66
|
+
:TH
|
67
|
+
end
|
61
68
|
when 2 then :SH
|
62
69
|
else :SS
|
63
70
|
end
|
data/lib/md2man/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
.TH MD2MAN\-HTML 1 2012\-10\-14 1.4.0
|
2
|
+
.SH NAME
|
3
|
+
.PP
|
4
|
+
md2man\-html \- convert
|
5
|
+
.BR md2man (1)
|
6
|
+
flavored
|
7
|
+
.BR markdown (7)
|
8
|
+
into HTML
|
9
|
+
.SH SYNOPSIS
|
10
|
+
.PP
|
11
|
+
\fB\fCmd2man-html\fR [\fIOPTION\fP]... [\fIFILE\fP]
|
12
|
+
.SH DESCRIPTION
|
13
|
+
.PP
|
14
|
+
This program converts the
|
15
|
+
.BR markdown (7)
|
16
|
+
input from the given \fIFILE\fP into HTML
|
17
|
+
and then prints the result to stdout. stdin is read if \fIFILE\fP is not given.
|
18
|
+
.SS Document format
|
19
|
+
.PP
|
20
|
+
See
|
21
|
+
.BR md2man (1)
|
22
|
+
for details about the document format and Markdown extensions.
|
23
|
+
.SS Cross linking
|
24
|
+
.PP
|
25
|
+
References to other manual pages are converted into hyperlinks that have
|
26
|
+
class="manpage\-reference" and href="../man${section}/${page}.${section}.html"
|
27
|
+
attributes.
|
28
|
+
.PP
|
29
|
+
For example, the
|
30
|
+
.BR markdown (7)
|
31
|
+
reference would be converted into HTML as:
|
32
|
+
.PP
|
33
|
+
.RS
|
34
|
+
.nf
|
35
|
+
<a class="manpage-reference" href="../man7/markdown.7.html">markdown(7)</a>
|
36
|
+
.fi
|
37
|
+
.RE
|
38
|
+
.SH OPTIONS
|
39
|
+
.TP
|
40
|
+
\fB\fC-h\fR, \fB\fC--help\fR
|
41
|
+
Show this help manual.
|
42
|
+
.SH SEE ALSO
|
43
|
+
.PP
|
44
|
+
.BR md2man (1)
|
data/man/man1/md2man.1
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
.TH MD2MAN 1 2012\-10\-
|
1
|
+
.TH MD2MAN 1 2012\-10\-14 1.4.0
|
2
2
|
.SH NAME
|
3
3
|
.PP
|
4
4
|
md2man \- convert
|
@@ -49,10 +49,11 @@ md2man extends
|
|
49
49
|
semantics in the following ways:
|
50
50
|
.RS
|
51
51
|
.IP \(bu 2
|
52
|
-
|
52
|
+
The first top\-level heading (H1) found in the document is emitted as \fB\fC.TH\fR
|
53
53
|
in the
|
54
54
|
.BR roff (7)
|
55
55
|
output to define the UNIX manual page's header and footer.
|
56
|
+
Any subsequent top\-level headings (H1) are treated as second\-level (H2).
|
56
57
|
.RE
|
57
58
|
.SS Markdown extensions
|
58
59
|
.PP
|
@@ -81,5 +82,4 @@ fenced_code_blocks
|
|
81
82
|
Show this help manual.
|
82
83
|
.SH SEE ALSO
|
83
84
|
.PP
|
84
|
-
.BR
|
85
|
-
.BR roff (7)
|
85
|
+
.BR md2man-html (1)
|
data/md2man.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = 'markdown to manpage'
|
12
12
|
s.description = 'Converts markdown documents into UNIX manual pages.'
|
13
13
|
|
14
|
-
s.files = `git ls-files`.split("\n") + Dir['man
|
14
|
+
s.files = `git ls-files`.split("\n") + Dir['man/man?/*.?']
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ['lib']
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'md2man/html/engine'
|
3
|
+
|
4
|
+
describe 'html engine' do
|
5
|
+
before do
|
6
|
+
@markdown = Redcarpet::Markdown.new(Md2Man::HTML::Engine)
|
7
|
+
end
|
8
|
+
|
9
|
+
def heredoc document
|
10
|
+
document.gsub(/^\s*\|/, '').chomp
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'renders nothing as nothing' do
|
14
|
+
@markdown.render('').must_be_empty
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'renders paragraphs' do
|
18
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
19
|
+
|just some paragraph
|
20
|
+
|spanning
|
21
|
+
|multiple
|
22
|
+
|lines
|
23
|
+
|but within 4-space indent
|
24
|
+
INPUT
|
25
|
+
|<p>just some paragraph
|
26
|
+
|spanning
|
27
|
+
|multiple
|
28
|
+
|lines
|
29
|
+
|but within 4-space indent</p>
|
30
|
+
OUTPUT
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'renders tagged paragraphs with uniformly two-space indented bodies' do
|
34
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
35
|
+
|just some paragraph
|
36
|
+
| spanning
|
37
|
+
| multiple
|
38
|
+
| lines
|
39
|
+
| but within 4-space indent
|
40
|
+
|
|
41
|
+
| and a single line following
|
42
|
+
|
|
43
|
+
| and multiple
|
44
|
+
| lines following
|
45
|
+
INPUT
|
46
|
+
|<dl><dt>just some paragraph</dt><dd>spanning
|
47
|
+
|multiple
|
48
|
+
|lines
|
49
|
+
|but within 4-space indent</dd></dl><dl><dd>and a single line following</dd></dl><dl><dd>and multiple
|
50
|
+
|lines following</dd></dl>
|
51
|
+
OUTPUT
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'renders references to other man pages as hyperlinks in middle of line' do
|
55
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
56
|
+
|convert them from markdown(7) into roff(7), using
|
57
|
+
INPUT
|
58
|
+
|<p>convert them from <a class="manpage-reference" href="../man7/markdown.7.html">markdown(7)</a> into <a class="manpage-reference" href="../man7/roff.7.html">roff(7)</a>, using</p>
|
59
|
+
OUTPUT
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'renders references to other man pages as hyperlinks at beginning of line' do
|
63
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
64
|
+
|markdown(1) into roff(2)
|
65
|
+
INPUT
|
66
|
+
|<p><a class="manpage-reference" href="../man1/markdown.1.html">markdown(1)</a> into <a class="manpage-reference" href="../man2/roff.2.html">roff(2)</a></p>
|
67
|
+
OUTPUT
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'does not render references inside code blocks' do
|
71
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
72
|
+
| this is a code block
|
73
|
+
| containing markdown(7),
|
74
|
+
| roff(7), and much more!
|
75
|
+
INPUT
|
76
|
+
|<pre><code>this is a code block
|
77
|
+
|containing markdown(7),
|
78
|
+
|roff(7), and much more!
|
79
|
+
|</code></pre>
|
80
|
+
OUTPUT
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'does not render references inside code spans' do
|
84
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
85
|
+
|this is a code span `containing markdown(7), roff(7), and` much more!
|
86
|
+
INPUT
|
87
|
+
|<p>this is a code span <code>containing markdown(7), roff(7), and</code> much more!</p>
|
88
|
+
OUTPUT
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'escapes backslashes inside code blocks' do
|
92
|
+
# NOTE: we have to escape backslashes in the INPUT to
|
93
|
+
# prevent Ruby from interpreting them as escapes
|
94
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
95
|
+
| _______ _______
|
96
|
+
| ___ /___________ /__
|
97
|
+
| _ __/ __ \\ __/ /_/
|
98
|
+
| / /_/ /_/ / / / ,\\
|
99
|
+
| \\__/\\____/_/ /_/|_\\
|
100
|
+
| >>>------>
|
101
|
+
INPUT
|
102
|
+
|<pre><code>_______ _______
|
103
|
+
| ___ /___________ /__
|
104
|
+
| _ __/ __ \\ __/ /_/
|
105
|
+
| / /_/ /_/ / / / ,\\
|
106
|
+
| \\__/\\____/_/ /_/|_\\
|
107
|
+
| >>>------>
|
108
|
+
|</code></pre>
|
109
|
+
OUTPUT
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'adds ID attributes on headings for permalinking' do
|
113
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
114
|
+
|# foo *BAR*
|
115
|
+
|## bar BAZ
|
116
|
+
|### --BAZ-QUX--
|
117
|
+
|#### qux (MOZ)
|
118
|
+
|##### {m}oz END
|
119
|
+
INPUT
|
120
|
+
<h1 id="foo-BAR">foo <em>BAR</em></h1>\
|
121
|
+
<h2 id="bar-BAZ">bar BAZ</h2>\
|
122
|
+
<h3 id="BAZ-QUX">--BAZ-QUX--</h3>\
|
123
|
+
<h4 id="qux-MOZ">qux (MOZ)</h4>\
|
124
|
+
<h5 id="m-oz-END">{m}oz END</h5>
|
125
|
+
OUTPUT
|
126
|
+
end
|
127
|
+
end
|
data/test/md2man/roff_test.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
require 'test_helper'
|
10
10
|
require 'md2man/engine'
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe 'roff engine' do
|
13
13
|
before do
|
14
14
|
@markdown = Redcarpet::Markdown.new(
|
15
15
|
Md2Man::Engine,
|
@@ -229,6 +229,30 @@ describe Md2Man::Roff do
|
|
229
229
|
OUTPUT
|
230
230
|
end
|
231
231
|
|
232
|
+
it 'renders non-first top-level headings as 2nd-level headings' do
|
233
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
234
|
+
|just some h1 heading
|
235
|
+
|====================
|
236
|
+
|
|
237
|
+
|yet another h1 heading
|
238
|
+
|======================
|
239
|
+
INPUT
|
240
|
+
|.TH just some h1 heading
|
241
|
+
|.SH yet another h1 heading
|
242
|
+
OUTPUT
|
243
|
+
|
244
|
+
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
245
|
+
|BINMAN 1 "2011-11-05" "1.1.0" "Ruby User Manuals"
|
246
|
+
|=================================================
|
247
|
+
|
|
248
|
+
|DUPMAN 1 "2011-11-05" "1.1.0" "Ruby User Manuals"
|
249
|
+
|=================================================
|
250
|
+
INPUT
|
251
|
+
|.TH BINMAN 1 "2011\\-11\\-05" "1.1.0" "Ruby User Manuals"
|
252
|
+
|.SH DUPMAN 1 "2011\\-11\\-05" "1.1.0" "Ruby User Manuals"
|
253
|
+
OUTPUT
|
254
|
+
end
|
255
|
+
|
232
256
|
it 'renders 2nd-level headings' do
|
233
257
|
@markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
|
234
258
|
|just some h2 heading
|
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
|
+
version: 1.4.0
|
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: 2012-10-
|
12
|
+
date: 2012-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: binman
|
@@ -80,6 +80,7 @@ email:
|
|
80
80
|
- sunaku@gmail.com
|
81
81
|
executables:
|
82
82
|
- md2man
|
83
|
+
- md2man-html
|
83
84
|
extensions: []
|
84
85
|
extra_rdoc_files: []
|
85
86
|
files:
|
@@ -92,14 +93,20 @@ files:
|
|
92
93
|
- README.markdown
|
93
94
|
- Rakefile
|
94
95
|
- bin/md2man
|
96
|
+
- bin/md2man-html
|
95
97
|
- lib/md2man.rb
|
96
98
|
- lib/md2man/document.rb
|
97
99
|
- lib/md2man/engine.rb
|
100
|
+
- lib/md2man/html.rb
|
101
|
+
- lib/md2man/html/engine.rb
|
102
|
+
- lib/md2man/rakefile.rb
|
98
103
|
- lib/md2man/roff.rb
|
99
104
|
- lib/md2man/version.rb
|
100
105
|
- md2man.gemspec
|
106
|
+
- test/md2man/html_test.rb
|
101
107
|
- test/md2man/roff_test.rb
|
102
108
|
- test/test_helper.rb
|
109
|
+
- man/man1/md2man-html.1
|
103
110
|
- man/man1/md2man.1
|
104
111
|
homepage: http://github.com/sunaku/md2man
|
105
112
|
licenses: []
|
@@ -115,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
122
|
version: '0'
|
116
123
|
segments:
|
117
124
|
- 0
|
118
|
-
hash:
|
125
|
+
hash: -1838080913948275679
|
119
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
127
|
none: false
|
121
128
|
requirements:
|
@@ -124,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
131
|
version: '0'
|
125
132
|
segments:
|
126
133
|
- 0
|
127
|
-
hash:
|
134
|
+
hash: -1838080913948275679
|
128
135
|
requirements: []
|
129
136
|
rubyforge_project:
|
130
137
|
rubygems_version: 1.8.23
|
@@ -132,5 +139,6 @@ signing_key:
|
|
132
139
|
specification_version: 3
|
133
140
|
summary: markdown to manpage
|
134
141
|
test_files:
|
142
|
+
- test/md2man/html_test.rb
|
135
143
|
- test/md2man/roff_test.rb
|
136
144
|
- test/test_helper.rb
|