rdb man: Titel der Themen-Seiten (dashline, headline ...) aus .TH
This commit is contained in:
+5
-2
@@ -148,8 +148,11 @@ Rdb.register('man', 'Display the manual page for a command', 'man [-g] command')
|
||||
args.each do |a|
|
||||
f = File.join(Rdb::ROOT, 'man', "#{a == 'Number' ? 'number.c' : a}.man")
|
||||
File.exist?(f) or die("no manual page for '#{a}'")
|
||||
desc = File.read(f)[/^\.PC\s+"?(.*?)"?\s*$/, 1]
|
||||
puts "#{a}#{desc ? " -- #{troff_clean(desc)}" : ''}", '=' * 60
|
||||
src = File.read(f)
|
||||
desc = src[/^\.PC[ \t]+"?(.*?)"?[ \t]*$/, 1]
|
||||
# topic pages (dash line, head line ...) have an empty .PC; their title is in .TH
|
||||
title = desc.to_s.empty? && src =~ /^\.TH\s+(?:"([^"]*)"|(\S+))/ ? ($1 || $2) : nil
|
||||
puts "#{title || a}#{desc.to_s.empty? ? '' : " -- #{troff_clean(desc)}"}", '=' * 60
|
||||
puts render_man(File.read(f)), ''
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user