md2man 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.markdown CHANGED
@@ -1,3 +1,11 @@
1
+ ## Version 1.3.2 (2012-10-13)
2
+
3
+ Patch:
4
+
5
+ * roff: escape backslashes inside codespan nodes too
6
+
7
+ * roff: escape backslashes inside block\_code nodes
8
+
1
9
  ## Version 1.3.1 (2012-10-09)
2
10
 
3
11
  Patch:
data/bin/md2man CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin =======================================================================
3
3
 
4
- # MD2MAN 1 2012-10-09 1.3.1
4
+ # MD2MAN 1 2012-10-13 1.3.2
5
5
 
6
6
  ## NAME
7
7
 
data/lib/md2man/roff.rb CHANGED
@@ -42,7 +42,8 @@ module Roff
42
42
  end
43
43
 
44
44
  def block_code code, language
45
- block_quote "\n.nf\n#{super.chomp}\n.fi\n"
45
+ code = escape_backslashes(super)
46
+ block_quote "\n.nf\n#{code.chomp}\n.fi\n"
46
47
  end
47
48
 
48
49
  def block_quote quote
@@ -154,9 +155,10 @@ module Roff
154
155
  end
155
156
 
156
157
  def codespan code
158
+ code = escape_backslashes(super)
157
159
  # NOTE: this double font sequence gives us the best of both worlds:
158
160
  # man(1) shows it in bold and `groff -Thtml` shows it in monospace
159
- "\\fB\\fC#{super}\\fR"
161
+ "\\fB\\fC#{code}\\fR"
160
162
  end
161
163
 
162
164
  def link link, title, content
@@ -202,6 +204,10 @@ module Roff
202
204
 
203
205
  private
204
206
 
207
+ def escape_backslashes text
208
+ text.gsub(/\\/, '\&\&')
209
+ end
210
+
205
211
  def remove_leading_pp text
206
212
  text.sub(/\A\n\.PP\n/, '')
207
213
  end
@@ -1,3 +1,3 @@
1
1
  module Md2Man
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
data/man/man1/md2man.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH MD2MAN 1 2012\-10\-09 1.3.1
1
+ .TH MD2MAN 1 2012\-10\-13 1.3.2
2
2
  .SH NAME
3
3
  .PP
4
4
  md2man \- convert
@@ -347,6 +347,31 @@ describe Md2Man::Roff do
347
347
  OUTPUT
348
348
  end
349
349
 
350
+ it 'escapes backslashes inside code blocks' do
351
+ # NOTE: we have to escape backslashes in the INPUT to
352
+ # prevent Ruby from interpreting them as escapes
353
+ @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
354
+ | _______ _______
355
+ | ___ /___________ /__
356
+ | _ __/ __ \\ __/ /_/
357
+ | / /_/ /_/ / / / ,\\
358
+ | \\__/\\____/_/ /_/|_\\
359
+ | >>>------>
360
+ INPUT
361
+ |.PP
362
+ |.RS
363
+ |.nf
364
+ |_______ _______
365
+ | ___ /___________ /__
366
+ | _ __/ __ \\\\ __/ /_/
367
+ | / /_/ /_/ / / / ,\\\\
368
+ | \\\\__/\\\\____/_/ /_/|_\\\\
369
+ | >>>------>
370
+ |.fi
371
+ |.RE
372
+ OUTPUT
373
+ end
374
+
350
375
  it 'renders code spans' do
351
376
  @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
352
377
  |here is `some code` for you
@@ -356,6 +381,17 @@ describe Md2Man::Roff do
356
381
  OUTPUT
357
382
  end
358
383
 
384
+ it 'escapes backslashes inside code spans' do
385
+ # NOTE: we have to escape backslashes in the INPUT to
386
+ # prevent Ruby from interpreting them as escapes
387
+ @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
388
+ |here is `so\\m\\e \\c\\ode` for you
389
+ INPUT
390
+ |.PP
391
+ |here is \\fB\\fCso\\\\m\\\\e \\\\c\\\\ode\\fR for you
392
+ OUTPUT
393
+ end
394
+
359
395
  it 'renders hyperlinks' do
360
396
  @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
361
397
  |Send [me](mailto:foo@bar.baz), e-mail.
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.3.1
4
+ version: 1.3.2
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-11 00:00:00.000000000 Z
12
+ date: 2012-10-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: binman
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
115
  version: '0'
116
116
  segments:
117
117
  - 0
118
- hash: -2252989265192127039
118
+ hash: 3059084899837276996
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  none: false
121
121
  requirements:
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  segments:
126
126
  - 0
127
- hash: -2252989265192127039
127
+ hash: 3059084899837276996
128
128
  requirements: []
129
129
  rubyforge_project:
130
130
  rubygems_version: 1.8.23