ruby-changes:44145
From: knu <ko1@a...>
Date: Fri, 23 Sep 2016 21:40:21 +0900 (JST)
Subject: [ruby-changes:44145] knu:r56218 (trunk): Add support for the `Lk` macro to tool/mdoc2man.rb
knu 2016-09-23 21:40:16 +0900 (Fri, 23 Sep 2016) New Revision: 56218 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56218 Log: Add support for the `Lk` macro to tool/mdoc2man.rb Modified files: trunk/ChangeLog trunk/tool/mdoc2man.rb Index: tool/mdoc2man.rb =================================================================== --- tool/mdoc2man.rb (revision 56217) +++ tool/mdoc2man.rb (revision 56218) @@ -82,6 +82,24 @@ class Mdoc2Man https://github.com/ruby/ruby/blob/trunk/tool/mdoc2man.rb#L82 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 https://github.com/ruby/ruby/blob/trunk/tool/mdoc2man.rb#L338 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 https://github.com/ruby/ruby/blob/trunk/tool/mdoc2man.rb#L440 # tags retval << ".TP\n" case words[0] - when 'Pa', 'Ev' + when 'Pa', 'Ev', 'Lk' words.shift retval << '.B' end Index: ChangeLog =================================================================== --- ChangeLog (revision 56217) +++ ChangeLog (revision 56218) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Sep 23 21:38:58 2016 Akinori MUSHA <knu@i...> + + * tool/mdoc2man.rb (Mdoc2Man#parse_macro): Add support for the + `Lk` macro. + + * tool/mdoc2man.rb (Mdoc2Man#shift_arg): A new function to extract + a possibly quoted argument. + Fri Sep 23 20:36:05 2016 Shugo Maeda <shugo@r...> * eval.c (rb_mod_refine): refine modules as well. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/