summaryrefslogtreecommitdiff
path: root/tool/mdoc2man.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-23 12:40:16 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-23 12:40:16 +0000
commit9d5bc13fdbb0541e078d0ffd89036052d9e8f4d8 (patch)
treed42bb38d069b8fb66b8ab47de939e4b457b40bb8 /tool/mdoc2man.rb
parent4d3e3c2550ca38ed23d3fb19cd86929b019efdf5 (diff)
Add support for the `Lk` macro to tool/mdoc2man.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/mdoc2man.rb')
-rwxr-xr-xtool/mdoc2man.rb52
1 files changed, 42 insertions, 10 deletions
diff --git a/tool/mdoc2man.rb b/tool/mdoc2man.rb
index 610feac..e005fcf 100755
--- a/tool/mdoc2man.rb
+++ b/tool/mdoc2man.rb
@@ -82,6 +82,24 @@ class Mdoc2Man
initialize
end
+ def shift_arg(words)
+ case words[0]
+ when nil, RE_PUNCT
+ nil
+ when /\A"(.+)/
+ words.shift
+ word = $1
+ loop {
+ break if word.chomp!('"')
+ token = words.shift or break
+ word << ' ' << token
+ }
+ word
+ else
+ words.shift
+ end
+ end
+
def parse_macro(line)
words = line.split
retval = ''
@@ -320,15 +338,29 @@ class Mdoc2Man
next
end
- if word == 'Pa' && !quote.include?(OPTION)
- retval << '\\fI'
- retval << '\\&' if /^\./ =~ words[0]
- retval << words.shift << '\\fP'
- while RE_PUNCT =~ words[0]
- retval << words.shift
- end
- # @nospace = 1 if @nospace == 0 && RE_PUNCT =~ words[0]
- next
+ case word
+ when 'Pa'
+ if !quote.include?(OPTION)
+ retval << '\\fI'
+ retval << '\\&' if /^\./ =~ words[0]
+ retval << words.shift << '\\fP'
+ while RE_PUNCT =~ words[0]
+ retval << words.shift
+ end
+ # @nospace = 1 if @nospace == 0 && RE_PUNCT =~ words[0]
+ next
+ end
+ when 'Lk'
+ if !quote.include?(OPTION)
+ url = words.shift
+ if name = shift_arg(words)
+ retval << '\\fI' << name << ':\\fP '
+ end
+ retval << '\\fB'
+ retval << '\\&' if /\A\./ =~ url
+ retval << url << '\\fP'
+ next
+ end
end
case word
@@ -408,7 +440,7 @@ class Mdoc2Man
# tags
retval << ".TP\n"
case words[0]
- when 'Pa', 'Ev'
+ when 'Pa', 'Ev', 'Lk'
words.shift
retval << '.B'
end