kramdown-man 0.1.3 → 0.1.8
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/.github/workflows/ruby.yml +32 -0
- data/.gitignore +1 -0
- data/ChangeLog.md +29 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +9 -8
- data/Rakefile +12 -34
- data/gemspec.yml +2 -4
- data/lib/kramdown/converter/man.rb +399 -27
- data/lib/kramdown/man.rb +3 -2
- data/lib/kramdown/man/task.rb +1 -1
- data/lib/kramdown/man/version.rb +1 -1
- data/man/kramdown-man.1 +43 -36
- data/man/kramdown-man.1.md +6 -2
- data/spec/kramdown/converter/man_spec.rb +180 -97
- data/spec/kramdown/document_spec.rb +19 -0
- data/spec/kramdown/man_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -1
- metadata +23 -60
- data/.travis.yml +0 -11
data/lib/kramdown/man.rb
CHANGED
data/lib/kramdown/man/task.rb
CHANGED
data/lib/kramdown/man/version.rb
CHANGED
data/man/kramdown-man.1
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
.\" Generated by kramdown-man 0.1.
|
2
|
-
.\" https://github.com/postmodern/kramdown-
|
1
|
+
.\" Generated by kramdown-man 0.1.7
|
2
|
+
.\" https://github.com/postmodern/kramdown-man#readme
|
3
3
|
.TH kramdown-man.1 "April 2013" kramdown-man "User Manuals"
|
4
4
|
.LP
|
5
5
|
.SH DESCRIPTION
|
6
6
|
.LP
|
7
7
|
.PP
|
8
8
|
A Kramdown
|
9
|
-
.UR http
|
10
|
-
.UE
|
9
|
+
.UR http:\[sl]\[sl]kramdown\.gettalong\.org\[sl]
|
10
|
+
.UE plugin for converting Markdown files into man pages\.
|
11
11
|
.LP
|
12
12
|
.SH EXAMPLE
|
13
13
|
.LP
|
14
14
|
.nf
|
15
|
-
require
|
16
|
-
require
|
15
|
+
require \(aqkramdown\(aq
|
16
|
+
require \(aqkramdown\[sl]man\(aq
|
17
17
|
|
18
|
-
doc
|
19
|
-
File
|
20
|
-
system
|
18
|
+
doc \[eq] Kramdown::Document\.new(File\.read(\(aqman\[sl]kramdown\-man\.1\.md\(aq))
|
19
|
+
File\.write(\(aqman\[sl]kramdown\-man\.1\(aq,doc\.to\[ru]man)
|
20
|
+
system \(aqman\(aq, \(aqman\[sl]kramdown\-man\.1\(aq
|
21
21
|
.fi
|
22
22
|
.LP
|
23
23
|
.SH SYNTAX
|
@@ -25,11 +25,11 @@ system 'man', 'man/kramdown\-man.1'
|
|
25
25
|
.SS FORMATTING
|
26
26
|
.LP
|
27
27
|
.nf
|
28
|
-
|
28
|
+
\`code\`
|
29
29
|
.fi
|
30
30
|
.LP
|
31
31
|
.PP
|
32
|
-
\
|
32
|
+
\fBcode\fR
|
33
33
|
.LP
|
34
34
|
.nf
|
35
35
|
*emphasis*
|
@@ -48,46 +48,53 @@ system 'man', 'man/kramdown\-man.1'
|
|
48
48
|
.SS PARAGRAPHS
|
49
49
|
.LP
|
50
50
|
.nf
|
51
|
-
Normal paragraph
|
51
|
+
Normal paragraph\.
|
52
52
|
.fi
|
53
53
|
.LP
|
54
54
|
.PP
|
55
|
-
Normal paragraph
|
55
|
+
Normal paragraph\.
|
56
56
|
.LP
|
57
57
|
.nf
|
58
|
-
|
59
|
-
|
58
|
+
\`command\` \[lB]\`\-\-foo\`\[rB] *FILE*
|
59
|
+
.fi
|
60
|
+
.LP
|
61
|
+
.HP
|
62
|
+
\fBcommand\fR \[lB]\fB--foo\fR\[rB] \fIFILE\fP
|
63
|
+
.LP
|
64
|
+
.nf
|
65
|
+
\`\-\-tagged\`
|
66
|
+
Text here\.
|
60
67
|
.fi
|
61
68
|
.LP
|
62
69
|
.TP
|
63
|
-
\fB
|
64
|
-
Text here
|
70
|
+
\fB--tagged\fR
|
71
|
+
Text here\.
|
65
72
|
.LP
|
66
73
|
.SS LINKS
|
67
74
|
.LP
|
68
75
|
.nf
|
69
|
-
[website](http
|
76
|
+
\[lB]website\[rB](http:\[sl]\[sl]example\.com\[sl])
|
70
77
|
.fi
|
71
78
|
.LP
|
72
79
|
.PP
|
73
80
|
website
|
74
|
-
.UR http
|
81
|
+
.UR http:\[sl]\[sl]example\.com\[sl]
|
75
82
|
.UE
|
76
83
|
.LP
|
77
84
|
.nf
|
78
|
-
[bash](man:bash(1))
|
85
|
+
\[lB]bash\[rB](man:bash(1))
|
79
86
|
.fi
|
80
87
|
.LP
|
81
88
|
.PP
|
82
89
|
.BR bash (1)
|
83
90
|
.LP
|
84
91
|
.nf
|
85
|
-
Email <bob
|
92
|
+
Email <bob\[at]example\.com>
|
86
93
|
.fi
|
87
94
|
.LP
|
88
95
|
.PP
|
89
96
|
Email
|
90
|
-
.MT bob
|
97
|
+
.MT bob\[at]example\.com
|
91
98
|
.ME
|
92
99
|
.LP
|
93
100
|
.SS LISTS
|
@@ -135,42 +142,42 @@ extra paragraph
|
|
135
142
|
.SS BLOCKQUOTES
|
136
143
|
.LP
|
137
144
|
.nf
|
138
|
-
> Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away
|
145
|
+
> Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away\.
|
139
146
|
>
|
140
|
-
> \-\-Antoine de Saint\-
|
147
|
+
> \-\-Antoine de Saint\-Exup\['e]ry
|
141
148
|
.fi
|
142
149
|
.LP
|
143
150
|
.PP
|
144
151
|
.RS
|
145
|
-
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away
|
152
|
+
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away\.
|
146
153
|
.LP
|
147
|
-
|
154
|
+
\-\-Antoine de Saint\-Exup\['e]ry
|
148
155
|
.RE
|
149
156
|
.LP
|
150
157
|
.SS CODE BLOCKS
|
151
158
|
.LP
|
152
159
|
.nf
|
153
|
-
|
160
|
+
\[sh]include <stdio\.h>
|
154
161
|
|
155
162
|
int main()
|
156
|
-
|
157
|
-
printf(
|
163
|
+
\[lC]
|
164
|
+
printf(\[dq]hello world\en\[dq]);
|
158
165
|
return 0;
|
159
|
-
|
166
|
+
\[rC]
|
160
167
|
|
161
|
-
|
168
|
+
\[sh]include <stdio\.h>
|
162
169
|
|
163
170
|
int main()
|
164
|
-
|
165
|
-
printf(
|
171
|
+
\[lC]
|
172
|
+
printf(\[dq]hello world\en\[dq]);
|
166
173
|
return 0;
|
167
|
-
|
174
|
+
\[rC]
|
168
175
|
.fi
|
169
176
|
.LP
|
170
177
|
.SH AUTHOR
|
171
178
|
.LP
|
172
179
|
.PP
|
173
180
|
Postmodern
|
174
|
-
.MT postmodern
|
181
|
+
.MT postmodern\.mod3\[at]gmail\.com
|
175
182
|
.ME
|
176
|
-
.LP
|
183
|
+
.LP
|
data/man/kramdown-man.1.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## DESCRIPTION
|
4
4
|
|
5
|
-
A [Kramdown][kramdown]
|
5
|
+
A [Kramdown][kramdown] plugin for converting Markdown files into man pages.
|
6
6
|
|
7
7
|
## EXAMPLE
|
8
8
|
|
@@ -35,6 +35,10 @@ A [Kramdown][kramdown] convert for converting Markdown files into man pages.
|
|
35
35
|
|
36
36
|
Normal paragraph.
|
37
37
|
|
38
|
+
`command` [`--foo`] *FILE*
|
39
|
+
|
40
|
+
`command` [`--foo`] *FILE*
|
41
|
+
|
38
42
|
`--tagged`
|
39
43
|
Text here.
|
40
44
|
|
@@ -120,4 +124,4 @@ Email <bob@example.com>
|
|
120
124
|
|
121
125
|
Postmodern <postmodern.mod3@gmail.com>
|
122
126
|
|
123
|
-
[kramdown]: http://kramdown.
|
127
|
+
[kramdown]: http://kramdown.gettalong.org/
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
|
2
|
+
require_relative '../../spec_helper'
|
3
|
+
|
4
|
+
# HACK: load our version of kramdown/converter/man.rb and not kramdown's
|
5
|
+
require_relative '../../../lib/kramdown/converter/man'
|
4
6
|
|
5
7
|
describe Kramdown::Converter::Man do
|
6
8
|
let(:markdown) { File.read('man/kramdown-man.1.md') }
|
@@ -20,13 +22,13 @@ Hello world.
|
|
20
22
|
let(:root) { doc.root }
|
21
23
|
|
22
24
|
it "should add the header" do
|
23
|
-
subject.convert(root).
|
25
|
+
expect(subject.convert(root)).to eq([
|
24
26
|
described_class::HEADER,
|
25
27
|
".TH Header",
|
26
28
|
".LP",
|
27
29
|
".PP",
|
28
|
-
|
29
|
-
].join("\n")
|
30
|
+
'Hello world\.'
|
31
|
+
].join("\n"))
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -42,12 +44,12 @@ Hello world.
|
|
42
44
|
let(:root) { doc.root }
|
43
45
|
|
44
46
|
it "should convert every element" do
|
45
|
-
subject.convert_root(root).
|
47
|
+
expect(subject.convert_root(root)).to eq([
|
46
48
|
".TH Header",
|
47
49
|
".LP",
|
48
50
|
".PP",
|
49
|
-
|
50
|
-
].join("\n")
|
51
|
+
'Hello world\.'
|
52
|
+
].join("\n"))
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
@@ -56,7 +58,7 @@ Hello world.
|
|
56
58
|
let(:el) { doc.root.children[0] }
|
57
59
|
|
58
60
|
it "should convert the element based on it's type" do
|
59
|
-
subject.convert_element(el).
|
61
|
+
expect(subject.convert_element(el)).to eq(subject.convert_codeblock(el))
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -65,7 +67,7 @@ Hello world.
|
|
65
67
|
let(:blank) { doc.root.children[0].children[1] }
|
66
68
|
|
67
69
|
it "should convert blank elements to '.LP'" do
|
68
|
-
subject.convert_blank(blank).
|
70
|
+
expect(subject.convert_blank(blank)).to eq('.LP')
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
@@ -75,7 +77,23 @@ Hello world.
|
|
75
77
|
let(:text) { doc.root.children[0].children[0] }
|
76
78
|
|
77
79
|
it "should convert text elements" do
|
78
|
-
subject.convert_text(text).
|
80
|
+
expect(subject.convert_text(text)).to eq(content)
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when the text has two-space indentation" do
|
84
|
+
let(:content) { "Foo\n bar\n baz" }
|
85
|
+
|
86
|
+
it "should strip leading whitespace from each line" do
|
87
|
+
expect(subject.convert_text(text)).to eq(content.gsub("\n ","\n"))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when the text has tab indentation" do
|
92
|
+
let(:content) { "Foo\n\tbar\n\tbaz" }
|
93
|
+
|
94
|
+
it "should strip leading whitespace from each line" do
|
95
|
+
expect(subject.convert_text(text)).to eq(content.gsub("\n\t","\n"))
|
96
|
+
end
|
79
97
|
end
|
80
98
|
end
|
81
99
|
|
@@ -84,8 +102,8 @@ Hello world.
|
|
84
102
|
let(:doc) { Kramdown::Document.new("-- foo") }
|
85
103
|
let(:sym) { doc.root.children[0].children[0] }
|
86
104
|
|
87
|
-
it "should convert ndash symbols back into '
|
88
|
-
subject.convert_typographic_sym(sym).
|
105
|
+
it "should convert ndash symbols back into '\-\-'" do
|
106
|
+
expect(subject.convert_typographic_sym(sym)).to eq("\\-\\-")
|
89
107
|
end
|
90
108
|
end
|
91
109
|
|
@@ -93,8 +111,8 @@ Hello world.
|
|
93
111
|
let(:doc) { Kramdown::Document.new("--- foo") }
|
94
112
|
let(:sym) { doc.root.children[0].children[0] }
|
95
113
|
|
96
|
-
it "should convert mdash symbols into '
|
97
|
-
subject.convert_typographic_sym(sym).
|
114
|
+
it "should convert mdash symbols into '\[em]'" do
|
115
|
+
expect(subject.convert_typographic_sym(sym)).to eq('\[em]')
|
98
116
|
end
|
99
117
|
end
|
100
118
|
|
@@ -102,8 +120,8 @@ Hello world.
|
|
102
120
|
let(:doc) { Kramdown::Document.new("... foo") }
|
103
121
|
let(:sym) { doc.root.children[0].children[0] }
|
104
122
|
|
105
|
-
it "should convert mdash symbols into '
|
106
|
-
subject.convert_typographic_sym(sym).
|
123
|
+
it "should convert mdash symbols into '\\.\\.\\.'" do
|
124
|
+
expect(subject.convert_typographic_sym(sym)).to eq('\.\.\.')
|
107
125
|
end
|
108
126
|
end
|
109
127
|
|
@@ -111,8 +129,8 @@ Hello world.
|
|
111
129
|
let(:doc) { Kramdown::Document.new("<< foo") }
|
112
130
|
let(:sym) { doc.root.children[0].children[0] }
|
113
131
|
|
114
|
-
it "should convert mdash symbols into '
|
115
|
-
subject.convert_typographic_sym(sym).
|
132
|
+
it "should convert mdash symbols into '\[Fo]'" do
|
133
|
+
expect(subject.convert_typographic_sym(sym)).to eq('\[Fo]')
|
116
134
|
end
|
117
135
|
end
|
118
136
|
|
@@ -120,8 +138,8 @@ Hello world.
|
|
120
138
|
let(:doc) { Kramdown::Document.new("foo >> bar") }
|
121
139
|
let(:sym) { doc.root.children[0].children[1] }
|
122
140
|
|
123
|
-
it "should convert mdash symbols into '
|
124
|
-
subject.convert_typographic_sym(sym).
|
141
|
+
it "should convert mdash symbols into '\[Fc]'" do
|
142
|
+
expect(subject.convert_typographic_sym(sym)).to eq('\[Fc]')
|
125
143
|
end
|
126
144
|
end
|
127
145
|
|
@@ -129,8 +147,8 @@ Hello world.
|
|
129
147
|
let(:doc) { Kramdown::Document.new(" << foo") }
|
130
148
|
let(:sym) { doc.root.children[0].children[0] }
|
131
149
|
|
132
|
-
it "should convert mdash symbols into '
|
133
|
-
subject.convert_typographic_sym(sym).
|
150
|
+
it "should convert mdash symbols into '\[Fo]'" do
|
151
|
+
expect(subject.convert_typographic_sym(sym)).to eq('\[Fo]')
|
134
152
|
end
|
135
153
|
end
|
136
154
|
|
@@ -138,8 +156,8 @@ Hello world.
|
|
138
156
|
let(:doc) { Kramdown::Document.new("foo >> bar") }
|
139
157
|
let(:sym) { doc.root.children[0].children[1] }
|
140
158
|
|
141
|
-
it "should convert mdash symbols into '
|
142
|
-
subject.convert_typographic_sym(sym).
|
159
|
+
it "should convert mdash symbols into '\[Fc]'" do
|
160
|
+
expect(subject.convert_typographic_sym(sym)).to eq('\[Fc]')
|
143
161
|
end
|
144
162
|
end
|
145
163
|
end
|
@@ -149,8 +167,8 @@ Hello world.
|
|
149
167
|
let(:doc) { Kramdown::Document.new("'hello world'") }
|
150
168
|
let(:quote) { doc.root.children[0].children.first }
|
151
169
|
|
152
|
-
it "should convert lsquo quotes into '
|
153
|
-
subject.convert_smart_quote(quote).
|
170
|
+
it "should convert lsquo quotes into '\[oq]'" do
|
171
|
+
expect(subject.convert_smart_quote(quote)).to eq('\[oq]')
|
154
172
|
end
|
155
173
|
end
|
156
174
|
|
@@ -158,8 +176,8 @@ Hello world.
|
|
158
176
|
let(:doc) { Kramdown::Document.new("'hello world'") }
|
159
177
|
let(:quote) { doc.root.children[0].children.last }
|
160
178
|
|
161
|
-
it "should convert rsquo quotes into '
|
162
|
-
subject.convert_smart_quote(quote).
|
179
|
+
it "should convert rsquo quotes into '\[cq]'" do
|
180
|
+
expect(subject.convert_smart_quote(quote)).to eq('\[cq]')
|
163
181
|
end
|
164
182
|
end
|
165
183
|
|
@@ -167,8 +185,8 @@ Hello world.
|
|
167
185
|
let(:doc) { Kramdown::Document.new('"hello world"') }
|
168
186
|
let(:quote) { doc.root.children[0].children.first }
|
169
187
|
|
170
|
-
it "should convert lsquo quotes into '
|
171
|
-
subject.convert_smart_quote(quote).
|
188
|
+
it "should convert lsquo quotes into '\[lq]'" do
|
189
|
+
expect(subject.convert_smart_quote(quote)).to eq('\[lq]')
|
172
190
|
end
|
173
191
|
end
|
174
192
|
|
@@ -176,8 +194,8 @@ Hello world.
|
|
176
194
|
let(:doc) { Kramdown::Document.new('"hello world"') }
|
177
195
|
let(:quote) { doc.root.children[0].children.last }
|
178
196
|
|
179
|
-
it "should convert lsquo quotes into '
|
180
|
-
subject.convert_smart_quote(quote).
|
197
|
+
it "should convert lsquo quotes into '\[rq]'" do
|
198
|
+
expect(subject.convert_smart_quote(quote)).to eq('\[rq]')
|
181
199
|
end
|
182
200
|
end
|
183
201
|
end
|
@@ -188,7 +206,7 @@ Hello world.
|
|
188
206
|
let(:header) { doc.root.children[0] }
|
189
207
|
|
190
208
|
it "should convert level 1 headers into '.TH text'" do
|
191
|
-
subject.convert_header(header).
|
209
|
+
expect(subject.convert_header(header)).to eq(".TH Header")
|
192
210
|
end
|
193
211
|
end
|
194
212
|
|
@@ -197,7 +215,7 @@ Hello world.
|
|
197
215
|
let(:header) { doc.root.children[0] }
|
198
216
|
|
199
217
|
it "should convert level 2 headers into '.SH text'" do
|
200
|
-
subject.convert_header(header).
|
218
|
+
expect(subject.convert_header(header)).to eq(".SH Header")
|
201
219
|
end
|
202
220
|
end
|
203
221
|
|
@@ -206,7 +224,7 @@ Hello world.
|
|
206
224
|
let(:header) { doc.root.children[0] }
|
207
225
|
|
208
226
|
it "should convert level 2 headers into '.SS text'" do
|
209
|
-
subject.convert_header(header).
|
227
|
+
expect(subject.convert_header(header)).to eq(".SS Header")
|
210
228
|
end
|
211
229
|
end
|
212
230
|
|
@@ -215,7 +233,7 @@ Hello world.
|
|
215
233
|
let(:header) { doc.root.children[0] }
|
216
234
|
|
217
235
|
it "should convert level 2 headers into '.SS text'" do
|
218
|
-
subject.convert_header(header).
|
236
|
+
expect(subject.convert_header(header)).to eq(".SS Header")
|
219
237
|
end
|
220
238
|
end
|
221
239
|
end
|
@@ -225,7 +243,7 @@ Hello world.
|
|
225
243
|
let(:hr) { doc.root.children[0] }
|
226
244
|
|
227
245
|
it "should convert hr elements into '.ti 0\\n\\\\l'\\\\n(.lu\\''" do
|
228
|
-
subject.convert_hr(hr).
|
246
|
+
expect(subject.convert_hr(hr)).to eq(".ti 0\n\\l'\\n(.lu'")
|
229
247
|
end
|
230
248
|
end
|
231
249
|
|
@@ -236,14 +254,14 @@ Hello world.
|
|
236
254
|
let(:ul) { doc.root.children[0] }
|
237
255
|
|
238
256
|
it "should convert ul elements into '.RS\\n...\\n.RE'" do
|
239
|
-
subject.convert_ul(ul).
|
257
|
+
expect(subject.convert_ul(ul)).to eq([
|
240
258
|
".RS",
|
241
259
|
".IP \\(bu 2",
|
242
260
|
text1,
|
243
261
|
".IP \\(bu 2",
|
244
262
|
text2,
|
245
263
|
".RE"
|
246
|
-
].join("\n")
|
264
|
+
].join("\n"))
|
247
265
|
end
|
248
266
|
end
|
249
267
|
|
@@ -253,7 +271,7 @@ Hello world.
|
|
253
271
|
let(:li) { doc.root.children[0].children[0] }
|
254
272
|
|
255
273
|
it "should convert the first p element to '.IP \\\\(bu 2\\n...'" do
|
256
|
-
subject.convert_ul_li(li).
|
274
|
+
expect(subject.convert_ul_li(li)).to eq(".IP \\(bu 2\n#{text}")
|
257
275
|
end
|
258
276
|
|
259
277
|
context "with multiple multiple paragraphs" do
|
@@ -262,12 +280,12 @@ Hello world.
|
|
262
280
|
let(:doc) { Kramdown::Document.new("* #{text1}\n\n #{text2}") }
|
263
281
|
|
264
282
|
it "should convert the other p elements to '.IP \\\\( 2\\n...'" do
|
265
|
-
subject.convert_ul_li(li).
|
283
|
+
expect(subject.convert_ul_li(li)).to eq([
|
266
284
|
".IP \\(bu 2",
|
267
285
|
text1,
|
268
286
|
".IP \\( 2",
|
269
287
|
text2
|
270
|
-
].join("\n")
|
288
|
+
].join("\n"))
|
271
289
|
end
|
272
290
|
end
|
273
291
|
end
|
@@ -279,7 +297,7 @@ Hello world.
|
|
279
297
|
let(:ol) { doc.root.children[0] }
|
280
298
|
|
281
299
|
it "should convert ol elements into '.RS\\n...\\n.RE'" do
|
282
|
-
subject.convert_ol(ol).
|
300
|
+
expect(subject.convert_ol(ol)).to eq([
|
283
301
|
".nr step1 0 1",
|
284
302
|
".RS",
|
285
303
|
".IP \\n+[step1]",
|
@@ -287,7 +305,7 @@ Hello world.
|
|
287
305
|
".IP \\n+[step1]",
|
288
306
|
text2,
|
289
307
|
".RE"
|
290
|
-
].join("\n")
|
308
|
+
].join("\n"))
|
291
309
|
end
|
292
310
|
end
|
293
311
|
|
@@ -297,7 +315,7 @@ Hello world.
|
|
297
315
|
let(:li) { doc.root.children[0].children[0] }
|
298
316
|
|
299
317
|
it "should convert the first p element to '.IP \\\\n+[step0]\\n...'" do
|
300
|
-
subject.convert_ol_li(li).
|
318
|
+
expect(subject.convert_ol_li(li)).to eq(".IP \\n+[step0]\n#{text}")
|
301
319
|
end
|
302
320
|
|
303
321
|
context "with multiple multiple paragraphs" do
|
@@ -306,14 +324,12 @@ Hello world.
|
|
306
324
|
let(:doc) { Kramdown::Document.new("1. #{text1}\n\n #{text2}") }
|
307
325
|
|
308
326
|
it "should convert the other p elements to '.IP \\\\n\\n...'" do
|
309
|
-
|
310
|
-
|
311
|
-
subject.convert_ol_li(li).should == [
|
327
|
+
expect(subject.convert_ol_li(li)).to eq([
|
312
328
|
".IP \\n+[step0]",
|
313
329
|
text1,
|
314
330
|
".IP \\n",
|
315
331
|
text2
|
316
|
-
].join("\n")
|
332
|
+
].join("\n"))
|
317
333
|
end
|
318
334
|
end
|
319
335
|
end
|
@@ -325,27 +341,29 @@ Hello world.
|
|
325
341
|
let(:abbreviation) { doc.root.children[0].children[1] }
|
326
342
|
|
327
343
|
it "should convert abbreviation elements into their text" do
|
328
|
-
subject.convert_abbreviation(abbreviation).
|
344
|
+
expect(subject.convert_abbreviation(abbreviation)).to eq(acronym)
|
329
345
|
end
|
330
346
|
end
|
331
347
|
|
332
348
|
describe "#convert_blockquote" do
|
333
|
-
let(:text)
|
334
|
-
let(:
|
335
|
-
let(:
|
349
|
+
let(:text) { "Some quote." }
|
350
|
+
let(:escaped_text) { 'Some quote\.' }
|
351
|
+
let(:doc) { Kramdown::Document.new("> #{text}") }
|
352
|
+
let(:blockquote) { doc.root.children[0] }
|
336
353
|
|
337
354
|
it "should convert blockquote elements into '.PP\\n.RS\\ntext...\\n.RE'" do
|
338
|
-
subject.convert_blockquote(blockquote).
|
355
|
+
expect(subject.convert_blockquote(blockquote)).to eq(".PP\n.RS\n#{escaped_text}\n.RE")
|
339
356
|
end
|
340
357
|
end
|
341
358
|
|
342
359
|
describe "#convert_codeblock" do
|
343
|
-
let(:code)
|
344
|
-
let(:
|
345
|
-
let(:
|
360
|
+
let(:code) { "puts 'hello world'" }
|
361
|
+
let(:escaped_code) { 'puts \(aqhello world\(aq' }
|
362
|
+
let(:doc) { Kramdown::Document.new(" #{code}\n") }
|
363
|
+
let(:codeblock) { doc.root.children[0] }
|
346
364
|
|
347
365
|
it "should convert codeblock elements into '.nf\\ntext...\\n.fi'" do
|
348
|
-
subject.convert_codeblock(codeblock).
|
366
|
+
expect(subject.convert_codeblock(codeblock)).to eq(".nf\n#{escaped_code}\n.fi")
|
349
367
|
end
|
350
368
|
end
|
351
369
|
|
@@ -355,36 +373,100 @@ Hello world.
|
|
355
373
|
let(:comment) { doc.root.children[0] }
|
356
374
|
|
357
375
|
it "should convert comment elements into '.\\\" text...'" do
|
358
|
-
subject.convert_comment(comment).
|
376
|
+
expect(subject.convert_comment(comment)).to eq(".\\\" #{text}")
|
359
377
|
end
|
360
378
|
end
|
361
379
|
|
362
380
|
describe "#convert_p" do
|
363
|
-
let(:text)
|
364
|
-
let(:
|
365
|
-
let(:
|
381
|
+
let(:text) { "Hello world." }
|
382
|
+
let(:escaped_text) { 'Hello world\.' }
|
383
|
+
let(:doc) { Kramdown::Document.new(text) }
|
384
|
+
let(:p) { doc.root.children[0] }
|
366
385
|
|
367
386
|
it "should convert p elements into '.PP\\ntext'" do
|
368
|
-
subject.convert_p(p).
|
387
|
+
expect(subject.convert_p(p)).to eq(".PP\n#{escaped_text}")
|
369
388
|
end
|
370
389
|
|
371
|
-
context "when the
|
390
|
+
context "when the paragraph starts with a codespan element" do
|
372
391
|
let(:option) { '--foo' }
|
373
392
|
let(:text) { 'Foo bar baz' }
|
374
|
-
let(:doc) { Kramdown::Document.new("`#{option}`\n
|
393
|
+
let(:doc) { Kramdown::Document.new("`#{option}`\n\t#{text}") }
|
394
|
+
|
395
|
+
it "should convert p elements into '.TP\\n\\fB--option\\fR\\ntext...'" do
|
396
|
+
expect(subject.convert_p(p)).to eq(".TP\n\\fB#{option}\\fR\n#{text}")
|
397
|
+
end
|
398
|
+
|
399
|
+
context "when there is only one codespan element" do
|
400
|
+
let(:code) { 'code' }
|
401
|
+
let(:doc) { Kramdown::Document.new("`#{code}`") }
|
402
|
+
|
403
|
+
it "should convert p elements into '.PP\\n\\fB...\\fR'" do
|
404
|
+
expect(subject.convert_p(p)).to eq(".PP\n\\fB#{code}\\fR")
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
context "when there are more than one codespan element" do
|
409
|
+
let(:flag) { '-f' }
|
410
|
+
let(:option) { '--foo' }
|
411
|
+
let(:text) { 'Foo bar baz' }
|
412
|
+
let(:doc) { Kramdown::Document.new("`#{flag}`, `#{option}`\n\t#{text}") }
|
413
|
+
|
414
|
+
it "should convert p elements into '.TP\\n\\fB-o\\fR, \\fB--option\\fR\\ntext...'" do
|
415
|
+
expect(subject.convert_p(p)).to eq(".TP\n\\fB#{flag}\\fR, \\fB#{option}\\fR\n#{text}")
|
416
|
+
end
|
417
|
+
|
418
|
+
context "when there is no newline" do
|
419
|
+
let(:doc) { Kramdown::Document.new("`#{flag}` `#{option}`") }
|
375
420
|
|
376
|
-
|
377
|
-
|
421
|
+
it "should convert the p element into a '.HP\\n...'" do
|
422
|
+
expect(subject.convert_p(p)).to eq(".HP\n\\fB#{flag}\\fR \\fB#{option}\\fR")
|
423
|
+
end
|
424
|
+
end
|
378
425
|
end
|
379
426
|
end
|
380
427
|
|
381
|
-
context "when the
|
382
|
-
let(:option)
|
383
|
-
let(:
|
384
|
-
let(:
|
428
|
+
context "when the paragraph starts with a em element" do
|
429
|
+
let(:option) { '--foo' }
|
430
|
+
let(:escaped_option) { "\\-\\-foo" }
|
431
|
+
let(:text) { 'Foo bar baz' }
|
432
|
+
|
433
|
+
let(:doc) do
|
434
|
+
Kramdown::Document.new("*#{option}*\n\t#{text}")
|
435
|
+
end
|
385
436
|
|
386
|
-
it "should convert p elements into '.TP\\n\\
|
387
|
-
subject.convert_p(p).
|
437
|
+
it "should convert p elements into '.TP\\n\\fI--option\\fP\\ntext...'" do
|
438
|
+
expect(subject.convert_p(p)).to eq(".TP\n\\fI#{escaped_option}\\fP\n#{text}")
|
439
|
+
end
|
440
|
+
|
441
|
+
context "when there is only one em element" do
|
442
|
+
let(:text) { 'foo' }
|
443
|
+
let(:doc) { Kramdown::Document.new("*#{text}*") }
|
444
|
+
|
445
|
+
it "should convert p elements into '.PP\\n\\fI...\\fP'" do
|
446
|
+
expect(subject.convert_p(p)).to eq(".PP\n\\fI#{text}\\fP")
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
context "when there are more than one em element" do
|
451
|
+
let(:flag) { '-f' }
|
452
|
+
let(:escaped_flag) { "\\-f" }
|
453
|
+
let(:text) { 'Foo bar baz' }
|
454
|
+
|
455
|
+
let(:doc) do
|
456
|
+
Kramdown::Document.new("*#{flag}*, *#{option}*\n\t#{text}")
|
457
|
+
end
|
458
|
+
|
459
|
+
it "should convert p elements into '.TP\\n\\fI-o\\fP, \\fI\\-\\-option\\fP\\ntext...'" do
|
460
|
+
expect(subject.convert_p(p)).to eq(".TP\n\\fI#{escaped_flag}\\fP, \\fI#{escaped_option}\\fP\n#{text}")
|
461
|
+
end
|
462
|
+
|
463
|
+
context "when there is no newline" do
|
464
|
+
let(:doc) { Kramdown::Document.new("*#{flag}* *#{option}*") }
|
465
|
+
|
466
|
+
it "should convert the p element into a '.HP\\n...'" do
|
467
|
+
expect(subject.convert_p(p)).to eq(".HP\n\\fI#{escaped_flag}\\fP \\fI#{escaped_option}\\fP")
|
468
|
+
end
|
469
|
+
end
|
388
470
|
end
|
389
471
|
end
|
390
472
|
end
|
@@ -395,7 +477,7 @@ Hello world.
|
|
395
477
|
let(:em) { doc.root.children[0].children[0] }
|
396
478
|
|
397
479
|
it "should convert em elements into '\\fItext\\fP'" do
|
398
|
-
subject.convert_em(em).
|
480
|
+
expect(subject.convert_em(em)).to eq("\\fI#{text}\\fP")
|
399
481
|
end
|
400
482
|
end
|
401
483
|
|
@@ -405,7 +487,7 @@ Hello world.
|
|
405
487
|
let(:strong) { doc.root.children[0].children[0] }
|
406
488
|
|
407
489
|
it "should convert strong elements into '\\fBtext\\fP'" do
|
408
|
-
subject.convert_strong(strong).
|
490
|
+
expect(subject.convert_strong(strong)).to eq("\\fB#{text}\\fP")
|
409
491
|
end
|
410
492
|
end
|
411
493
|
|
@@ -414,36 +496,37 @@ Hello world.
|
|
414
496
|
let(:doc) { Kramdown::Document.new("`#{code}`") }
|
415
497
|
let(:codespan) { doc.root.children[0].children[0] }
|
416
498
|
|
417
|
-
it "should convert codespan elements into '\\
|
418
|
-
subject.convert_codespan(codespan).
|
499
|
+
it "should convert codespan elements into '\\fBcode\\fR'" do
|
500
|
+
expect(subject.convert_codespan(codespan)).to eq("\\fB#{code}\\fR")
|
419
501
|
end
|
420
502
|
end
|
421
503
|
|
422
504
|
describe "#convert_a" do
|
423
|
-
let(:text)
|
424
|
-
let(:href)
|
425
|
-
let(:
|
426
|
-
let(:
|
505
|
+
let(:text) { 'example' }
|
506
|
+
let(:href) { 'http://example.com/' }
|
507
|
+
let(:escaped_href) { 'http:\[sl]\[sl]example\.com\[sl]' }
|
508
|
+
let(:doc) { Kramdown::Document.new("[#{text}](#{href})") }
|
509
|
+
let(:link) { doc.root.children[0].children[0] }
|
427
510
|
|
428
511
|
it "should convert a link elements into 'text\\n.UR href\\n.UE'" do
|
429
|
-
subject.convert_a(link).
|
512
|
+
expect(subject.convert_a(link)).to eq("#{text}\n.UR #{escaped_href}\n.UE")
|
430
513
|
end
|
431
514
|
|
432
515
|
context "when the href begins with mailto:" do
|
433
|
-
let(:text)
|
434
|
-
let(:email)
|
435
|
-
let(:
|
516
|
+
let(:text) { 'Bob' }
|
517
|
+
let(:email) { 'bob@example.com' }
|
518
|
+
let(:escaped_email) { 'bob\[at]example\.com' }
|
519
|
+
let(:doc) { Kramdown::Document.new("[#{text}](mailto:#{email})") }
|
436
520
|
|
437
521
|
it "should convert the link elements into '.MT email\\n.ME'" do
|
438
|
-
subject.convert_a(link).
|
522
|
+
expect(subject.convert_a(link)).to eq("#{text}\n.MT #{escaped_email}\n.ME")
|
439
523
|
end
|
440
524
|
|
441
525
|
context "when link is <email>" do
|
442
|
-
let(:
|
443
|
-
let(:doc) { Kramdown::Document.new("<#{email}>") }
|
526
|
+
let(:doc) { Kramdown::Document.new("<#{email}>") }
|
444
527
|
|
445
528
|
it "should convert the link elements into '.MT email\\n.ME'" do
|
446
|
-
subject.convert_a(link).
|
529
|
+
expect(subject.convert_a(link)).to eq("\n.MT #{escaped_email}\n.ME")
|
447
530
|
end
|
448
531
|
end
|
449
532
|
end
|
@@ -453,7 +536,7 @@ Hello world.
|
|
453
536
|
let(:doc) { Kramdown::Document.new("[#{man}](man:#{man})") }
|
454
537
|
|
455
538
|
it "should convert the link elements into '.BR man'" do
|
456
|
-
subject.convert_a(link).
|
539
|
+
expect(subject.convert_a(link)).to eq("\n.BR #{man}")
|
457
540
|
end
|
458
541
|
|
459
542
|
context "when a section number is specified" do
|
@@ -461,19 +544,19 @@ Hello world.
|
|
461
544
|
let(:doc) { Kramdown::Document.new("[#{man}](man:#{man}(#{section}))") }
|
462
545
|
|
463
546
|
it "should convert the link elements into '.BR man (section)'" do
|
464
|
-
subject.convert_a(link).
|
547
|
+
expect(subject.convert_a(link)).to eq("\n.BR #{man} (#{section})")
|
465
548
|
end
|
466
549
|
end
|
467
550
|
end
|
468
551
|
end
|
469
552
|
|
470
553
|
describe "#escape" do
|
471
|
-
|
472
|
-
subject.escape("hello\\ world").should == "hello\\\\ world"
|
473
|
-
end
|
554
|
+
let(:text) { "hello\nworld" }
|
474
555
|
|
475
|
-
|
476
|
-
|
556
|
+
described_class::GLYPHS.each do |char,glyph|
|
557
|
+
it "should convert #{char.dump} into #{glyph.dump}" do
|
558
|
+
expect(subject.escape("#{text} #{char}")).to eq("#{text} #{glyph}")
|
559
|
+
end
|
477
560
|
end
|
478
561
|
end
|
479
562
|
end
|