Permalink
Browse files

make reference regexp generic to match any manpage

  • Loading branch information...
1 parent 609802f commit fceedcf7312f75344cbb05d672f3fd2498202714 @sunaku committed Oct 9, 2012
Showing with 28 additions and 1 deletion.
  1. +3 −1 lib/md2man/document.rb
  2. +25 −0 test/md2man/roff_test.rb
View
@@ -103,7 +103,9 @@ def encode object
private
def encode_references text
- text.gsub(/(\S+)\(([1-9nol])\)([[:punct:]]?[^\n\S]*)/) do
+ # the [^\n\S] captures all non-newline whitespace
+ # basically, it's meant to be \s but excluding \n
+ text.gsub(/([\w\-\.]+)\((\w+)\)(\S*[^\n\S]*)/) do
match = $~
key = encode(match)
@references[key] = match
View
@@ -661,4 +661,29 @@ def heredoc document
|this is a code span \\fB\\fCcontaining markdown(7), roff(7), and\\fR much more!
OUTPUT
end
+
+ it 'renders references to manual pages present on my linux box' do
+ @markdown.render(heredoc(<<-INPUT)).must_equal(heredoc(<<-OUTPUT))
+ |man(1)
+ |man-pages(7)
+ |ld.so(8)
+ |ld-linux.so(8)
+ |ld-linux(8)
+ |aio.h(0p)
+ |vi(1p)
+ |vfork(3p)
+ |exit(3tcl)
+ INPUT
+ |.PP
+ |.BR man (1)
+ |.BR man-pages (7)
+ |.BR ld.so (8)
+ |.BR ld-linux.so (8)
+ |.BR ld-linux (8)
+ |.BR aio.h (0p)
+ |.BR vi (1p)
+ |.BR vfork (3p)
+ |.BR exit (3tcl)
+ OUTPUT
+ end
end

0 comments on commit fceedcf

Please sign in to comment.