nronn 0.10.1.pre2
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.
- checksums.yaml +7 -0
- data/AUTHORS +8 -0
- data/CHANGES +230 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +72 -0
- data/INSTALLING.md +92 -0
- data/LICENSE.txt +12 -0
- data/README.md +131 -0
- data/Rakefile +153 -0
- data/bin/ronn +253 -0
- data/completion/bash/ronn +32 -0
- data/completion/zsh/_ronn +24 -0
- data/config.ru +15 -0
- data/lib/ronn/document.rb +530 -0
- data/lib/ronn/index.rb +180 -0
- data/lib/ronn/roff.rb +393 -0
- data/lib/ronn/server.rb +67 -0
- data/lib/ronn/template/80c.css +6 -0
- data/lib/ronn/template/dark.css +18 -0
- data/lib/ronn/template/darktoc.css +17 -0
- data/lib/ronn/template/default.html +41 -0
- data/lib/ronn/template/man.css +100 -0
- data/lib/ronn/template/print.css +5 -0
- data/lib/ronn/template/screen.css +105 -0
- data/lib/ronn/template/toc.css +27 -0
- data/lib/ronn/template.rb +173 -0
- data/lib/ronn/utils.rb +57 -0
- data/lib/ronn.rb +47 -0
- data/man/index.html +78 -0
- data/man/index.txt +15 -0
- data/man/ronn-format.7 +145 -0
- data/man/ronn-format.7.ronn +157 -0
- data/man/ronn.1 +227 -0
- data/man/ronn.1.ronn +316 -0
- data/nronn.gemspec +136 -0
- data/test/angle_bracket_syntax.html +27 -0
- data/test/angle_bracket_syntax.roff +24 -0
- data/test/angle_bracket_syntax.ronn +22 -0
- data/test/backticks.html +14 -0
- data/test/backticks.ronn +10 -0
- data/test/basic_document.html +8 -0
- data/test/basic_document.ronn +4 -0
- data/test/circumflexes.ronn +1 -0
- data/test/code_blocks.html +38 -0
- data/test/code_blocks.roff +38 -0
- data/test/code_blocks.ronn +41 -0
- data/test/code_blocks_regression +19 -0
- data/test/code_blocks_regression.html +38 -0
- data/test/code_blocks_regression.ronn +40 -0
- data/test/contest.rb +70 -0
- data/test/custom_title_document.html +6 -0
- data/test/custom_title_document.ronn +5 -0
- data/test/definition_list_syntax.html +25 -0
- data/test/definition_list_syntax.roff +19 -0
- data/test/definition_list_syntax.ronn +18 -0
- data/test/dots_at_line_start_test.roff +19 -0
- data/test/dots_at_line_start_test.ronn +12 -0
- data/test/ellipses.roff +7 -0
- data/test/ellipses.ronn +7 -0
- data/test/entity_encoding_test.html +42 -0
- data/test/entity_encoding_test.roff +51 -0
- data/test/entity_encoding_test.ronn +34 -0
- data/test/index.txt +8 -0
- data/test/markdown_syntax.html +954 -0
- data/test/markdown_syntax.roff +907 -0
- data/test/markdown_syntax.ronn +881 -0
- data/test/middle_paragraph.html +14 -0
- data/test/middle_paragraph.roff +9 -0
- data/test/middle_paragraph.ronn +10 -0
- data/test/missing_spaces.roff +7 -0
- data/test/missing_spaces.ronn +2 -0
- data/test/nested_list.ronn +19 -0
- data/test/nested_list_with_code.html +14 -0
- data/test/nested_list_with_code.roff +11 -0
- data/test/nested_list_with_code.ronn +6 -0
- data/test/ordered_list.html +28 -0
- data/test/ordered_list.roff +25 -0
- data/test/ordered_list.ronn +21 -0
- data/test/page.with.periods.in.name.5.ronn +4 -0
- data/test/pre_block_with_quotes.roff +8 -0
- data/test/pre_block_with_quotes.ronn +6 -0
- data/test/section_reference_links.html +16 -0
- data/test/section_reference_links.roff +7 -0
- data/test/section_reference_links.ronn +12 -0
- data/test/single_quotes.html +11 -0
- data/test/single_quotes.roff +5 -0
- data/test/single_quotes.ronn +9 -0
- data/test/tables.ronn +24 -0
- data/test/test_ronn.rb +124 -0
- data/test/test_ronn_document.rb +186 -0
- data/test/test_ronn_index.rb +73 -0
- data/test/titleless_document.html +9 -0
- data/test/titleless_document.ronn +3 -0
- data/test/underline_spacing_test.roff +13 -0
- data/test/underline_spacing_test.ronn +11 -0
- metadata +309 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class='mp'>
|
2
|
+
|
3
|
+
<h2 id="NAME">NAME</h2>
|
4
|
+
<p class="man-name">
|
5
|
+
<code>test</code> - <span class="man-whatis">just a ronn test</span>
|
6
|
+
</p>
|
7
|
+
<h2 id="TEST">TEST</h2>
|
8
|
+
|
9
|
+
<p>Foo</p>
|
10
|
+
|
11
|
+
<p>Always use <code>attr_reader</code>, <code>attr_writer</code> or <code>attr_accessor</code>. Do not use <code>for...in</code>; use each instead. Do not use <code>and</code>/<code>or</code>; use <code>&&</code>/<code>||</code> instead.</p>
|
12
|
+
|
13
|
+
<p>Bar</p>
|
14
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
.TH "TEST" "1" "January 1979" ""
|
2
|
+
.SH "NAME"
|
3
|
+
\fBtest\fR \- just a ronn test
|
4
|
+
.SH "TEST"
|
5
|
+
Foo
|
6
|
+
.P
|
7
|
+
Always use \fBattr_reader\fR, \fBattr_writer\fR or \fBattr_accessor\fR\. Do not use \fBfor\|\.\|\.\|\.in\fR; use each instead\. Do not use \fBand\fR/\fBor\fR; use \fB&&\fR/\fB||\fR instead\.
|
8
|
+
.P
|
9
|
+
Bar
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class='mp'>
|
2
|
+
|
3
|
+
<h1 id="a-1-">a(1)</h1>
|
4
|
+
<ul>
|
5
|
+
<li>
|
6
|
+
<code>toggle_status</code>
|
7
|
+
<ul>
|
8
|
+
<li>Toggle the display of the status bar.</li>
|
9
|
+
</ul>
|
10
|
+
</li>
|
11
|
+
<li>
|
12
|
+
<code>spawn <executable> <additional args></code> TODO explain path-alike expansion</li>
|
13
|
+
</ul>
|
14
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
.TH "NESTED_LIST_WITH_CODE" "" "January 1979" ""
|
2
|
+
.IP "\(bu" 4
|
3
|
+
\fBtoggle_status\fR
|
4
|
+
.IP "\(bu" 4
|
5
|
+
Toggle the display of the status bar\.
|
6
|
+
.IP "" 0
|
7
|
+
|
8
|
+
.IP "\(bu" 4
|
9
|
+
\fBspawn <executable> <additional args>\fR TODO explain path\-alike expansion
|
10
|
+
.IP "" 0
|
11
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<div class='mp'>
|
2
|
+
|
3
|
+
<h1 id="Ordered-Lists">Ordered Lists</h1>
|
4
|
+
<h2 id="Simple-ordered-lists">Simple ordered lists</h2>
|
5
|
+
|
6
|
+
<h3 id="One-item-list">One-item list</h3>
|
7
|
+
|
8
|
+
<ol>
|
9
|
+
<li>Hello, world!</li>
|
10
|
+
</ol>
|
11
|
+
|
12
|
+
<h3 id="Three-item-list">Three-item list</h3>
|
13
|
+
|
14
|
+
<ol>
|
15
|
+
<li>Hello, world!</li>
|
16
|
+
<li>Item 2</li>
|
17
|
+
<li>Item 3</li>
|
18
|
+
</ol>
|
19
|
+
|
20
|
+
<h3 id="Four-item-list-with-all-1s">Four-item list with all 1s</h3>
|
21
|
+
|
22
|
+
<ol>
|
23
|
+
<li>Item 1</li>
|
24
|
+
<li>Item 2</li>
|
25
|
+
<li>Item 3</li>
|
26
|
+
<li>Item 4</li>
|
27
|
+
</ol>
|
28
|
+
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
.TH "ORDERED_LIST" "" "January 1979" ""
|
2
|
+
.SH "Simple ordered lists"
|
3
|
+
.SS "One\-item list"
|
4
|
+
.IP "1." 4
|
5
|
+
Hello, world!
|
6
|
+
.IP "" 0
|
7
|
+
.SS "Three\-item list"
|
8
|
+
.IP "1." 4
|
9
|
+
Hello, world!
|
10
|
+
.IP "2." 4
|
11
|
+
Item 2
|
12
|
+
.IP "3." 4
|
13
|
+
Item 3
|
14
|
+
.IP "" 0
|
15
|
+
.SS "Four\-item list with all 1s"
|
16
|
+
.IP "1." 4
|
17
|
+
Item 1
|
18
|
+
.IP "2." 4
|
19
|
+
Item 2
|
20
|
+
.IP "3." 4
|
21
|
+
Item 3
|
22
|
+
.IP "4." 4
|
23
|
+
Item 4
|
24
|
+
.IP "" 0
|
25
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Ordered Lists
|
2
|
+
=============
|
3
|
+
|
4
|
+
## Simple ordered lists
|
5
|
+
|
6
|
+
### One-item list
|
7
|
+
|
8
|
+
1. Hello, world!
|
9
|
+
|
10
|
+
### Three-item list
|
11
|
+
|
12
|
+
1. Hello, world!
|
13
|
+
2. Item 2
|
14
|
+
3. Item 3
|
15
|
+
|
16
|
+
### Four-item list with all 1s
|
17
|
+
|
18
|
+
1. Item 1
|
19
|
+
1. Item 2
|
20
|
+
1. Item 3
|
21
|
+
1. Item 4
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class='mp'>
|
2
|
+
|
3
|
+
<h2 id="NAME">NAME</h2>
|
4
|
+
<p class="man-name">
|
5
|
+
<code>section_reference_links</code> - <span class="man-whatis">linking to sections</span>
|
6
|
+
</p>
|
7
|
+
<h2 id="SECTION-1">SECTION 1</h2>
|
8
|
+
|
9
|
+
<p>See the following section.</p>
|
10
|
+
|
11
|
+
<h2 id="SECTION-2">SECTION 2</h2>
|
12
|
+
|
13
|
+
<p>See <a href="#SECTION-1" title="SECTION 1" data-bare-link="true">SECTION 1</a>
|
14
|
+
or <a href="#SECTION-1" title="SECTION 1" data-bare-link="true">to put it another way</a>
|
15
|
+
or even <a href="#SECTION-1" data-bare-link="true">like this</a></p>
|
16
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
section_reference_links(1) - linking to sections
|
2
|
+
================================================
|
3
|
+
|
4
|
+
## SECTION 1
|
5
|
+
|
6
|
+
See the following section.
|
7
|
+
|
8
|
+
## SECTION 2
|
9
|
+
|
10
|
+
See [SECTION 1][]
|
11
|
+
or [to put it another way][SECTION 1]
|
12
|
+
or even [like this](#SECTION-1)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class='mp'>
|
2
|
+
|
3
|
+
<h1 id="Single-quotes">Single quotes</h1>
|
4
|
+
<h2 id="Single-quote-at-beginning-of-line">Single quote at beginning of line</h2>
|
5
|
+
|
6
|
+
<p>'This phrase should appear as normal, starting with a single quote.'</p>
|
7
|
+
|
8
|
+
<h2 id="Quotes-in-middle-of-line">Quotes in middle of line</h2>
|
9
|
+
|
10
|
+
<p>When you've got single quotes (') in a line, they're regular quotes.</p>
|
11
|
+
</div>
|
data/test/tables.ronn
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Hello, world with tables
|
2
|
+
========================
|
3
|
+
|
4
|
+
|
5
|
+
## Simple table
|
6
|
+
|
7
|
+
| Syntax | Description |
|
8
|
+
| ----------- | ----------- |
|
9
|
+
| Header | Title |
|
10
|
+
| Paragraph | Text |
|
11
|
+
|
12
|
+
## Table with column alignment
|
13
|
+
|
14
|
+
| Syntax | Description | Test Text With A Long Header Name |
|
15
|
+
| :--- | :----: | ---: |
|
16
|
+
| Header | Title | Here's this |
|
17
|
+
| Paragraph | Text | And more |
|
18
|
+
|
19
|
+
## Table with embedded markup
|
20
|
+
|
21
|
+
| Header |
|
22
|
+
| ------ |
|
23
|
+
| Code: `some code` |
|
24
|
+
| Emphasis: *foo* and *bar* |
|
data/test/test_ronn.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'contest'
|
2
|
+
|
3
|
+
class RonnTest < Test::Unit::TestCase
|
4
|
+
testdir = File.dirname(__FILE__)
|
5
|
+
|
6
|
+
# setup PATH so that we execute the right ronn command
|
7
|
+
bindir = File.dirname(testdir) + '/bin'
|
8
|
+
ENV['PATH'] = "#{bindir}:#{ENV['PATH']}"
|
9
|
+
|
10
|
+
# make sure the load path is setup correctly
|
11
|
+
libdir = File.expand_path("#{testdir}/../lib")
|
12
|
+
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.any? { |path| File.expand_path(path) == libdir }
|
13
|
+
ENV['RUBYLIB'] = $LOAD_PATH.join(':')
|
14
|
+
|
15
|
+
require 'ronn'
|
16
|
+
|
17
|
+
test 'takes ronn text on stdin and produces roff on stdout' do
|
18
|
+
output = `echo '# hello(1) -- hello world' | ronn --date=2009-11-23`
|
19
|
+
lines = output.split("\n")
|
20
|
+
assert_equal 5, lines.size
|
21
|
+
assert_equal %(.\\" generated with nRonn/v#{Ronn.version}), lines.shift
|
22
|
+
assert_equal %(.\\" https://github.com/n-ronn/nronn/tree/#{Ronn.revision}), lines.shift
|
23
|
+
assert_equal %(.TH "HELLO" "1" "November 2009" ""), lines.shift
|
24
|
+
assert_equal %(.SH "NAME"), lines.shift
|
25
|
+
assert_equal %(\\fBhello\\fR \\- hello world), lines.shift
|
26
|
+
assert_equal 0, lines.size
|
27
|
+
end
|
28
|
+
|
29
|
+
def canonicalize(text)
|
30
|
+
text
|
31
|
+
.gsub(/^ +/, '')
|
32
|
+
.gsub(/\n/m, '')
|
33
|
+
.gsub(/ +/, ' ')
|
34
|
+
.tr('"', "'")
|
35
|
+
end
|
36
|
+
|
37
|
+
def flunk_with_diff(dest, wrong, output)
|
38
|
+
File.open(wrong, 'wb') { |f| f.write(output) }
|
39
|
+
if ENV['RONN_QUIET_TEST'] == '1'
|
40
|
+
flunk 'Output did not match expected.'
|
41
|
+
else
|
42
|
+
diff = `diff -u #{dest} #{wrong} 2>/dev/null`
|
43
|
+
flunk diff
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'produces html instead of roff with the --html argument' do
|
48
|
+
output = `echo '# hello(1) -- hello world' | ronn --html`
|
49
|
+
output = canonicalize(output)
|
50
|
+
assert_match(/<h2 id='NAME'>NAME<\/h2>/, output)
|
51
|
+
advertising = "<meta name='generator' content='nRonn/v" + Ronn.version +
|
52
|
+
' (https://github.com/n-ronn/nronn/tree/' + Ronn.revision + ")'>"
|
53
|
+
assert_match(/#{Regexp.escape(advertising)}/, output)
|
54
|
+
end
|
55
|
+
|
56
|
+
test 'produces html fragment with the --fragment argument' do
|
57
|
+
output = `echo '# hello(1) -- hello world' | ronn --fragment`
|
58
|
+
assert_equal [
|
59
|
+
"<div class='mp'>",
|
60
|
+
"<h2 id='NAME'>NAME</h2>",
|
61
|
+
"<p class='man-name'><code>hello</code>",
|
62
|
+
" - <span class='man-whatis'>hello world</span>",
|
63
|
+
'</p></div>'
|
64
|
+
].join, canonicalize(output)
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'abides by the RONN_MANUAL environment variable' do
|
68
|
+
output = `echo '# hello(1) -- hello world' | RONN_MANUAL='Some Manual' ronn --html`
|
69
|
+
assert_match(/Some Manual/, output)
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'abides by the RONN_DATE environment variable' do
|
73
|
+
output = `echo '# hello(1) -- hello world' | RONN_DATE=1979-01-01 ronn --html`
|
74
|
+
assert_match(/January 1979/, output)
|
75
|
+
end
|
76
|
+
|
77
|
+
test 'abides by the RONN_ORGANIZATION environment variable' do
|
78
|
+
output = `echo '# hello(1) -- hello world' | RONN_ORGANIZATION='GitHub' ronn --html`
|
79
|
+
assert_match(/GitHub/, output)
|
80
|
+
end
|
81
|
+
|
82
|
+
# ronn -> HTML file based tests
|
83
|
+
Dir[testdir + '/*.ronn'].each do |source|
|
84
|
+
dest = source.sub(/ronn$/, 'html')
|
85
|
+
next unless File.exist?(dest)
|
86
|
+
|
87
|
+
wrong = dest + '.wrong'
|
88
|
+
test File.basename(source, '.ronn') + ' HTML' do
|
89
|
+
output = `ronn --pipe --html --fragment #{source}`
|
90
|
+
expected = begin
|
91
|
+
File.read(dest)
|
92
|
+
rescue IOError
|
93
|
+
''
|
94
|
+
end
|
95
|
+
if expected != output
|
96
|
+
flunk_with_diff(dest, wrong, output)
|
97
|
+
elsif File.exist?(wrong)
|
98
|
+
File.unlink(wrong)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# ronn -> roff file based tests
|
104
|
+
Dir[testdir + '/*.ronn'].each do |source|
|
105
|
+
dest = source.sub(/ronn$/, 'roff')
|
106
|
+
next unless File.exist?(dest)
|
107
|
+
|
108
|
+
wrong = dest + '.wrong'
|
109
|
+
test File.basename(source, '.ronn') + ' roff' do
|
110
|
+
output = `ronn --pipe --roff --date=1979-01-01 #{source}`
|
111
|
+
.split("\n", 3).last # remove ronn version comments
|
112
|
+
expected = begin
|
113
|
+
File.read(dest)
|
114
|
+
rescue IOError
|
115
|
+
''
|
116
|
+
end
|
117
|
+
if expected != output
|
118
|
+
flunk_with_diff(dest, wrong, output)
|
119
|
+
elsif File.exist?(wrong)
|
120
|
+
File.unlink(wrong)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require 'contest'
|
2
|
+
require 'ronn/document'
|
3
|
+
|
4
|
+
class DocumentTest < Test::Unit::TestCase
|
5
|
+
SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ronn".freeze
|
6
|
+
|
7
|
+
def canonicalize(text)
|
8
|
+
text
|
9
|
+
.gsub(/^ +/, '')
|
10
|
+
.gsub(/\n/m, '')
|
11
|
+
.gsub(/ +/, ' ')
|
12
|
+
.tr('"', "'")
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'new with path' do
|
16
|
+
doc = Ronn::Document.new(SIMPLE_FILE)
|
17
|
+
assert_equal File.read(SIMPLE_FILE), doc.data
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'new with path and block' do
|
21
|
+
doc = Ronn::Document.new('hello.1.ronn') { '# hello(1) -- hello world' }
|
22
|
+
assert_equal '# hello(1) -- hello world', doc.data
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'new with path and block but missing name section' do
|
26
|
+
doc = Ronn::Document.new('foo.7.ronn') { '' }
|
27
|
+
assert_equal 'foo', doc.name
|
28
|
+
assert_equal '7', doc.section
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'new with non conventional path and missing name section' do
|
32
|
+
doc = Ronn::Document.new('bar.ronn') { '' }
|
33
|
+
assert_equal 'bar', doc.name
|
34
|
+
assert_equal nil, doc.section
|
35
|
+
assert_equal './bar.html', doc.path_for('html')
|
36
|
+
assert_equal './bar', doc.path_for('roff')
|
37
|
+
assert_equal './bar', doc.path_for('')
|
38
|
+
assert_equal './bar', doc.path_for(nil)
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'new with path and name section mismatch' do
|
42
|
+
doc = Ronn::Document.new('foo/rick.7.ronn') { "# randy(3) -- I'm confused." }
|
43
|
+
assert_equal 'randy', doc.name
|
44
|
+
assert_equal 'rick', doc.path_name
|
45
|
+
assert_equal '3', doc.section
|
46
|
+
assert_equal '7', doc.path_section
|
47
|
+
assert_equal 'rick.7', doc.basename
|
48
|
+
assert_equal 'foo/rick.7.bar', doc.path_for(:bar)
|
49
|
+
end
|
50
|
+
|
51
|
+
test 'new with no path and a name section' do
|
52
|
+
doc = Ronn::Document.new { '# brandy(5) -- wootderitis' }
|
53
|
+
assert_equal nil, doc.path_name
|
54
|
+
assert_equal nil, doc.path_section
|
55
|
+
assert_equal 'brandy', doc.name
|
56
|
+
assert_equal '5', doc.section
|
57
|
+
assert_equal 'brandy.5', doc.basename
|
58
|
+
assert_equal 'brandy.5.foo', doc.path_for(:foo)
|
59
|
+
end
|
60
|
+
|
61
|
+
1.upto(5) do |i|
|
62
|
+
dashes = '-' * i
|
63
|
+
|
64
|
+
test "new with no path and #{i} dashes in name" do
|
65
|
+
doc = Ronn::Document.new { "# brandy #{dashes} wootderitis" }
|
66
|
+
assert_equal 'brandy', doc.name
|
67
|
+
assert_equal nil, doc.section
|
68
|
+
assert_equal 'wootderitis', doc.tagline
|
69
|
+
end
|
70
|
+
|
71
|
+
test "new with no path and a name section and #{i} dashes in name" do
|
72
|
+
doc = Ronn::Document.new { "# brandy(5) #{dashes} wootderitis" }
|
73
|
+
assert_equal 'brandy', doc.name
|
74
|
+
assert_equal '5', doc.section
|
75
|
+
assert_equal 'wootderitis', doc.tagline
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'simple conventionally named document' do
|
80
|
+
setup do
|
81
|
+
@now = Time.now
|
82
|
+
@doc = Ronn::Document.new('hello.1.ronn') { '# hello(1) -- hello world' }
|
83
|
+
@doc.date = @now
|
84
|
+
end
|
85
|
+
|
86
|
+
should 'load data' do
|
87
|
+
assert_equal '# hello(1) -- hello world', @doc.data
|
88
|
+
end
|
89
|
+
|
90
|
+
should 'extract the manual page name from the filename or document' do
|
91
|
+
assert_equal 'hello', @doc.name
|
92
|
+
end
|
93
|
+
|
94
|
+
should 'extract the manual page section from the filename or document' do
|
95
|
+
assert_equal '1', @doc.section
|
96
|
+
end
|
97
|
+
|
98
|
+
should 'convert to an HTML fragment with no wrap div' do
|
99
|
+
assert_equal %(<h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p>),
|
100
|
+
canonicalize(@doc.to_html_fragment(nil))
|
101
|
+
end
|
102
|
+
|
103
|
+
should 'convert to an HTML fragment with a wrap class' do
|
104
|
+
assert_equal %(<div class='pm'><h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p></div>),
|
105
|
+
canonicalize(@doc.to_html_fragment('pm'))
|
106
|
+
end
|
107
|
+
|
108
|
+
should 'convert to HTML with a layout' do
|
109
|
+
assert_match %r{^<!DOCTYPE html.*}m, @doc.to_html
|
110
|
+
assert_match %(<h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p>),
|
111
|
+
canonicalize(@doc.to_html)
|
112
|
+
end
|
113
|
+
|
114
|
+
should 'construct a path to related documents' do
|
115
|
+
assert_equal './hello.1.html', @doc.path_for(:html)
|
116
|
+
assert_equal './hello.1', @doc.path_for(:roff)
|
117
|
+
assert_equal './hello.1', @doc.path_for('')
|
118
|
+
assert_equal './hello.1', @doc.path_for(nil)
|
119
|
+
end
|
120
|
+
|
121
|
+
test 'uses default styles' do
|
122
|
+
assert_equal %w[man], @doc.styles
|
123
|
+
end
|
124
|
+
|
125
|
+
test 'converting to a hash' do
|
126
|
+
assert_equal({
|
127
|
+
'section' => '1',
|
128
|
+
'name' => 'hello',
|
129
|
+
'date' => @now,
|
130
|
+
'tagline' => 'hello world',
|
131
|
+
'styles' => ['man'],
|
132
|
+
'toc' => [['NAME', 'NAME']],
|
133
|
+
'organization' => nil,
|
134
|
+
'manual' => nil
|
135
|
+
}, @doc.to_h)
|
136
|
+
end
|
137
|
+
|
138
|
+
test 'converting to yaml' do
|
139
|
+
require 'yaml'
|
140
|
+
assert_equal({
|
141
|
+
'section' => '1',
|
142
|
+
'name' => 'hello',
|
143
|
+
'date' => @now,
|
144
|
+
'tagline' => 'hello world',
|
145
|
+
'styles' => ['man'],
|
146
|
+
'toc' => [['NAME', 'NAME']],
|
147
|
+
'organization' => nil,
|
148
|
+
'manual' => nil
|
149
|
+
}, YAML.load(@doc.to_yaml))
|
150
|
+
end
|
151
|
+
|
152
|
+
test 'converting to json' do
|
153
|
+
require 'json'
|
154
|
+
assert_equal({
|
155
|
+
'section' => '1',
|
156
|
+
'name' => 'hello',
|
157
|
+
'date' => @now.iso8601,
|
158
|
+
'tagline' => 'hello world',
|
159
|
+
'styles' => ['man'],
|
160
|
+
'toc' => [['NAME', 'NAME']],
|
161
|
+
'organization' => nil,
|
162
|
+
'manual' => nil
|
163
|
+
}, JSON.parse(@doc.to_json))
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
test 'extracting toc' do
|
168
|
+
@doc = Ronn::Document.new(File.expand_path('markdown_syntax.ronn', __dir__))
|
169
|
+
expected = [
|
170
|
+
['NAME', 'NAME'],
|
171
|
+
['SYNOPSIS', 'SYNOPSIS'],
|
172
|
+
['DESCRIPTION', 'DESCRIPTION'],
|
173
|
+
['BLOCK-ELEMENTS', 'BLOCK ELEMENTS'],
|
174
|
+
['SPAN-ELEMENTS', 'SPAN ELEMENTS'],
|
175
|
+
['MISCELLANEOUS', 'MISCELLANEOUS'],
|
176
|
+
['AUTHOR', 'AUTHOR'],
|
177
|
+
['SEE-ALSO', 'SEE ALSO']
|
178
|
+
]
|
179
|
+
assert_equal expected, @doc.toc
|
180
|
+
end
|
181
|
+
|
182
|
+
test 'passing a list of styles' do
|
183
|
+
@doc = Ronn::Document.new('hello.1.ronn', styles: %w[test boom test]) { '' }
|
184
|
+
assert_equal %w[man test boom], @doc.styles
|
185
|
+
end
|
186
|
+
end
|