ronn-ng 0.7.4 → 0.8.0.SNAPSHOT
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +12 -3
- data/Gemfile +2 -0
- data/INSTALLING.md +100 -0
- data/README.md +19 -1
- data/Rakefile +39 -49
- data/bin/ronn +93 -75
- data/completion/bash/ronn +32 -0
- data/completion/zsh/_ronn +24 -0
- data/config.ru +3 -3
- data/lib/ronn/document.rb +127 -106
- data/lib/ronn/index.rb +8 -9
- data/lib/ronn/roff.rb +153 -76
- data/lib/ronn/server.rb +19 -22
- data/lib/ronn/template.rb +27 -26
- data/lib/ronn/utils.rb +9 -7
- data/lib/ronn.rb +5 -3
- data/man/ronn-format.7 +6 -62
- data/man/ronn.1 +21 -123
- data/man/ronn.1.ronn +8 -0
- data/ronn-ng.gemspec +38 -13
- data/test/angle_bracket_syntax.html +4 -5
- data/test/backticks.html +14 -0
- data/test/backticks.ronn +10 -0
- data/test/basic_document.html +3 -4
- data/test/basic_document.ronn +2 -2
- data/test/circumflexes.ronn +1 -0
- data/test/code_blocks.7.ronn +41 -0
- data/test/contest.rb +56 -54
- data/test/custom_title_document.html +2 -2
- data/test/definition_list_syntax.html +13 -9
- data/test/definition_list_syntax.roff +2 -9
- data/test/definition_list_syntax.ronn +2 -2
- data/test/dots_at_line_start_test.roff +12 -3
- data/test/dots_at_line_start_test.ronn +8 -0
- data/test/ellipses.roff +7 -0
- data/test/ellipses.ronn +7 -0
- data/test/entity_encoding_test.html +13 -14
- data/test/entity_encoding_test.roff +1 -22
- data/test/entity_encoding_test.ronn +1 -1
- data/test/markdown_syntax.html +4 -5
- data/test/markdown_syntax.roff +1 -561
- data/test/middle_paragraph.html +2 -3
- data/test/middle_paragraph.roff +1 -5
- data/test/middle_paragraph.ronn +1 -1
- data/test/missing_spaces.roff +0 -2
- data/test/nested_list.ronn +19 -0
- data/test/nested_list_with_code.html +15 -0
- data/test/nested_list_with_code.roff +11 -0
- data/test/nested_list_with_code.ronn +6 -0
- data/test/page.with.periods.in.name.5.ronn +4 -0
- data/test/pre_block_with_quotes.roff +0 -5
- data/test/section_reference_links.html +2 -3
- data/test/section_reference_links.roff +1 -4
- data/test/section_reference_links.ronn +1 -1
- data/test/tables.ronn +24 -0
- data/test/test_ronn.rb +49 -35
- data/test/test_ronn_document.rb +81 -81
- data/test/test_ronn_index.rb +11 -11
- data/test/titleless_document.html +0 -1
- data/test/underline_spacing_test.roff +0 -8
- metadata +140 -22
- data/INSTALLING +0 -20
data/test/middle_paragraph.html
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
<div class='mp'>
|
2
|
+
|
2
3
|
<h2 id="NAME">NAME</h2>
|
3
4
|
<p class="man-name">
|
4
|
-
<code>test</code> - <span class="man-whatis">just a
|
5
|
+
<code>test</code> - <span class="man-whatis">just a ronn test</span>
|
5
6
|
</p>
|
6
|
-
|
7
7
|
<h2 id="TEST">TEST</h2>
|
8
8
|
|
9
9
|
<p>Foo</p>
|
@@ -11,5 +11,4 @@
|
|
11
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
12
|
|
13
13
|
<p>Bar</p>
|
14
|
-
|
15
14
|
</div>
|
data/test/middle_paragraph.roff
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
.TH "TEST" "1" "January 1979" "" ""
|
2
|
-
.
|
3
2
|
.SH "NAME"
|
4
|
-
\fBtest\fR \- just a
|
5
|
-
.
|
3
|
+
\fBtest\fR \- just a ronn test
|
6
4
|
.SH "TEST"
|
7
5
|
Foo
|
8
|
-
.
|
9
6
|
.P
|
10
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\.
|
11
|
-
.
|
12
8
|
.P
|
13
9
|
Bar
|
data/test/middle_paragraph.ronn
CHANGED
data/test/missing_spaces.roff
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
<div class='mp'>
|
2
|
+
|
3
|
+
<h1 id="a-1-">a(1)</h1>
|
4
|
+
<ul>
|
5
|
+
<li>
|
6
|
+
<code>toggle_status</code>
|
7
|
+
|
8
|
+
<ul>
|
9
|
+
<li>Toggle the display of the status bar.</li>
|
10
|
+
</ul>
|
11
|
+
</li>
|
12
|
+
<li>
|
13
|
+
<code>spawn <executable> <additional args></code> TODO explain path-alike expansion</li>
|
14
|
+
</ul>
|
15
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
.TH "NESTED_LIST_WITH_CODE" "" "January 1979" "" ""
|
2
|
+
.IP "\[ci]" 4
|
3
|
+
\fBtoggle_status\fR
|
4
|
+
.IP "\[ci]" 4
|
5
|
+
Toggle the display of the status bar\.
|
6
|
+
.IP "" 0
|
7
|
+
|
8
|
+
.IP "\[ci]" 4
|
9
|
+
\fBspawn <executable> <additional args>\fR TODO explain path\-alike expansion
|
10
|
+
.IP "" 0
|
11
|
+
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<div class='mp'>
|
2
|
+
|
2
3
|
<h2 id="NAME">NAME</h2>
|
3
4
|
<p class="man-name">
|
4
5
|
<code>section_reference_links</code> - <span class="man-whatis">linking to sections</span>
|
5
6
|
</p>
|
6
|
-
|
7
7
|
<h2 id="SECTION-1">SECTION 1</h2>
|
8
8
|
|
9
9
|
<p>See the following section.</p>
|
@@ -12,6 +12,5 @@
|
|
12
12
|
|
13
13
|
<p>See <a href="#SECTION-1" title="SECTION 1" data-bare-link="true">SECTION 1</a>
|
14
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">
|
16
|
-
|
15
|
+
or even <a href="#SECTION-1" data-bare-link="true">like this</a></p>
|
17
16
|
</div>
|
@@ -1,10 +1,7 @@
|
|
1
1
|
.TH "SECTION_REFERENCE_LINKS" "1" "January 1979" "" ""
|
2
|
-
.
|
3
2
|
.SH "NAME"
|
4
3
|
\fBsection_reference_links\fR \- linking to sections
|
5
|
-
.
|
6
4
|
.SH "SECTION 1"
|
7
5
|
See the following section\.
|
8
|
-
.
|
9
6
|
.SH "SECTION 2"
|
10
|
-
See \fISECTION 1\fR or \fIto put it another way\fR or even \
|
7
|
+
See \fISECTION 1\fR or \fIto put it another way\fR or even \fIlike this\fR
|
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
CHANGED
@@ -4,69 +4,77 @@ class RonnTest < Test::Unit::TestCase
|
|
4
4
|
testdir = File.dirname(__FILE__)
|
5
5
|
|
6
6
|
# setup PATH so that we execute the right ronn command
|
7
|
-
bindir = File.dirname(testdir) +
|
7
|
+
bindir = File.dirname(testdir) + '/bin'
|
8
8
|
ENV['PATH'] = "#{bindir}:#{ENV['PATH']}"
|
9
9
|
|
10
10
|
# make sure the load path is setup correctly
|
11
11
|
libdir = File.expand_path("#{testdir}/../lib")
|
12
|
-
|
13
|
-
ENV['RUBYLIB'] =
|
12
|
+
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.any? { |path| File.expand_path(path) == libdir }
|
13
|
+
ENV['RUBYLIB'] = $LOAD_PATH.join(':')
|
14
14
|
|
15
15
|
require 'ronn'
|
16
16
|
|
17
|
-
test
|
17
|
+
test 'takes ronn text on stdin and produces roff on stdout' do
|
18
18
|
output = `echo '# hello(1) -- hello world' | ronn --date=2009-11-23`
|
19
19
|
lines = output.split("\n")
|
20
|
-
assert_equal
|
21
|
-
assert_equal %
|
22
|
-
assert_equal %
|
23
|
-
assert_equal %
|
24
|
-
assert_equal %
|
25
|
-
assert_equal %
|
26
|
-
assert_equal %[.SH "NAME"], lines.shift
|
27
|
-
assert_equal %[\\fBhello\\fR \\- hello world], lines.shift
|
20
|
+
assert_equal 5, lines.size
|
21
|
+
assert_equal %(.\\" generated with Ronn-NG/v#{Ronn.version}), lines.shift
|
22
|
+
assert_equal %(.\\" http://github.com/apjanke/ronn-ng/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
|
28
26
|
assert_equal 0, lines.size
|
29
27
|
end
|
30
28
|
|
31
29
|
def canonicalize(text)
|
32
|
-
text
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
text
|
31
|
+
.gsub(/^ +/, '')
|
32
|
+
.gsub(/\n/m, '')
|
33
|
+
.gsub(/ +/, ' ')
|
34
|
+
.tr('"', "'")
|
37
35
|
end
|
38
36
|
|
39
|
-
|
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
|
40
48
|
output = `echo '# hello(1) -- hello world' | ronn --html`
|
41
49
|
output = canonicalize(output)
|
42
50
|
assert_match(/<h2 id='NAME'>NAME<\/h2>/, output)
|
43
|
-
advertising = "<meta name='generator' content='Ronn-NG/v"
|
44
|
-
|
51
|
+
advertising = "<meta name='generator' content='Ronn-NG/v" + Ronn.version +
|
52
|
+
' (http://github.com/apjanke/ronn-ng/tree/' + Ronn.revision + ")'>"
|
45
53
|
assert_match(/#{Regexp.escape(advertising)}/, output)
|
46
54
|
end
|
47
55
|
|
48
|
-
test
|
56
|
+
test 'produces html fragment with the --fragment argument' do
|
49
57
|
output = `echo '# hello(1) -- hello world' | ronn --fragment`
|
50
58
|
assert_equal [
|
51
59
|
"<div class='mp'>",
|
52
60
|
"<h2 id='NAME'>NAME</h2>",
|
53
61
|
"<p class='man-name'><code>hello</code>",
|
54
62
|
" - <span class='man-whatis'>hello world</span>",
|
55
|
-
|
63
|
+
'</p></div>'
|
56
64
|
].join, canonicalize(output)
|
57
65
|
end
|
58
66
|
|
59
|
-
test
|
67
|
+
test 'abides by the RONN_MANUAL environment variable' do
|
60
68
|
output = `echo '# hello(1) -- hello world' | RONN_MANUAL='Some Manual' ronn --html`
|
61
69
|
assert_match(/Some Manual/, output)
|
62
70
|
end
|
63
71
|
|
64
|
-
test
|
72
|
+
test 'abides by the RONN_DATE environment variable' do
|
65
73
|
output = `echo '# hello(1) -- hello world' | RONN_DATE=1979-01-01 ronn --html`
|
66
74
|
assert_match(/January 1979/, output)
|
67
75
|
end
|
68
76
|
|
69
|
-
test
|
77
|
+
test 'abides by the RONN_ORGANIZATION environment variable' do
|
70
78
|
output = `echo '# hello(1) -- hello world' | RONN_ORGANIZATION='GitHub' ronn --html`
|
71
79
|
assert_match(/GitHub/, output)
|
72
80
|
end
|
@@ -75,14 +83,17 @@ class RonnTest < Test::Unit::TestCase
|
|
75
83
|
Dir[testdir + '/*.ronn'].each do |source|
|
76
84
|
dest = source.sub(/ronn$/, 'html')
|
77
85
|
next unless File.exist?(dest)
|
86
|
+
|
78
87
|
wrong = dest + '.wrong'
|
79
88
|
test File.basename(source, '.ronn') + ' HTML' do
|
80
89
|
output = `ronn --pipe --html --fragment #{source}`
|
81
|
-
expected =
|
90
|
+
expected = begin
|
91
|
+
File.read(dest)
|
92
|
+
rescue IOError
|
93
|
+
''
|
94
|
+
end
|
82
95
|
if expected != output
|
83
|
-
|
84
|
-
diff = `diff -u #{dest} #{wrong} 2>/dev/null`
|
85
|
-
flunk diff
|
96
|
+
flunk_with_diff(dest, wrong, output)
|
86
97
|
elsif File.exist?(wrong)
|
87
98
|
File.unlink(wrong)
|
88
99
|
end
|
@@ -93,15 +104,18 @@ class RonnTest < Test::Unit::TestCase
|
|
93
104
|
Dir[testdir + '/*.ronn'].each do |source|
|
94
105
|
dest = source.sub(/ronn$/, 'roff')
|
95
106
|
next unless File.exist?(dest)
|
107
|
+
|
96
108
|
wrong = dest + '.wrong'
|
97
109
|
test File.basename(source, '.ronn') + ' roff' do
|
98
|
-
output = `ronn --pipe --roff --date=1979-01-01 #{source}
|
99
|
-
|
100
|
-
expected =
|
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
|
101
117
|
if expected != output
|
102
|
-
|
103
|
-
diff = `diff -u #{dest} #{wrong} 2>/dev/null`
|
104
|
-
flunk diff
|
118
|
+
flunk_with_diff(dest, wrong, output)
|
105
119
|
elsif File.exist?(wrong)
|
106
120
|
File.unlink(wrong)
|
107
121
|
end
|
data/test/test_ronn_document.rb
CHANGED
@@ -2,43 +2,43 @@ require 'contest'
|
|
2
2
|
require 'ronn/document'
|
3
3
|
|
4
4
|
class DocumentTest < Test::Unit::TestCase
|
5
|
-
SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ronn"
|
5
|
+
SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ronn".freeze
|
6
6
|
|
7
7
|
def canonicalize(text)
|
8
|
-
text
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
text
|
9
|
+
.gsub(/^ +/, '')
|
10
|
+
.gsub(/\n/m, '')
|
11
|
+
.gsub(/ +/, ' ')
|
12
|
+
.tr('"', "'")
|
13
13
|
end
|
14
14
|
|
15
|
-
test
|
15
|
+
test 'new with path' do
|
16
16
|
doc = Ronn::Document.new(SIMPLE_FILE)
|
17
17
|
assert_equal File.read(SIMPLE_FILE), doc.data
|
18
18
|
end
|
19
19
|
|
20
|
-
test
|
21
|
-
doc = Ronn::Document.new('hello.1.ronn') {
|
22
|
-
assert_equal
|
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
23
|
end
|
24
24
|
|
25
|
-
test
|
25
|
+
test 'new with path and block but missing name section' do
|
26
26
|
doc = Ronn::Document.new('foo.7.ronn') { '' }
|
27
27
|
assert_equal 'foo', doc.name
|
28
28
|
assert_equal '7', doc.section
|
29
29
|
end
|
30
30
|
|
31
|
-
test
|
31
|
+
test 'new with non conventional path and missing name section' do
|
32
32
|
doc = Ronn::Document.new('bar.ronn') { '' }
|
33
33
|
assert_equal 'bar', doc.name
|
34
34
|
assert_equal nil, doc.section
|
35
|
-
assert_equal
|
36
|
-
assert_equal
|
37
|
-
assert_equal
|
38
|
-
assert_equal
|
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
39
|
end
|
40
40
|
|
41
|
-
test
|
41
|
+
test 'new with path and name section mismatch' do
|
42
42
|
doc = Ronn::Document.new('foo/rick.7.ronn') { "# randy(3) -- I'm confused." }
|
43
43
|
assert_equal 'randy', doc.name
|
44
44
|
assert_equal 'rick', doc.path_name
|
@@ -48,8 +48,8 @@ class DocumentTest < Test::Unit::TestCase
|
|
48
48
|
assert_equal 'foo/rick.7.bar', doc.path_for(:bar)
|
49
49
|
end
|
50
50
|
|
51
|
-
test
|
52
|
-
doc = Ronn::Document.new {
|
51
|
+
test 'new with no path and a name section' do
|
52
|
+
doc = Ronn::Document.new { '# brandy(5) -- wootderitis' }
|
53
53
|
assert_equal nil, doc.path_name
|
54
54
|
assert_equal nil, doc.path_section
|
55
55
|
assert_equal 'brandy', doc.name
|
@@ -76,111 +76,111 @@ class DocumentTest < Test::Unit::TestCase
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
context
|
79
|
+
context 'simple conventionally named document' do
|
80
80
|
setup do
|
81
81
|
@now = Time.now
|
82
|
-
@doc = Ronn::Document.new('hello.1.ronn') {
|
82
|
+
@doc = Ronn::Document.new('hello.1.ronn') { '# hello(1) -- hello world' }
|
83
83
|
@doc.date = @now
|
84
84
|
end
|
85
85
|
|
86
|
-
should
|
87
|
-
assert_equal
|
86
|
+
should 'load data' do
|
87
|
+
assert_equal '# hello(1) -- hello world', @doc.data
|
88
88
|
end
|
89
89
|
|
90
|
-
should
|
90
|
+
should 'extract the manual page name from the filename or document' do
|
91
91
|
assert_equal 'hello', @doc.name
|
92
92
|
end
|
93
93
|
|
94
|
-
should
|
94
|
+
should 'extract the manual page section from the filename or document' do
|
95
95
|
assert_equal '1', @doc.section
|
96
96
|
end
|
97
97
|
|
98
|
-
should
|
99
|
-
assert_equal %
|
100
|
-
|
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
101
|
end
|
102
102
|
|
103
|
-
should
|
104
|
-
assert_equal %
|
105
|
-
|
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
106
|
end
|
107
107
|
|
108
|
-
should
|
108
|
+
should 'convert to HTML with a layout' do
|
109
109
|
assert_match %r{^<!DOCTYPE html.*}m, @doc.to_html
|
110
|
-
assert_match %
|
111
|
-
|
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
112
|
end
|
113
113
|
|
114
|
-
should
|
115
|
-
assert_equal
|
116
|
-
assert_equal
|
117
|
-
assert_equal
|
118
|
-
assert_equal
|
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
119
|
end
|
120
120
|
|
121
|
-
test
|
121
|
+
test 'uses default styles' do
|
122
122
|
assert_equal %w[man], @doc.styles
|
123
123
|
end
|
124
124
|
|
125
|
-
test
|
125
|
+
test 'converting to a hash' do
|
126
126
|
assert_equal({
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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
136
|
end
|
137
137
|
|
138
|
-
test
|
138
|
+
test 'converting to yaml' do
|
139
139
|
require 'yaml'
|
140
140
|
assert_equal({
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
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
150
|
end
|
151
151
|
|
152
|
-
test
|
152
|
+
test 'converting to json' do
|
153
153
|
require 'json'
|
154
154
|
assert_equal({
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
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
164
|
end
|
165
165
|
end
|
166
166
|
|
167
167
|
test 'extracting toc' do
|
168
|
-
@doc = Ronn::Document.new(File.expand_path('
|
168
|
+
@doc = Ronn::Document.new(File.expand_path('markdown_syntax.ronn', __dir__))
|
169
169
|
expected = [
|
170
|
-
[
|
171
|
-
[
|
172
|
-
[
|
173
|
-
[
|
174
|
-
[
|
175
|
-
[
|
176
|
-
[
|
177
|
-
[
|
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
178
|
]
|
179
179
|
assert_equal expected, @doc.toc
|
180
180
|
end
|
181
181
|
|
182
|
-
test
|
183
|
-
@doc = Ronn::Document.new('hello.1.ronn', :
|
182
|
+
test 'passing a list of styles' do
|
183
|
+
@doc = Ronn::Document.new('hello.1.ronn', styles: %w[test boom test]) { '' }
|
184
184
|
assert_equal %w[man test boom], @doc.styles
|
185
185
|
end
|
186
186
|
end
|