rdb man: Titel der Themen-Seiten (dashline, headline ...) aus .TH

This commit is contained in:
wkh
2026-10-11 23:56:05 +02:00
parent 6b9810b075
commit 2e03c0a440
3 changed files with 12 additions and 2 deletions
+5 -2
View File
@@ -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