kramdown-man 0.1.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
- require_relative '../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  require 'kramdown/man'
4
4
 
5
5
  describe Kramdown::Document, :integration do
6
- let(:man_dir) { File.expand_path('../../../man',__FILE__) }
6
+ let(:man_dir) { File.expand_path('../man',__dir__) }
7
7
  let(:markdown_path) { File.join(man_dir,'kramdown-man.1.md') }
8
8
  let(:markdown) { File.read(markdown_path) }
9
9
 
@@ -11,7 +11,7 @@ describe Kramdown::Document, :integration do
11
11
 
12
12
  describe "#to_man" do
13
13
  it "must return the same output as Kramdown::Converter::Man" do
14
- output, warnings = Kramdown::Converter::Man.convert(subject.root)
14
+ output, warnings = Kramdown::Man::Converter.convert(subject.root)
15
15
 
16
16
  expect(subject.to_man).to be == output
17
17
  end
@@ -1,4 +1,4 @@
1
- require_relative '../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'kramdown/man'
3
3
 
4
4
  describe Kramdown::Man do
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,4 @@
1
1
  require 'rspec'
2
2
  require 'kramdown'
3
+ require 'simplecov'
4
+ SimpleCov.start
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-27 00:00:00.000000000 Z
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -61,21 +61,28 @@ files:
61
61
  - bin/kramdown-man
62
62
  - gemspec.yml
63
63
  - kramdown-man.gemspec
64
- - lib/kramdown/converter/man.rb
65
64
  - lib/kramdown/man.rb
65
+ - lib/kramdown/man/cli.rb
66
+ - lib/kramdown/man/converter.rb
66
67
  - lib/kramdown/man/task.rb
67
68
  - lib/kramdown/man/version.rb
68
69
  - man/kramdown-man.1
69
70
  - man/kramdown-man.1.md
70
- - spec/kramdown/converter/man_spec.rb
71
- - spec/kramdown/document_spec.rb
72
- - spec/kramdown/man_spec.rb
71
+ - spec/cli_spec.rb
72
+ - spec/converter_spec.rb
73
+ - spec/integration_spec.rb
74
+ - spec/man_spec.rb
73
75
  - spec/spec_helper.rb
74
76
  homepage: https://github.com/postmodern/kramdown-man#readme
75
77
  licenses:
76
78
  - MIT
77
- metadata: {}
78
- post_install_message:
79
+ metadata:
80
+ documentation_uri: https://rubydoc.info/gems/kramdown-man
81
+ source_code_uri: https://github.com/postmodern/kramdown-man
82
+ bug_tracker_uri: https://github.com/postmodern/kramdown-man/issues
83
+ changelog_uri: https://github.com/postmodern/kramdown-man/blob/master/ChangeLog.md
84
+ rubygems_mfa_required: 'true'
85
+ post_install_message:
79
86
  rdoc_options: []
80
87
  require_paths:
81
88
  - lib
@@ -90,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
97
  - !ruby/object:Gem::Version
91
98
  version: '0'
92
99
  requirements: []
93
- rubygems_version: 3.2.3
94
- signing_key:
100
+ rubygems_version: 3.4.10
101
+ signing_key:
95
102
  specification_version: 4
96
103
  summary: Converts markdown to man pages
97
104
  test_files: []
@@ -1,562 +0,0 @@
1
- # encoding: utf-8
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'
6
-
7
- describe Kramdown::Converter::Man do
8
- let(:markdown) { File.read('man/kramdown-man.1.md') }
9
- let(:doc) { Kramdown::Document.new(markdown) }
10
- let(:root) { doc.root }
11
-
12
- subject { described_class.send(:new,root,{}) }
13
-
14
- describe "#convert" do
15
- let(:doc) do
16
- Kramdown::Document.new(%{
17
- # Header
18
-
19
- Hello world.
20
- }.strip)
21
- end
22
- let(:root) { doc.root }
23
-
24
- it "should add the header" do
25
- expect(subject.convert(root)).to eq([
26
- described_class::HEADER,
27
- ".TH Header",
28
- ".LP",
29
- ".PP",
30
- 'Hello world\.'
31
- ].join("\n"))
32
- end
33
- end
34
-
35
- describe "#convert_root" do
36
- let(:doc) do
37
- Kramdown::Document.new(%{
38
- # Header
39
-
40
- Hello world.
41
- }.strip)
42
- end
43
-
44
- let(:root) { doc.root }
45
-
46
- it "should convert every element" do
47
- expect(subject.convert_root(root)).to eq([
48
- ".TH Header",
49
- ".LP",
50
- ".PP",
51
- 'Hello world\.'
52
- ].join("\n"))
53
- end
54
- end
55
-
56
- describe "#convert_element" do
57
- let(:doc) { Kramdown::Document.new(" puts 'hello'") }
58
- let(:el) { doc.root.children[0] }
59
-
60
- it "should convert the element based on it's type" do
61
- expect(subject.convert_element(el)).to eq(subject.convert_codeblock(el))
62
- end
63
- end
64
-
65
- describe "#convert_blank" do
66
- let(:doc) { Kramdown::Document.new("foo\n\nbar") }
67
- let(:blank) { doc.root.children[0].children[1] }
68
-
69
- it "should convert blank elements to '.LP'" do
70
- expect(subject.convert_blank(blank)).to eq('.LP')
71
- end
72
- end
73
-
74
- describe "#convert_text" do
75
- let(:content) { 'Foo bar' }
76
- let(:doc) { Kramdown::Document.new(content) }
77
- let(:text) { doc.root.children[0].children[0] }
78
-
79
- it "should convert text elements" do
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
97
- end
98
- end
99
-
100
- describe "#convert_typographic_sym" do
101
- context "ndash" do
102
- let(:doc) { Kramdown::Document.new("-- foo") }
103
- let(:sym) { doc.root.children[0].children[0] }
104
-
105
- it "should convert ndash symbols back into '\-\-'" do
106
- expect(subject.convert_typographic_sym(sym)).to eq("\\-\\-")
107
- end
108
- end
109
-
110
- context "mdash" do
111
- let(:doc) { Kramdown::Document.new("--- foo") }
112
- let(:sym) { doc.root.children[0].children[0] }
113
-
114
- it "should convert mdash symbols into '\[em]'" do
115
- expect(subject.convert_typographic_sym(sym)).to eq('\[em]')
116
- end
117
- end
118
-
119
- context "hellip" do
120
- let(:doc) { Kramdown::Document.new("... foo") }
121
- let(:sym) { doc.root.children[0].children[0] }
122
-
123
- it "should convert mdash symbols into '\\.\\.\\.'" do
124
- expect(subject.convert_typographic_sym(sym)).to eq('\.\.\.')
125
- end
126
- end
127
-
128
- context "laquo" do
129
- let(:doc) { Kramdown::Document.new("<< foo") }
130
- let(:sym) { doc.root.children[0].children[0] }
131
-
132
- it "should convert mdash symbols into '\[Fo]'" do
133
- expect(subject.convert_typographic_sym(sym)).to eq('\[Fo]')
134
- end
135
- end
136
-
137
- context "raquo" do
138
- let(:doc) { Kramdown::Document.new("foo >> bar") }
139
- let(:sym) { doc.root.children[0].children[1] }
140
-
141
- it "should convert mdash symbols into '\[Fc]'" do
142
- expect(subject.convert_typographic_sym(sym)).to eq('\[Fc]')
143
- end
144
- end
145
-
146
- context "laquo_space" do
147
- let(:doc) { Kramdown::Document.new(" << foo") }
148
- let(:sym) { doc.root.children[0].children[0] }
149
-
150
- it "should convert mdash symbols into '\[Fo]'" do
151
- expect(subject.convert_typographic_sym(sym)).to eq('\[Fo]')
152
- end
153
- end
154
-
155
- context "raquo_space" do
156
- let(:doc) { Kramdown::Document.new("foo >> bar") }
157
- let(:sym) { doc.root.children[0].children[1] }
158
-
159
- it "should convert mdash symbols into '\[Fc]'" do
160
- expect(subject.convert_typographic_sym(sym)).to eq('\[Fc]')
161
- end
162
- end
163
- end
164
-
165
- describe "#convert_smart_quote" do
166
- context "lsquo" do
167
- let(:doc) { Kramdown::Document.new("'hello world'") }
168
- let(:quote) { doc.root.children[0].children.first }
169
-
170
- it "should convert lsquo quotes into '\[oq]'" do
171
- expect(subject.convert_smart_quote(quote)).to eq('\[oq]')
172
- end
173
- end
174
-
175
- context "rsquo" do
176
- let(:doc) { Kramdown::Document.new("'hello world'") }
177
- let(:quote) { doc.root.children[0].children.last }
178
-
179
- it "should convert rsquo quotes into '\[cq]'" do
180
- expect(subject.convert_smart_quote(quote)).to eq('\[cq]')
181
- end
182
- end
183
-
184
- context "ldquo" do
185
- let(:doc) { Kramdown::Document.new('"hello world"') }
186
- let(:quote) { doc.root.children[0].children.first }
187
-
188
- it "should convert lsquo quotes into '\[lq]'" do
189
- expect(subject.convert_smart_quote(quote)).to eq('\[lq]')
190
- end
191
- end
192
-
193
- context "rdquo" do
194
- let(:doc) { Kramdown::Document.new('"hello world"') }
195
- let(:quote) { doc.root.children[0].children.last }
196
-
197
- it "should convert lsquo quotes into '\[rq]'" do
198
- expect(subject.convert_smart_quote(quote)).to eq('\[rq]')
199
- end
200
- end
201
- end
202
-
203
- describe "#convert_header" do
204
- context "when level is 1" do
205
- let(:doc) { Kramdown::Document.new("# Header") }
206
- let(:header) { doc.root.children[0] }
207
-
208
- it "should convert level 1 headers into '.TH text'" do
209
- expect(subject.convert_header(header)).to eq(".TH Header")
210
- end
211
- end
212
-
213
- context "when level is 2" do
214
- let(:doc) { Kramdown::Document.new("## Header") }
215
- let(:header) { doc.root.children[0] }
216
-
217
- it "should convert level 2 headers into '.SH text'" do
218
- expect(subject.convert_header(header)).to eq(".SH Header")
219
- end
220
- end
221
-
222
- context "when level is 3" do
223
- let(:doc) { Kramdown::Document.new("### Header") }
224
- let(:header) { doc.root.children[0] }
225
-
226
- it "should convert level 2 headers into '.SS text'" do
227
- expect(subject.convert_header(header)).to eq(".SS Header")
228
- end
229
- end
230
-
231
- context "when level is 4 or greater" do
232
- let(:doc) { Kramdown::Document.new("#### Header") }
233
- let(:header) { doc.root.children[0] }
234
-
235
- it "should convert level 2 headers into '.SS text'" do
236
- expect(subject.convert_header(header)).to eq(".SS Header")
237
- end
238
- end
239
- end
240
-
241
- describe "#convert_hr" do
242
- let(:doc) { Kramdown::Document.new('------------------------------------') }
243
- let(:hr) { doc.root.children[0] }
244
-
245
- it "should convert hr elements into '.ti 0\\n\\\\l'\\\\n(.lu\\''" do
246
- expect(subject.convert_hr(hr)).to eq(".ti 0\n\\l'\\n(.lu'")
247
- end
248
- end
249
-
250
- describe "#convert_ul" do
251
- let(:text1) { 'foo' }
252
- let(:text2) { 'bar' }
253
- let(:doc) { Kramdown::Document.new("* #{text1}\n* #{text2}") }
254
- let(:ul) { doc.root.children[0] }
255
-
256
- it "should convert ul elements into '.RS\\n...\\n.RE'" do
257
- expect(subject.convert_ul(ul)).to eq([
258
- ".RS",
259
- ".IP \\(bu 2",
260
- text1,
261
- ".IP \\(bu 2",
262
- text2,
263
- ".RE"
264
- ].join("\n"))
265
- end
266
- end
267
-
268
- describe "#convert_ul_li" do
269
- let(:text) { 'hello world' }
270
- let(:doc) { Kramdown::Document.new("* #{text}") }
271
- let(:li) { doc.root.children[0].children[0] }
272
-
273
- it "should convert the first p element to '.IP \\\\(bu 2\\n...'" do
274
- expect(subject.convert_ul_li(li)).to eq(".IP \\(bu 2\n#{text}")
275
- end
276
-
277
- context "with multiple multiple paragraphs" do
278
- let(:text1) { 'hello' }
279
- let(:text2) { 'world' }
280
- let(:doc) { Kramdown::Document.new("* #{text1}\n\n #{text2}") }
281
-
282
- it "should convert the other p elements to '.IP \\\\( 2\\n...'" do
283
- expect(subject.convert_ul_li(li)).to eq([
284
- ".IP \\(bu 2",
285
- text1,
286
- ".IP \\( 2",
287
- text2
288
- ].join("\n"))
289
- end
290
- end
291
- end
292
-
293
- describe "#convert_ol" do
294
- let(:text1) { 'foo' }
295
- let(:text2) { 'bar' }
296
- let(:doc) { Kramdown::Document.new("1. #{text1}\n2. #{text2}") }
297
- let(:ol) { doc.root.children[0] }
298
-
299
- it "should convert ol elements into '.RS\\n...\\n.RE'" do
300
- expect(subject.convert_ol(ol)).to eq([
301
- ".nr step1 0 1",
302
- ".RS",
303
- ".IP \\n+[step1]",
304
- text1,
305
- ".IP \\n+[step1]",
306
- text2,
307
- ".RE"
308
- ].join("\n"))
309
- end
310
- end
311
-
312
- describe "#convert_ol_li" do
313
- let(:text) { 'hello world' }
314
- let(:doc) { Kramdown::Document.new("1. #{text}") }
315
- let(:li) { doc.root.children[0].children[0] }
316
-
317
- it "should convert the first p element to '.IP \\\\n+[step0]\\n...'" do
318
- expect(subject.convert_ol_li(li)).to eq(".IP \\n+[step0]\n#{text}")
319
- end
320
-
321
- context "with multiple multiple paragraphs" do
322
- let(:text1) { 'hello' }
323
- let(:text2) { 'world' }
324
- let(:doc) { Kramdown::Document.new("1. #{text1}\n\n #{text2}") }
325
-
326
- it "should convert the other p elements to '.IP \\\\n\\n...'" do
327
- expect(subject.convert_ol_li(li)).to eq([
328
- ".IP \\n+[step0]",
329
- text1,
330
- ".IP \\n",
331
- text2
332
- ].join("\n"))
333
- end
334
- end
335
- end
336
-
337
- describe "#convert_abbreviation" do
338
- let(:acronym) { 'HTML' }
339
- let(:definition) { 'Hyper Text Markup Language' }
340
- let(:doc) { Kramdown::Document.new("This is an #{acronym} example.\n\n*[#{acronym}]: #{definition}") }
341
- let(:abbreviation) { doc.root.children[0].children[1] }
342
-
343
- it "should convert abbreviation elements into their text" do
344
- expect(subject.convert_abbreviation(abbreviation)).to eq(acronym)
345
- end
346
- end
347
-
348
- describe "#convert_blockquote" do
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] }
353
-
354
- it "should convert blockquote elements into '.PP\\n.RS\\ntext...\\n.RE'" do
355
- expect(subject.convert_blockquote(blockquote)).to eq(".PP\n.RS\n#{escaped_text}\n.RE")
356
- end
357
- end
358
-
359
- describe "#convert_codeblock" do
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] }
364
-
365
- it "should convert codeblock elements into '.nf\\ntext...\\n.fi'" do
366
- expect(subject.convert_codeblock(codeblock)).to eq(".nf\n#{escaped_code}\n.fi")
367
- end
368
- end
369
-
370
- describe "#convert_comment" do
371
- let(:text) { "Copyright (c) 2013" }
372
- let(:doc) { Kramdown::Document.new("{::comment}\n#{text}\n{:/comment}") }
373
- let(:comment) { doc.root.children[0] }
374
-
375
- it "should convert comment elements into '.\\\" text...'" do
376
- expect(subject.convert_comment(comment)).to eq(".\\\" #{text}")
377
- end
378
- end
379
-
380
- describe "#convert_p" do
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] }
385
-
386
- it "should convert p elements into '.PP\\ntext'" do
387
- expect(subject.convert_p(p)).to eq(".PP\n#{escaped_text}")
388
- end
389
-
390
- context "when the paragraph starts with a codespan element" do
391
- let(:option) { '--foo' }
392
- let(:text) { 'Foo bar baz' }
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}`") }
420
-
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
425
- end
426
- end
427
-
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
436
-
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
470
- end
471
- end
472
- end
473
-
474
- describe "#convert_em" do
475
- let(:text) { "hello world" }
476
- let(:doc) { Kramdown::Document.new("*#{text}*") }
477
- let(:em) { doc.root.children[0].children[0] }
478
-
479
- it "should convert em elements into '\\fItext\\fP'" do
480
- expect(subject.convert_em(em)).to eq("\\fI#{text}\\fP")
481
- end
482
- end
483
-
484
- describe "#convert_strong" do
485
- let(:text) { "hello world" }
486
- let(:doc) { Kramdown::Document.new("**#{text}**") }
487
- let(:strong) { doc.root.children[0].children[0] }
488
-
489
- it "should convert strong elements into '\\fBtext\\fP'" do
490
- expect(subject.convert_strong(strong)).to eq("\\fB#{text}\\fP")
491
- end
492
- end
493
-
494
- describe "#convert_codespan" do
495
- let(:code) { "puts 'hello world'" }
496
- let(:doc) { Kramdown::Document.new("`#{code}`") }
497
- let(:codespan) { doc.root.children[0].children[0] }
498
-
499
- it "should convert codespan elements into '\\fBcode\\fR'" do
500
- expect(subject.convert_codespan(codespan)).to eq("\\fB#{code}\\fR")
501
- end
502
- end
503
-
504
- describe "#convert_a" do
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] }
510
-
511
- it "should convert a link elements into 'text\\n.UR href\\n.UE'" do
512
- expect(subject.convert_a(link)).to eq("#{text}\n.UR #{escaped_href}\n.UE")
513
- end
514
-
515
- context "when the href begins with mailto:" do
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})") }
520
-
521
- it "should convert the link elements into '.MT email\\n.ME'" do
522
- expect(subject.convert_a(link)).to eq("#{text}\n.MT #{escaped_email}\n.ME")
523
- end
524
-
525
- context "when link is <email>" do
526
- let(:doc) { Kramdown::Document.new("<#{email}>") }
527
-
528
- it "should convert the link elements into '.MT email\\n.ME'" do
529
- expect(subject.convert_a(link)).to eq("\n.MT #{escaped_email}\n.ME")
530
- end
531
- end
532
- end
533
-
534
- context "when the href begins with man:" do
535
- let(:man) { 'bash' }
536
- let(:doc) { Kramdown::Document.new("[#{man}](man:#{man})") }
537
-
538
- it "should convert the link elements into '.BR man'" do
539
- expect(subject.convert_a(link)).to eq("\n.BR #{man}")
540
- end
541
-
542
- context "when a section number is specified" do
543
- let(:section) { '1' }
544
- let(:doc) { Kramdown::Document.new("[#{man}](man:#{man}(#{section}))") }
545
-
546
- it "should convert the link elements into '.BR man (section)'" do
547
- expect(subject.convert_a(link)).to eq("\n.BR #{man} (#{section})")
548
- end
549
- end
550
- end
551
- end
552
-
553
- describe "#escape" do
554
- let(:text) { "hello\nworld" }
555
-
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
560
- end
561
- end
562
- end